-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[add] add files to build Docekr image for cvtk package.
- Loading branch information
jsun
committed
Aug 11, 2024
1 parent
06567bf
commit 393ed0b
Showing
5 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
``` | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |