Skip to content

Commit

Permalink
[add] add files to build Docekr image for cvtk package.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsun committed Aug 11, 2024
1 parent 06567bf commit 393ed0b
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 0 deletions.
42 changes: 42 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

ARG PYTORCH="2.3.1"
ARG CUDA="12.1"
ARG CUDNN="8"
FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel

ARG UID
ARG GID
ARG USERNAME
ARG GROUPNAME

#setup environment
ENV FORCE_CUDA="1" \
TORCH_CUDA_ARCH_LIST="6.0 6.1 7.0 7.5 8.0 8.6+PTX" \
PATH="/usr/local/cuda/bin:$PATH" \
TORCH_NVCC_FLAGS="-Xfatbin -compress-all" \
CMAKE_PREFIX_PATH="$(dirname $(which conda))/../" MMCV_WITH_OPS="1"

# installation
RUN apt update \
&& apt install -y git libgl1 libglib2.0-0 ffmpeg libturbojpeg libsm6 libxext6 ninja-build libxrender-dev \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* \
&& git clone https://github.com/open-mmlab/mmcv.git -b v2.1.0 mmcv-v2.1.0 \
&& cd mmcv-v2.1.0 \
&& pip install --no-cache-dir -r ./requirements/build.txt \
&& pip install --no-cache-dir .[all] -v \
&& cd .. \
&& git clone https://github.com/open-mmlab/mmdetection.git -b v3.3.0 mmdet-v3.3.0 \
&& cd mmdet-v3.3.0 \
&& pip install --no-cache-dir -r ./requirements/build.txt \
&& pip install --no-cache-dir . -v \
&& cd .. \
&& rm -rf ./mmcv-v2.1.0 ./mmdet-v3.3.0


RUN groupadd -g ${GID} ${GROUPNAME} -f \
&& useradd -m -s /bin/bash -u ${UID} -g ${GID} ${USERNAME} \
&& echo 'export PATH=~/.local/bin:${PATH}' >> /home/${USERNAME}/.bashrc
USER ${USERNAME}
RUN pip install -U cvtk
WORKDIR /home/${USERNAME}
22 changes: 22 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Dockerfile for cvtk package

To build the cvtk Docker image, run the following command.

```bash
bash build.sh
```


To start the Docker container for the cvtk package after build,
run the following command.
If necessary, the directory to mount and the port number
to communicate with the host
can be changed by editing the docker-compose.yml file.


```bash
bash run.sh
```



7 changes: 7 additions & 0 deletions docker/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bash/bin

sudo env USERNAME="$(id -un)" docker compose build \
--build-arg UID="$(id -u)" \
--build-arg GID="$(id -g)" \
--build-arg USERNAME="$(id -un)" \
--build-arg GROUPNAME="$(id -un)"
27 changes: 27 additions & 0 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
services:
devel-env:
image: "devel:${USERNAME}"
build:
context: .
dockerfile: Dockerfile
args:
- UID:1000
- GID:1000
- USERNAME:ubuntu
- GROUPNAME:ubuntu
container_name: "DevEnv-${USERNAME}"
network_mode: host
ports:
- "80:80"
- "8080:8080"
shm_size: "12gb"
deploy:
resources:
reservations:
devices:
- capabilities: [gpu]
volumes:
# mounting home directory result in the ambiguity of shell configurations (e.g. .bashrc)
- type: bind
source: "/home/${USERNAME}/workspace"
target: "/home/${USERNAME}/workspace"
8 changes: 8 additions & 0 deletions docker/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bash/bin

sudo USERNAME="$(id -un)" docker compose run -it --rm \
-e UID="$(id -u)" \
-e GID="$(id -g)" \
-e USERNAME="$(id -un)" \
-e GROUPNAME="$(id -un)" \
devel-env

0 comments on commit 393ed0b

Please sign in to comment.