Skip to content

Instantly share code, notes, and snippets.

@hartikainen
Created August 28, 2018 22:17
Show Gist options
  • Select an option

  • Save hartikainen/5c48cbfd0a0c8482cc4330086edd4118 to your computer and use it in GitHub Desktop.

Select an option

Save hartikainen/5c48cbfd0a0c8482cc4330086edd4118 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
# Set up display; otherwise rendering will fail
Xvfb -screen 0 320x240x24 &
export DISPLAY=:0
# Wait for the file to come up
file="/tmp/.X11-unix/X0"
for i in $(seq 1 10); do
if [ -e "$file" ]; then
break
fi
echo "Waiting for $file to be created (try $i/10)"
sleep "$i"
done
if ! [ -e "$file" ]; then
echo "Timing out: $file was not created"
exit 1
fi
exec "$@"
# Base softlearning container that contains all softlearning requirements,
# but not the actual softlearning repo. Could be used for example when developing
# softlearning, in which case you would mount softlearning repo in to the container
# as a volume, and thus be able to modify code on the host, yet run things inside
# the container. You are encouraged to use docker-compose (docker-compose.dev.yml),
# which should allow you to setup your environment with a single one command.
FROM nvidia/cuda:9.0-runtime-ubuntu16.04
ARG MJKEY
MAINTAINER Kristian Hartikainen <[email protected]>
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
ENV PATH /opt/conda/bin:$PATH
RUN apt-get update --fix-missing && \
apt-get install -y wget bzip2 ca-certificates curl git && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh -O ~/miniconda.sh && \
/bin/bash ~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh && \
/opt/conda/bin/conda clean -tipsy && \
ln -s /opt/conda/etc/profile.d/conda.sh /etc/profile.d/conda.sh && \
echo ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc && \
echo "conda activate base" >> ~/.bashrc
RUN conda update -y --name base conda
# ========== Tensorflow dependencies ==========
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y --no-install-recommends \
build-essential \
cuda-command-line-tools-9-0 \
cuda-cublas-9-0 \
cuda-cufft-9-0 \
cuda-curand-9-0 \
cuda-cusolver-9-0 \
cuda-cusparse-9-0 \
curl \
libcudnn7=7.1.4.18-1+cuda9.0 \
libnccl2=2.2.13-1+cuda9.0 \
libfreetype6-dev \
libhdf5-serial-dev \
libpng12-dev \
libzmq3-dev \
pkg-config \
python \
python-dev \
rsync \
software-properties-common \
unzip \
gcc \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# ========== Softlearning dependencies ==========
RUN apt-get update \
# DO NOT apt-get upgrade here, it'll fuck up the tensorflow dependencies
&& apt-get install -y --no-install-recommends \
build-essential \
curl \
git \
make \
cmake \
swig \
libz-dev \
unzip \
zlib1g-dev \
libglfw3 \
libglfw3-dev \
libxrandr2 \
libxinerama-dev \
libxi6 \
libxcursor-dev \
libgl1-mesa-dev \
libgl1-mesa-glx \
libglew-dev \
libosmesa6-dev \
ack-grep \
patchelf \
vim \
emacs \
wget \
xpra \
xserver-xorg-dev \
xvfb \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# ========= Google Cloud SDK ===========
RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" \
&& echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" \
| tee -a /etc/apt/sources.list.d/google-cloud-sdk.list \
&& curl https://packages.cloud.google.com/apt/doc/apt-key.gpg \
| apt-key add - \
&& apt-get update -y \
&& apt-get install google-cloud-sdk -y
# ========= MuJoCo ===============
# Rllab requires mujoco 1.31
ENV MUJOCO_VERSION=131 \
MUJOCO_PATH=/root/.mujoco
RUN MUJOCO_ZIP="mjpro${MUJOCO_VERSION}_linux.zip" \
&& mkdir -p ${MUJOCO_PATH} \
&& wget -P ${MUJOCO_PATH} https://www.roboti.us/download/${MUJOCO_ZIP} \
&& unzip ${MUJOCO_PATH}/${MUJOCO_ZIP} -d ${MUJOCO_PATH} \
&& rm ${MUJOCO_PATH}/${MUJOCO_ZIP}
# Mujoco for gym and mujoco_py
ENV MUJOCO_VERSION=150 \
MUJOCO_PATH=/root/.mujoco
RUN MUJOCO_ZIP="mjpro${MUJOCO_VERSION}_linux.zip" \
&& mkdir -p ${MUJOCO_PATH} \
&& wget -P ${MUJOCO_PATH} https://www.roboti.us/download/${MUJOCO_ZIP} \
&& unzip ${MUJOCO_PATH}/${MUJOCO_ZIP} -d ${MUJOCO_PATH} \
&& rm ${MUJOCO_PATH}/${MUJOCO_ZIP}
ENV LD_LIBRARY_PATH /root/.mujoco/mjpro${MUJOCO_VERSION}/bin:${LD_LIBRARY_PATH}
COPY ./environment.yml /tmp/
COPY ./requirements.txt /tmp/
RUN conda env update -f /tmp/environment.yml \
&& rm /tmp/requirements.txt \
&& rm /tmp/environment.yml
RUN echo "source activate softlearning" >> /root/.bashrc
ENV BASH_ENV /root/.bashrc
# Trigger mujoco_py compilation using the MJKEY provided. Delete MJKEY afterwards.
RUN echo "${MJKEY}" > /root/.mujoco/mjkey.txt \
&& bash -c "source activate softlearning \
&& python -c 'import mujoco_py'" \
&& rm /root/.mujoco/mjkey.txt
COPY ./docker/entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment