forked from aws/amazon-sagemaker-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
144 lines (115 loc) · 4.97 KB
/
Dockerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
ARG AWS_REGION
FROM 520713654638.dkr.ecr.${AWS_REGION}.amazonaws.com/sagemaker-rl-tensorflow:coach0.11.0-cpu-py3
RUN buildDeps=" \
wget \
build-essential \
" \
&& apt-get update && apt-get install -y --no-install-recommends $buildDeps \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
##############################################################
# MPI & its dependencies
##############################################################
# Install Open MPI
RUN mkdir /tmp/openmpi && \
cd /tmp/openmpi && \
wget https://www.open-mpi.org/software/ompi/v3.0/downloads/openmpi-3.0.0.tar.gz && \
tar zxf openmpi-3.0.0.tar.gz && \
cd openmpi-3.0.0 && \
./configure --enable-orterun-prefix-by-default && \
make -j $(nproc) all && \
make install && \
ldconfig && \
rm -rf /tmp/openmpi
# Install Horovod, temporarily using CUDA stubs
RUN ldconfig /usr/local/cuda-9.0/targets/x86_64-linux/lib/stubs && \
HOROVOD_CPU_ALLREDUCE=MPI HOROVOD_WITH_TENSORFLOW=1 pip install --no-cache-dir horovod && \
ldconfig
# Create a wrapper for OpenMPI to allow running as root by default
RUN mv /usr/local/bin/mpirun /usr/local/bin/mpirun.real && \
echo '#!/bin/bash' > /usr/local/bin/mpirun && \
echo 'mpirun.real --allow-run-as-root "$@"' >> /usr/local/bin/mpirun && \
chmod a+x /usr/local/bin/mpirun
# Configure OpenMPI to run good defaults:
# --bind-to none --map-by slot --mca btl_tcp_if_exclude lo,docker0
RUN echo "hwloc_base_binding_policy = none" >> /usr/local/etc/openmpi-mca-params.conf && \
echo "rmaps_base_mapping_policy = slot" >> /usr/local/etc/openmpi-mca-params.conf
ENV LD_LIBRARY_PATH=/usr/local/openmpi/lib:$LD_LIBRARY_PATH
ENV PATH /usr/local/openmpi/bin/:$PATH
ENV PATH=/usr/local/nvidia/bin:$PATH
ENV PYTHONDONTWRITEBYTECODE=1 PYTHONUNBUFFERED=1
# SSH. Partially taken from https://docs.docker.com/engine/examples/running_ssh_service/
RUN apt-get update && apt-get install -y --no-install-recommends openssh-server && \
mkdir -p /var/run/sshd
# SSH login fix. Otherwise user is kicked off after login
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
# Create SSH key.
RUN mkdir -p /root/.ssh/ && \
ssh-keygen -q -t rsa -N '' -f /root/.ssh/id_rsa && \
cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys && \
printf "Host *\n StrictHostKeyChecking no\n" >> /root/.ssh/config
# Hostname Fix
COPY resources/changehostname.c /
COPY resources/change-hostname.sh /
COPY resources/change-hostname.sh /usr/local/bin/change-hostname.sh
RUN chmod +x /usr/local/bin/change-hostname.sh
RUN chmod +x /change-hostname.sh
RUN pip install keras
RUN pip install retrying
##############################################################
WORKDIR /opt
############################################
# Roboschool
############################################
RUN apt-get update && apt-get install -y \
git cmake ffmpeg pkg-config \
qtbase5-dev libqt5opengl5-dev libassimp-dev \
libpython3.5-dev libtinyxml-dev \
&& cd /opt \
&& git clone --depth 1 https://github.com/olegklimov/bullet3 -b roboschool_self_collision \
&& git clone --depth 1 https://github.com/openai/roboschool \
&& apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/*
ENV ROBOSCHOOL_PATH /opt/roboschool/
RUN mkdir -p /opt/bullet3/build \
&& cd /opt/bullet3/build \
&& cmake -DBUILD_SHARED_LIBS=ON -DUSE_DOUBLE_PRECISION=1 \
-DCMAKE_INSTALL_PREFIX:PATH=${ROBOSCHOOL_PATH}/roboschool/cpp-household/bullet_local_install \
-DBUILD_CPU_DEMOS=OFF -DBUILD_BULLET2_DEMOS=OFF \
-DBUILD_EXTRAS=OFF -DBUILD_UNIT_TESTS=OFF \
-DBUILD_CLSOCKET=OFF -DBUILD_ENET=OFF \
-DBUILD_OPENGL3_DEMOS=OFF .. \
&& make -j4\
&& make install \
&& cd ../..
RUN apt-get update && \
apt-get install -y libboost-python-dev
RUN apt-get update \
&& apt-get install -y --no-install-recommends python3.6-dev \
&& ln -s -f /usr/bin/python3.6 /usr/bin/python \
&& apt-get clean \
&& rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/*
RUN curl -fSsL -O https://bootstrap.pypa.io/get-pip.py && \
python get-pip.py && \
rm get-pip.py
RUN pip install --upgrade \
pip \
setuptools
RUN pip install -e ${ROBOSCHOOL_PATH} \
&& ldconfig
ENV PYTHONUNBUFFERED 1
############################################
# Baselines
############################################
RUN apt-get update && apt-get install -y cmake libopenmpi-dev python3-dev zlib1g-dev wget
ENV BASELINES_PATH /opt/baselines/
RUN git clone https://github.com/openai/baselines.git
RUN pip install -e ${BASELINES_PATH}
############################################
# Stable Baselines
############################################
RUN pip install stable-baselines
############################################
# Test Installation
############################################
# Test to verify if all required dependencies installed successfully or not.
RUN python -c "import gym; import roboschool;"