Last active
April 3, 2019 20:21
-
-
Save ricardodeazambuja/f81e17fb187c1a582b24147754bae965 to your computer and use it in GitHub Desktop.
Dockerfile for Tensorflow 2.0 (GPU) and opengl enabled (nvidia-docker2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Dockerfile for Tensorflow 2.0 (GPU) and opengl enabled (nvidia-docker2) | |
# | |
FROM nvcr.io/nvidia/cudagl:10.0-runtime-ubuntu18.04 as base | |
# Tensorflow 2 has problems with CUDA 10.1 | |
ARG DEBIAN_FRONTEND=noninteractive | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
apt-transport-https \ | |
mesa-utils \ | |
sudo \ | |
git \ | |
curl \ | |
cuda-toolkit-10-0 \ | |
libcudnn7=7.5.0.56-1+cuda10.0 \ | |
libnvinfer5=5.1.2-1+cuda10.0 \ | |
python3 \ | |
python3-pip \ | |
python3-dev \ | |
python3-scipy \ | |
python3-opencv \ | |
&& \ | |
apt-get clean && \ | |
rm -rf /var/lib/apt/lists/* | |
# For CUDA profiling, TensorFlow requires CUPTI. | |
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/extras/CUPTI/lib64 | |
# See http://bugs.python.org/issue19846 | |
ENV LANG C.UTF-8 | |
RUN pip3 --no-cache-dir install --upgrade \ | |
pip \ | |
setuptools | |
# Some TF tools expect a "python" binary | |
RUN ln -s $(which python3) /usr/local/bin/python | |
RUN pip3 --no-cache-dir install tensorflow-gpu==2.0.0-alpha0 | |
COPY bashrc /etc/bash.bashrc | |
RUN chmod a+rwx /etc/bash.bashrc | |
RUN pip3 --no-cache-dir install \ | |
jupyter \ | |
matplotlib \ | |
pyinstrument \ | |
hdf5storage \ | |
h5py \ | |
py3nvml \ | |
scikit-image \ | |
scikit-learn \ | |
Pillow | |
WORKDIR / | |
RUN mkdir /tf && chmod -R a+rwx /tf | |
RUN mkdir /.local && chmod a+rwx /.local | |
WORKDIR /tf | |
EXPOSE 8888 | |
RUN useradd -ms /bin/bash container_user | |
# https://stackoverflow.com/a/48329093 | |
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers | |
RUN python -m ipykernel.kernelspec | |
# Basic initialization | |
# CMD ["bash", "-c", "source /etc/bash.bashrc && jupyter notebook --notebook-dir=/tf --ip 0.0.0.0 --allow-root"] | |
# This is a fix for the crazy URL using the container ID OR localhost ip... chrome couldn't understand that. | |
# Using the custom_display_url I'm capable to just right click on the link to open it on my browser. | |
CMD ["bash", "-c", "source /etc/bash.bashrc && jupyter notebook --notebook-dir=/tf --ip 0.0.0.0 --no-browser --allow-root --NotebookApp.custom_display_url='http://localhost:8888'"] | |
# This last option creates a virtual enviroment, but needs python3-venv installed. | |
# CMD ["bash", "-c", "source /etc/bash.bashrc && python3 -m venv /tf && jupyter notebook --notebook-dir=/tf --ip 0.0.0.0 --no-browser --allow-root --NotebookApp.custom_display_url='http://localhost:8888'"] | |
# | |
# The last version of the IPython (7.2.0.) has a problem with autocomplete (https://github.com/ipython/ipython/issues/11530) | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment