Skip to content

Commit 26cff2b

Browse files
author
Dominik Falkner
committed
Add devcontainer support with CUDA
1 parent 1ed9984 commit 26cff2b

3 files changed

Lines changed: 101 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ A simple [Cookiecutter](https://github.com/cookiecutter/cookiecutter) template f
1313
## Batteries Included
1414

1515
- **Packaging and dependency management** with [Poetry](https://github.com/python-poetry/poetry)
16+
- **Ready to use CUDA DEVCONTAINER** with [devcontainers](https://containers.dev/)
1617
- **Task running** with [Poe the Poet](https://github.com/nat-n/poethepoet)
1718
- **Pre defined** tasks
1819
- **Code formatting** with [Black](https://github.com/psf/black), [isort](https://github.com/PyCQA/isort)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-dockerfile
3+
{
4+
"name": "CUDA Container ",
5+
"build": {
6+
// Sets the run context to one level up instead of the .devcontainer folder.
7+
"context": "..",
8+
// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
9+
"dockerfile": "../Dockerfile-cuda"
10+
},
11+
"features": {
12+
"ghcr.io/devcontainers/features/git-lfs:1": {
13+
"autoPull": true,
14+
"version": "latest"
15+
}
16+
},
17+
"runArgs": [
18+
"--gpus=all"
19+
],
20+
21+
// Features to add to the dev container. More info: https://containers.dev/features.
22+
// "features": {},
23+
24+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
25+
// "forwardPorts": [],
26+
27+
// Uncomment the next line to run commands after the container is created.
28+
// "postCreateCommand": "cat /etc/os-release",
29+
30+
// Configure tool-specific properties.
31+
// "customizations": {},
32+
33+
// Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root.
34+
// "remoteUser": "devcontainer"
35+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# This dockerfile serves as a base for all testing images.
2+
# It contains the minimal dependencies and is therefore smaller.
3+
from nvidia/cuda:12.3.1-runtime-ubuntu22.04
4+
ARG PYTHON_VERSION=3.10
5+
ARG POETRY_VERSION=1.7.1
6+
7+
ENV DEBIAN_FRONTEND noninteractive
8+
LABEL maintainer="Dominik Falkner <dominik.falkner@risc-software.at>"
9+
10+
RUN apt-get update --allow-insecure-repositories && apt-get install -yq \
11+
build-essential \
12+
# provides nohup command
13+
coreutils \
14+
# editor
15+
vim \
16+
libssl-dev \
17+
zlib1g-dev \
18+
libbz2-dev \
19+
libreadline-dev \
20+
libsqlite3-dev \
21+
curl \
22+
libncursesw5-dev \
23+
xz-utils \
24+
tk-dev \
25+
libxml2-dev \
26+
libxmlsec1-dev \
27+
libffi-dev \
28+
liblzma-dev \
29+
git \
30+
python3-distutils \
31+
&& rm -rf /var/lib/apt/lists/*
32+
33+
ENV PYENV_ROOT $HOME/.pyenv
34+
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
35+
36+
# Install pyenv
37+
RUN set -ex \
38+
&& curl https://pyenv.run | bash \
39+
&& pyenv update \
40+
&& eval "$(pyenv init -)" && pyenv --version
41+
42+
# Install python and set interpreter
43+
RUN pyenv install -s ${PYTHON_VERSION} && pyenv global ${PYTHON_VERSION}
44+
45+
# Install and configure Poetry
46+
ENV POETRY_VERSION=${POETRY_VERSION} \
47+
POETRY_HOME=/opt/poetry \
48+
POETRY_VIRTUALENVS_CREATE=false
49+
RUN curl -sSL https://install.python-poetry.org | python -
50+
ENV PATH="${PATH}:${POETRY_HOME}/bin"
51+
52+
# Setup directory structure
53+
RUN mkdir /repo
54+
WORKDIR /repo
55+
# set pythonpath for nvidia image
56+
ENV PYTHONPATH "${PYTHONPATH}:/repo"
57+
58+
# Install dependencies (package itself is not installed)
59+
COPY pyproject.toml poetry.lock .
60+
RUN poetry install --all-extras --no-root
61+
62+
# Copy the rest of the repository
63+
ADD . .
64+
65+
ENTRYPOINT ["tail", "-f", "/dev/null"]

0 commit comments

Comments
 (0)