Skip to content

Commit d6550b3

Browse files
NikosKokkiniseakirtas
authored andcommitted
Add docker folder with Dockerfile and readme
Finalize docker container for the deepbots Removing the white space at the end of the files
1 parent 851cba9 commit d6550b3

File tree

4 files changed

+494
-0
lines changed

4 files changed

+494
-0
lines changed

docker/Dockerfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
FROM nvidia/cudagl:11.0-devel-ubuntu20.04
2+
ARG DEBIAN_FRONTEND=noninteractive
3+
4+
ARG PYTHON_VERSION=3.8
5+
6+
ARG branch
7+
8+
# Install ubuntu libaries
9+
RUN apt-get update && \
10+
apt-get install -y --no-install-recommends build-essential cmake pkg-config \
11+
libfreetype6-dev git nano wget curl vim ca-certificates unzip libjpeg-dev \
12+
libpng-dev libosmesa6-dev software-properties-common xvfb gpg-agent
13+
14+
# Install miniconda
15+
RUN curl -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \
16+
chmod +x ~/miniconda.sh && \
17+
~/miniconda.sh -b -p /opt/conda && \
18+
rm ~/miniconda.sh && \
19+
/opt/conda/bin/conda update -n base -c defaults conda && \
20+
/opt/conda/bin/conda install -y python=$PYTHON_VERSION setuptools patchelf && \
21+
/opt/conda/bin/conda clean -ya
22+
ENV PATH /opt/conda/bin:$PATH
23+
24+
25+
# Env vars for the nvidia-container-runtime.
26+
ENV PATH /usr/local/cuda/bin/:$PATH
27+
ENV LD_LIBRARY_PATH /usr/local/cuda/lib:/usr/local/cuda/lib64
28+
ENV NVIDIA_VISIBLE_DEVICES all
29+
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
30+
LABEL com.nvidia.volumes.needed="nvidia_driver"
31+
32+
# Install weebots
33+
RUN wget -qO- https://cyberbotics.com/Cyberbotics.asc | apt-key add -
34+
RUN apt-add-repository 'deb https://cyberbotics.com/debian/ binary-amd64/' && \
35+
apt-get update && apt-get install -y webots
36+
37+
# Save enviroment libraries
38+
ENV WEBOTS_HOME /usr/local/webots
39+
ENV LD_LIBRARY_PATH $WEBOTS_HOME/lib/controller:$LD_LIBRARY_PATH
40+
41+
42+
ADD requirements.txt .
43+
# Install python dependencies
44+
RUN pip install -r requirements.txt
45+
46+
RUN if [ $branch = "dev" ]; then pip install -i https://test.pypi.org/simple/ deepbots ; else pip install deepbots ; fi
47+
48+
RUN pip install 'ray[tune]' 'ray[rllib]'
49+
50+
# Fix the error of the custome enviroment on Ray
51+
ADD preprocessors.py .
52+
RUN cp -r preprocessors.py opt/conda/lib/python3.8/site-packages/ray/rllib/models/
53+
RUN rm preprocessors.py
54+
55+
56+
WORKDIR /workspace
57+
RUN chmod -R a+w /workspace

docker/README.md

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Use the Docker of the deepbots
2+
3+
## In case you would like to add other functionalities/libraries on the docker:
4+
5+
* Edit the Dockerfile
6+
* Build the docker image using below commands
7+
* Building argument ```branch``` specify the ```dev``` or the ```master``` branch of deepbots.
8+
9+
### Building and tagging a Docker image:
10+
```bash
11+
$ docker build -t yourusername/repository-name --build-arg branch=dev .
12+
```
13+
14+
## Pull the existing image from DockerHub
15+
16+
```bash
17+
$ docker pull nickok/deepbots-dev
18+
```
19+
20+
## For the use of Cuda on your docker container
21+
22+
You should install NVIDIA Container Toolkit on your ```host``` machine.
23+
24+
1) Setup the stable repository and the GPG key:
25+
``` bash
26+
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
27+
&& curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - \
28+
&& curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
29+
```
30+
2) Install the nvidia-docker2 package (and dependencies) after updating the package listing:
31+
32+
``` bash
33+
$ sudo apt-get update
34+
```
35+
36+
``` bash
37+
$ sudo apt-get install -y nvidia-docker2
38+
```
39+
40+
Restart the Docker daemon to complete the installation after setting the default runtime:
41+
``` bash
42+
$ sudo sudo systemctl restart docker
43+
```
44+
45+
46+
47+
## Run docker
48+
49+
### Use docker with ```cpu```
50+
Mount Webots project and run it on interactive Docker container:
51+
```bash
52+
$ docker run -it -v /absolute/path/to/webots/project:/workspace/name-of-project nickok/deepbots-dev
53+
```
54+
55+
### Use docker with ```cuda``` (GPU)
56+
``` bash
57+
$ docker run --rm --gpus all run -it -v /absolute/path/to/webots/project:/workspace/name-of-project nickok/deepbots
58+
```
59+
60+
After starting the docker container you can start Webots headlessly using xvfb:
61+
```bash
62+
$ xvfb-run webots --stdout --stderr --batch --no-sandbox --mode=fast /path/to/your/world/file
63+
64+
```
65+
66+
Start Webots headlessly using xvfb and save the output at out.txt:
67+
```bash
68+
$ xvfb-run webots --stdout --stderr --batch --no-sandbox --mode=fast /path/to/your/world/file &> out.txt &
69+
```

0 commit comments

Comments
 (0)