Let's take the nvidia-docker image and add a Python environment for deep learning.
$ docker build -t nvidia-docker-mod .
$ nvidia-docker run gcr.io/tensorflow/tensorflow:latest-gpu bash
$ docker build -t nvidia-docker-mod .
$ nvidia-docker run gcr.io/tensorflow/tensorflow:latest-gpu bash
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 | FROM gcr.io/tensorflow/tensorflow:latest-gpu # By default, Docker containers run as the root user. This is bad because: # 1) You're more likely to modify up settings that you shouldn't be # 2) If an attacker gets access to your container - well, that's bad if they're root. # Here's how you can run change a Docker container to run as a non-root user ## CREATE APP USER ## # Create the home directory for the new app user. RUN mkdir -p /home/app # Create an app user so our program doesn't run as root. RUN groupadd -r app &&\ useradd -r -g app -d /home/app -s /sbin/nologin -c "Docker image user" app # Set the home directory to our app user's home. ENV HOME=/home/app ENV APP_HOME=/home/app/my-project ## SETTING UP THE APP ## RUN mkdir $APP_HOME WORKDIR $APP_HOME # *** # Do any custom logic needed prior to adding your code here # *** # Copy in the application code. ADD . $APP_HOME # Chown all the files to the app user. RUN chown -R app:app $APP_HOME ENV export WORKON_HOME="$HOME/python_virtual_env" RUN echo "/usr/share/virtualenvwrapper/virtualenvwrapper.sh" >> /etc/bash.bashrc # install python RUN apt-get update RUN apt-get install -yqq python RUN apt-get install -yqq python-pip # Install app dependencies RUN pip install --upgrade pip RUN easy_install --upgrade pip # 9. Misc. install RUN apt-get -yqq install apt-utils RUN apt-get -yqq install pandoc RUN apt-get -yqq install graphviz RUN apt-get -yqq install pandoc # 10. Install Python packages RUN pip3 install keras RUN pip3 install h5py RUN pip3 install numpy RUN pip3 install matplotlib RUN pip3 install gensim RUN pip3 install ioutils RUN pip3 install Cython RUN pip3 install opencv-python RUN pip3 install keras RUN pip3 install sklearn RUN pip3 install pypandoc RUN pip3 install pandoc RUN pip3 install keras_diagram RUN pip3 install tensorflow-gpu RUN pip3 install h5py RUN pip3 install seaborn RUN pip3 install python-flake8 RUN pip3 install pandas RUN pip3 install pydot RUN pip3 install pydot-ng # Python 3.5 GPU support ENV tfBinaryURL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp35-cp35m-linux_x86_64.whl RUN pip3 install --upgrade $tfBinaryURL # Change to the app user. USER app |
No comments:
Post a Comment