Skip to content

Commit 871a2ba

Browse files
author
BigJohhn
committed
add docker support
1 parent 3843e4c commit 871a2ba

File tree

7 files changed

+180
-0
lines changed

7 files changed

+180
-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: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
Terminal1:
2+
```
3+
docker-compose up --build
4+
```
5+
6+
```
7+
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.
8+
Building my-service
9+
[+] Building 1.6s (10/10) FINISHED docker:default
10+
=> [internal] load build definition from Dockerfile 0.2s
11+
=> => transferring dockerfile: 348B 0.0s
12+
=> [internal] load metadata for docker.io/nvidia/cuda:12.1.0-cudnn8-devel-ubuntu20.04 0.0s
13+
=> [internal] load .dockerignore 0.2s
14+
=> => transferring context: 2B 0.0s
15+
=> [1/5] FROM docker.io/nvidia/cuda:12.1.0-cudnn8-devel-ubuntu20.04 0.0s
16+
=> [internal] load build context 0.2s
17+
=> => transferring context: 34B 0.0s
18+
=> CACHED [2/5] WORKDIR /app 0.0s
19+
=> CACHED [3/5] COPY sources.list /etc/apt/sources.list 0.0s
20+
=> CACHED [4/5] RUN apt update 0.0s
21+
=> CACHED [5/5] WORKDIR /app/sim/ 0.0s
22+
=> exporting to image 0.2s
23+
=> => exporting layers 0.0s
24+
=> => writing image sha256:8e9c02e6c8b50dcbf7d6d1962d51de926126f132b65b65952ad8dfc74634f8c6 0.0s
25+
=> => naming to docker.io/library/docker_my-service 0.1s
26+
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`.
27+
Creating docker_my-service_1 ... done
28+
Attaching to docker_my-service_1
29+
my-service_1 |
30+
my-service_1 | ==========
31+
my-service_1 | == CUDA ==
32+
my-service_1 | ==========
33+
my-service_1 |
34+
my-service_1 | CUDA Version 12.1.0
35+
my-service_1 |
36+
my-service_1 | Container image Copyright (c) 2016-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
37+
my-service_1 |
38+
my-service_1 | This container image and its contents are governed by the NVIDIA Deep Learning Container License.
39+
my-service_1 | By pulling and using the container, you accept the terms and conditions of this license:
40+
my-service_1 | https://developer.nvidia.com/ngc/nvidia-deep-learning-container-license
41+
my-service_1 |
42+
my-service_1 | A copy of this license is made available in this container at /NGC-DL-CONTAINER-LICENSE for your convenience.
43+
my-service_1 |
44+
my-service_1 | *************************
45+
my-service_1 | ** DEPRECATION NOTICE! **
46+
my-service_1 | *************************
47+
my-service_1 | THIS IMAGE IS DEPRECATED and is scheduled for DELETION.
48+
my-service_1 | https://gitlab.com/nvidia/container-images/cuda/blob/master/doc/support-policy.md
49+
my-service_1 |
50+
```
51+
52+
Terminal2:
53+
54+
```
55+
docker exec -it docker_zeroth-sim_1 /bin/bash
56+
```
57+
58+
```
59+
gymuser@06aac36e0751:/app/sim# python3 sim/train.py --task=stompymicro --num_envs=4
60+
```

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)