From 76a192606fb8cd5f1f4872dddec6eef898fc17cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Geron?= Date: Thu, 24 Nov 2016 21:57:26 +0100 Subject: [PATCH] Update Dockerfile to TensorFlow 0.11.0 --- .binder_start | 11 ++++++ Dockerfile | 59 +++++++++++++++++++---------- Dockerfile-base | 95 ----------------------------------------------- start-notebook.sh | 16 -------- 4 files changed, 50 insertions(+), 131 deletions(-) create mode 100644 .binder_start delete mode 100644 Dockerfile-base delete mode 100755 start-notebook.sh diff --git a/.binder_start b/.binder_start new file mode 100644 index 0000000..620e00e --- /dev/null +++ b/.binder_start @@ -0,0 +1,11 @@ +#!/bin/bash + +function jupyter { + # Run Jupyter with xvfb-run so that it can render the CartPole + # environment without crashing: + xvfb-run -s "-screen 0 1400x900x24" /home/main/.local/bin/jupyter $@ +} + +function ipython { + jupyter $@ +} diff --git a/Dockerfile b/Dockerfile index 092e984..8b3ee89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,36 +4,55 @@ USER root RUN apt-get update -y &&\ apt-get install --fix-missing -y \ - python-numpy\ - python-dev\ cmake\ - zlib1g-dev\ libjpeg-dev\ - xvfb\ libav-tools\ - xorg-dev\ - python-opengl\ libboost-all-dev\ libsdl2-dev\ - swig &&\ + python-dev\ + python-opengl\ + python-pip\ + python3-dev\ + python3-opengl\ + python3-pip\ + swig\ + xorg-dev\ + xvfb\ + zlib1g-dev &&\ apt-get clean &&\ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*tmp USER main -# Python 2 -RUN conda install -c jjhelmus tensorflow=0.10.0 -RUN conda install -c conda-forge jupyter_contrib_nbextensions -RUN conda install -c https://conda.anaconda.org/kne pybox2d +RUN /usr/bin/pip2 install --upgrade --user pip wheel +RUN /usr/bin/pip3 install --upgrade --user pip wheel + +ENV PATH /home/main/.local/bin:$PATH + +# Install scientific packages +RUN pip2 install --upgrade --user matplotlib numexpr numpy pandas Pillow protobuf psutil scipy scikit-learn sympy jupyter +RUN pip3 install --upgrade --user matplotlib numexpr numpy pandas Pillow protobuf psutil scipy scikit-learn sympy jupyter + +# Install TensorFlow +RUN pip2 install --user --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.11.0-cp27-none-linux_x86_64.whl +RUN pip3 install --user --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.11.0-cp34-cp34m-linux_x86_64.whl + +# Install OpenAI gym +RUN pip2 install --user --upgrade gym +RUN pip3 install --user --upgrade gym +RUN pip2 install --user --upgrade 'gym[all]' +RUN pip3 install --user --upgrade 'gym[all]' + +# Install Jupyter extensions +RUN pip3 install --user --upgrade https://github.com/ipython-contrib/jupyter_contrib_nbextensions/tarball/master + +# Jupyter extensions +#RUN conda install -c conda-forge jupyter_contrib_nbextensions RUN jupyter contrib nbextension install --user RUN jupyter nbextension enable toc2/main -RUN pip install --upgrade gym -RUN pip install --upgrade 'gym[atari]' -RUN pip install --upgrade 'gym[box2d]' -# Python 3 -RUN conda install -n python3 -c jjhelmus tensorflow=0.10.0 -RUN conda install -n python3 -c https://conda.anaconda.org/kne pybox2d -RUN /bin/bash -c "source activate python3 && pip install --upgrade gym" -RUN /bin/bash -c "source activate python3 && pip install --upgrade 'gym[atari]'" -RUN /bin/bash -c "source activate python3 && pip install --upgrade 'gym[box2d]'" +RUN /home/main/anaconda2/bin/jupyter kernelspec remove -f python3 +RUN /usr/bin/python2 -m ipykernel install --user +RUN /usr/bin/python3 -m ipykernel install --user + +ADD .binder_start /home/main/ diff --git a/Dockerfile-base b/Dockerfile-base deleted file mode 100644 index 626a3ac..0000000 --- a/Dockerfile-base +++ /dev/null @@ -1,95 +0,0 @@ -# Andrew Osheroff's docker base image, using system python rather than conda -# https://github.com/binder-project/binder-build-core ... /images/python/3.5 -FROM debian:jessie - -MAINTAINER Aurelien Geron - -ENV DEBIAN_FRONTEND noninteractive - -RUN apt-get update -y &&\ - apt-get install --fix-missing -y \ - build-essential\ - bzip2\ - cmake\ - curl\ - gcc\ - gfortran\ - git\ - libav-tools\ - libboost-all-dev\ - libglib2.0-0\ - libjpeg-dev\ - libsdl2-dev\ - libsm6\ - locales\ - nodejs-legacy\ - npm\ - python-dev\ - python-opengl\ - python-pip\ - python-qt4\ - python-virtualenv\ - python3-dev\ - python3-opengl\ - python3-pip\ - python3-virtualenv\ - swig\ - vim\ - wget\ - xorg-dev\ - xvfb\ - zlib1g-dev &&\ - apt-get clean &&\ - rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*tmp - -# set utf8 locale: -RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen -ENV LANG=en_US.UTF-8 \ - LC_ALL=en_US.UTF-8 - -# We run our docker images with a non-root user as a security precaution. -# main is our user -RUN useradd -m -s /bin/bash main - -EXPOSE 8888 - -USER main -ENV HOME /home/main -ENV SHELL /bin/bash -ENV USER main -WORKDIR $HOME - -ENV SHELL /bin/bash - -RUN /usr/bin/pip install --upgrade --user pip wheel -RUN /usr/bin/pip3 install --upgrade --user pip wheel - -ENV PATH /home/main/.local/bin:$PATH - -# Install scientific packages -RUN pip install --upgrade --user matplotlib numexpr numpy pandas Pillow protobuf psutil scipy scikit-learn sympy -RUN pip3 install --upgrade --user matplotlib numexpr numpy pandas Pillow protobuf psutil scipy scikit-learn sympy - -# Install TensorFlow -RUN pip install --upgrade --user https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.11.0rc0-cp27-none-linux_x86_64.whl -RUN pip3 install --upgrade --user https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.11.0rc0-cp34-cp34m-linux_x86_64.whl - -# Install OpenAI gym -RUN pip install --upgrade --user gym -RUN pip3 install --upgrade --user gym -RUN pip install --upgrade --user "gym[atari]" -RUN pip3 install --upgrade --user "gym[atari]" - -# Install Jupyter and Jupyter extensions -RUN pip install --upgrade --user jupyter https://github.com/ipython-contrib/jupyter_contrib_nbextensions/tarball/master -RUN pip3 install --upgrade --user jupyter https://github.com/ipython-contrib/jupyter_contrib_nbextensions/tarball/master - -# Install Notebook extensions and activate the ToC extension -RUN jupyter contrib nbextension install --user -RUN jupyter nbextension enable toc2/main - -# Replace script to start Jupyter with xvfb-run -ADD start-notebook.sh /home/main/ - -RUN ipython2 kernel install --user -RUN ipython3 kernel install --user diff --git a/start-notebook.sh b/start-notebook.sh deleted file mode 100755 index abd84b5..0000000 --- a/start-notebook.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -OPTS="" -echo "$HOME/notebooks/index.ipynb: " $HOME/notebooks/index.ipynb -if [ -e $HOME/notebooks/index.ipynb ]; then - OPTS="$OPTS --NotebookApp.default_url=/tree/index.ipynb " -fi -if [ -e $HOME/.binder_start ]; then - source $HOME/.binder_start -fi -CMD="$OPTS $@" -echo "CMD: " $CMD - -# Run Jupyter with xvfb-run so that it can render the CartPole -# environment without crashing: -xvfb-run -s "-screen 0 1400x900x24" jupyter notebook $CMD -