Skip to content

Commit 94f4d1a

Browse files
author
BigJohhn
committed
add docker support
1 parent 3843e4c commit 94f4d1a

File tree

7 files changed

+224
-0
lines changed

7 files changed

+224
-0
lines changed

docker/10_nvidia.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"file_format_version" : "1.0.0",
3+
"ICD" : {
4+
"library_path" : "libEGL_nvidia.so.0"
5+
}
6+
}
7+

docker/Dockerfile

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# 1stly, to build zeroth-bot-sim:v0
2+
# FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu20.04
3+
4+
# COPY sources.list /etc/apt/sources.list
5+
6+
# RUN mkdir /root/.pip
7+
# COPY pip.conf /root/.pip/pip.conf
8+
9+
# RUN apt install -y wget zlib1g-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev libtk8.6 libgdm-dev libdb4o-cil-dev libpcap-dev
10+
# RUN wget https://mirrors.huaweicloud.com/python/3.8.19/Python-3.8.19.tar.xz && tar -xvf Python-3.8.19.tar.xz
11+
12+
# WORKDIR /root/Python-3.8.19
13+
# RUN ./configure --prefix=/usr/local && make && make install
14+
15+
# WORKDIR /usr/local/bin/
16+
# RUN ln -s pip3 pip
17+
18+
# WORKDIR /app/sim/
19+
# RUN make install-dev
20+
21+
# RUN wget https://developer.nvidia.com/isaac-gym-preview-4
22+
# # RUN tar -xvf
23+
# RUN make install-third-party-external
24+
25+
FROM zeroth-bot-sim:v0
26+
27+
WORKDIR /root
28+
29+
RUN apt update
30+
31+
# on vnc client use <your docker ip>:5901
32+
RUN apt update && apt install -y \
33+
--no-install-recommends \
34+
libxcursor-dev \
35+
libxrandr-dev \
36+
libxinerama-dev \
37+
libxi-dev \
38+
mesa-common-dev \
39+
zip \
40+
unzip \
41+
make \
42+
vulkan-utils \
43+
mesa-vulkan-drivers \
44+
pigz \
45+
git \
46+
libegl1
47+
48+
# WAR for eglReleaseThread shutdown crash in libEGL_mesa.so.0 (ensure it's never detected/loaded)
49+
# Can't remove package libegl-mesa0 directly (because of libegl1 which we need)
50+
RUN rm /usr/lib/x86_64-linux-gnu/libEGL_mesa.so.0 /usr/lib/x86_64-linux-gnu/libEGL_mesa.so.0.0.0 /usr/share/glvnd/egl_vendor.d/50_mesa.json
51+
52+
COPY ./nvidia_icd.json /usr/share/vulkan/icd.d/nvidia_icd.json
53+
COPY ./10_nvidia.json /usr/share/glvnd/egl_vendor.d/10_nvidia.json
54+
55+
56+
WORKDIR /app/sim
57+
58+
RUN useradd --create-home gymuser
59+
USER gymuser
60+
61+
# copy gym repo to docker
62+
COPY --chown=gymuser . .
63+
64+
# install gym modules
65+
ENV PATH="/home/gymuser/.local/bin:$PATH"
66+
67+
RUN export MODEL_DIR=sim/resources/stompymicro
68+
69+
ENV NVIDIA_VISIBLE_DEVICES=all NVIDIA_DRIVER_CAPABILITIES=all
70+
71+
CMD ["tail","-f", "/dev/null"]
72+
73+
# CMD ["python3", "sim/train.py", "--task=stompymicro", "--num_envs=4"]
74+
# python3 sim/train.py --task=stompymicro --num_envs=4
75+

docker/README.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
Preliminaries
2+
```
3+
Ensure nvidia-smi is work on your host machine.
4+
```
5+
6+
There is a prebuilt docker image, tested on a amd64 machine, with Ubuntu 24.04 LTS.
7+
```
8+
docker pull ghcr.io/bigjohnn/zeroth-bot-sim:v1
9+
```
10+
11+
But if that not work, maybe you can build it by yourself.
12+
13+
Make some changes in your Dockerfile && docker-compose.yml.
14+
```
15+
PREBUILD a docker image that have external dependencies
16+
17+
# 1stly, to build zeroth-bot-sim:v0
18+
# FROM nvidia/cuda:12.1.0-cudnn8-devel-ubuntu20.04
19+
20+
# COPY sources.list /etc/apt/sources.list
21+
22+
# RUN mkdir /root/.pip
23+
# COPY pip.conf /root/.pip/pip.conf
24+
25+
# RUN apt install -y wget zlib1g-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev libtk8.6 libgdm-dev libdb4o-cil-dev libpcap-dev
26+
# RUN wget https://mirrors.huaweicloud.com/python/3.8.19/Python-3.8.19.tar.xz && tar -xvf Python-3.8.19.tar.xz
27+
28+
# WORKDIR /root/Python-3.8.19
29+
# RUN ./configure --prefix=/usr/local && make && make install
30+
31+
# WORKDIR /usr/local/bin/
32+
# RUN ln -s pip3 pip
33+
34+
# WORKDIR /app/sim/
35+
# RUN make install-dev
36+
37+
# RUN wget https://developer.nvidia.com/isaac-gym-preview-4
38+
# # RUN tar -xvf
39+
# RUN make install-third-party-external
40+
41+
```
42+
43+
Then,
44+
45+
Terminal1:
46+
```
47+
docker-compose up --build
48+
```
49+
50+
```
51+
ARNING: Found orphan containers (a55a8ae7a762_docker_my_cuda_service_1) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.
52+
Building my-service
53+
[+] Building 1.6s (10/10) FINISHED docker:default
54+
=> [internal] load build definition from Dockerfile 0.2s
55+
=> => transferring dockerfile: 348B 0.0s
56+
=> [internal] load metadata for docker.io/nvidia/cuda:12.1.0-cudnn8-devel-ubuntu20.04 0.0s
57+
=> [internal] load .dockerignore 0.2s
58+
=> => transferring context: 2B 0.0s
59+
=> [1/5] FROM docker.io/nvidia/cuda:12.1.0-cudnn8-devel-ubuntu20.04 0.0s
60+
=> [internal] load build context 0.2s
61+
=> => transferring context: 34B 0.0s
62+
=> CACHED [2/5] WORKDIR /app 0.0s
63+
=> CACHED [3/5] COPY sources.list /etc/apt/sources.list 0.0s
64+
=> CACHED [4/5] RUN apt update 0.0s
65+
=> CACHED [5/5] WORKDIR /app/sim/ 0.0s
66+
=> exporting to image 0.2s
67+
=> => exporting layers 0.0s
68+
=> => writing image sha256:8e9c02e6c8b50dcbf7d6d1962d51de926126f132b65b65952ad8dfc74634f8c6 0.0s
69+
=> => naming to docker.io/library/docker_my-service 0.1s
70+
WARNING: Image for service my-service was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
71+
Creating docker_my-service_1 ... done
72+
Attaching to docker_my-service_1
73+
my-service_1 |
74+
my-service_1 | ==========
75+
my-service_1 | == CUDA ==
76+
my-service_1 | ==========
77+
my-service_1 |
78+
my-service_1 | CUDA Version 12.1.0
79+
my-service_1 |
80+
my-service_1 | Container image Copyright (c) 2016-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
81+
my-service_1 |
82+
my-service_1 | This container image and its contents are governed by the NVIDIA Deep Learning Container License.
83+
my-service_1 | By pulling and using the container, you accept the terms and conditions of this license:
84+
my-service_1 | https://developer.nvidia.com/ngc/nvidia-deep-learning-container-license
85+
my-service_1 |
86+
my-service_1 | A copy of this license is made available in this container at /NGC-DL-CONTAINER-LICENSE for your convenience.
87+
my-service_1 |
88+
my-service_1 | *************************
89+
my-service_1 | ** DEPRECATION NOTICE! **
90+
my-service_1 | *************************
91+
my-service_1 | THIS IMAGE IS DEPRECATED and is scheduled for DELETION.
92+
my-service_1 | https://gitlab.com/nvidia/container-images/cuda/blob/master/doc/support-policy.md
93+
my-service_1 |
94+
```
95+
96+
Terminal2:
97+
98+
```
99+
docker exec -it docker_zeroth-sim_1 /bin/bash
100+
```
101+
102+
```
103+
gymuser@06aac36e0751:/app/sim# python3 sim/train.py --task=stompymicro --num_envs=4
104+
```

docker/docker-compose.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# version: '3.8'
2+
3+
services:
4+
zeroth-sim:
5+
build:
6+
context: . # Assuming the Dockerfile is in the current directory
7+
dockerfile: Dockerfile
8+
volumes:
9+
- /home/hph/Codes/zeroth-bot:/app # Must have absolute path
10+
- /tmp/.X11-unix:/tmp/.X11-unix
11+
environment:
12+
- DISPLAY=$DISPLAY
13+
privileged: true
14+
cap_add:
15+
- SYS_PTRACE
16+
shm_size: 6g
17+
tty: true
18+
stdin_open: true
19+
deploy:
20+
resources:
21+
reservations:
22+
devices:
23+
- capabilities: [gpu]
24+
count: all

docker/nvidia_icd.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"file_format_version" : "1.0.0",
3+
"ICD": {
4+
"library_path": "libGLX_nvidia.so.0",
5+
"api_version" : "1.1.95"
6+
}
7+
}

docker/pip.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[global]
2+
trusted-host=mirrors.aliyun.com
3+
index-url=http://mirrors.aliyun.com/pypi/simple/

docker/sources.list

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
deb http://mirrors.ustc.edu.cn/ubuntu/ focal main restricted universe multiverse
2+
deb http://mirrors.ustc.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
3+
deb http://mirrors.ustc.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
4+
deb http://mirrors.ustc.edu.cn/ubuntu/ focal-security main restricted universe multiverse

0 commit comments

Comments
 (0)