Skip to content

Commit

Permalink
Merge pull request #33 from aisingapore/0.3.1-cvgpu
Browse files Browse the repository at this point in the history
[Fix] 0.3.1 - Get GPU image to use GPU resources
  • Loading branch information
Syakyr authored Mar 21, 2024
2 parents 6adc5af + 7e4f419 commit 8ed4c12
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 17 deletions.
6 changes: 4 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ pages:
before_script:
- pip install -r mkdocs-requirements.txt
script:
- mkdocs build --strict --verbose --site-dir public
- mkdocs build --verbose --site-dir public
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
needs: []

update:onprem-runai:
stage: update
Expand All @@ -40,4 +41,5 @@ update:onprem-runai:
- cp -rv ../git-repo/.git .
- git add .
- git commit -m "$CI_COMMIT_MESSAGE" || echo "Nothing to commit"
- git push origin $CI_COMMIT_BRANCH || echo "Nothing to push"
- git push origin $CI_COMMIT_BRANCH || echo "Nothing to push"
needs: []
18 changes: 3 additions & 15 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,9 @@

def populate_problem(problem_domain: str) -> None:

SUB_DIRS = ["src", "conf", "notebooks", "aisg-context"]

for subdir in SUB_DIRS:

working_dir = os.getcwd()
src_dir = os.path.join(working_dir, "problem-templates", problem_domain)
shutil.copytree(
os.path.join(src_dir, subdir),
os.path.join(working_dir, subdir),
dirs_exist_ok=True
)
shutil.copy2(
os.path.join(src_dir, "{{cookiecutter.repo_name}}-conda-env.yaml"),
os.path.join(working_dir, "{{cookiecutter.repo_name}}-conda-env.yaml")
)
working_dir = os.getcwd()
src_dir = os.path.join(working_dir, "problem-templates", problem_domain)
shutil.copytree(src_dir, working_dir, dirs_exist_ok=True)


def generate_template_scripts() -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,16 @@ and connect to http://localhost:5000.
We shall build the Docker image from the Docker file
`docker/{{cookiecutter.repo_name}}-gpu.Dockerfile`:

!!! warning "Attention"

If you're only using CPUs for training, then you can just use
`docker/{{cookiecutter.repo_name}}-cpu.Dockerfile` instead for
smaller image size.
If you're using AMD GPUs for training, you can copy the components
from the [`rocm`][rocm] folder in the Kapitan Hull repository.

[rocm]: https://github.com/aisingapore/kapitan-hull/tree/main/rocm

=== "Linux/macOS"

```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,16 @@ and connect to http://localhost:5000.
We shall build the Docker image from the Docker file
`docker/{{cookiecutter.repo_name}}-gpu.Dockerfile`:

!!! warning "Attention"

If you're only using CPUs for training, then you can just use
`docker/{{cookiecutter.repo_name}}-cpu.Dockerfile` instead for
smaller image size.
If you're using AMD GPUs for training, you can copy the components
from the [`rocm`][rocm] folder in the Kapitan Hull repository.

[rocm]: https://github.com/aisingapore/kapitan-hull/tree/main/rocm

=== "Linux/macOS"

```bash
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
FROM ubuntu:20.04

ARG DEBIAN_FRONTEND="noninteractive"

ARG NON_ROOT_USER="aisg"
ARG NON_ROOT_UID="2222"
ARG NON_ROOT_GID="2222"
ARG HOME_DIR="/home/${NON_ROOT_USER}"

ARG REPO_DIR="."
ARG CONDA_ENV_FILE="{{cookiecutter.repo_name}}-conda-env-gpu.yaml"
ARG CONDA_ENV_NAME="{{cookiecutter.repo_name}}"

# Miniconda arguments
ARG CONDA_HOME="/miniconda3"
ARG CONDA_BIN="${CONDA_HOME}/bin/conda"
ARG CONDA_VER="py310_23.5.2-0"
ARG CONDA_ARCH="Linux-x86_64"
ARG MINICONDA_SH="Miniconda3-${CONDA_VER}-${CONDA_ARCH}.sh"

RUN useradd -l -m -s /bin/bash -u ${NON_ROOT_UID} ${NON_ROOT_USER} && \
mkdir -p ${CONDA_HOME} && \
chown -R ${NON_ROOT_USER}:${NON_ROOT_GID} ${CONDA_HOME}

RUN apt-get update && \
apt-get -y install bzip2 curl wget gcc rsync git vim locales && \
sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
locale-gen && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8 && \
apt-get clean

ENV PYTHONIOENCODING utf8
ENV LANG "C.UTF-8"
ENV LC_ALL "C.UTF-8"

USER ${NON_ROOT_USER}
WORKDIR ${HOME_DIR}

COPY --chown=${NON_ROOT_USER}:${NON_ROOT_GID} ${REPO_DIR} {{cookiecutter.repo_name}}

# Install Miniconda
RUN curl -O https://repo.anaconda.com/miniconda/$MINICONDA_SH && \
chmod +x ${MINICONDA_SH} && \
./${MINICONDA_SH} -u -b -p ${CONDA_HOME} && \
rm ${MINICONDA_SH}
ENV PATH ${CONDA_HOME}/bin:${HOME_DIR}/.local/bin:$PATH

# Install conda environment
RUN ${CONDA_BIN} env create -f {{cookiecutter.repo_name}}/${CONDA_ENV_FILE} && \
${CONDA_BIN} init bash && \
${CONDA_BIN} clean -a -y && \
echo "source activate ${CONDA_ENV_NAME}" >> "${HOME_DIR}/.bashrc"
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: {{cookiecutter.repo_name}}
channels:
- defaults
- pytorch
- nvidia
- conda-forge
dependencies:
- pytorch=2.1.2
- torchvision=0.16.2
- pytorch-cuda=12.1
- python=3.11.7
- pip=23.3.2
- pip:
- mlflow-skinny==2.9.2
- hydra-core==1.3.2
- hydra-optuna-sweeper==1.2.0
- python-json-logger==2.0.7
- fastapi==0.109.0
- uvicorn[standard]==0.25.0
- python-multipart==0.0.6
- jsonlines==4.0.0
- pandas==2.1.4
- gunicorn==21.2.0
- pydantic==2.5.3
- pydantic-settings==2.1.0
- ipykernel==6.25.0

0 comments on commit 8ed4c12

Please sign in to comment.