Advertisement
Guest User

Untitled

a guest
Nov 28th, 2020
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.31 KB | None | 0 0
  1. FROM nvidia/cuda:10.2-base
  2.  
  3. # install git for accessing repositories
  4. # and make /opt accessible for all users
  5. RUN apt-get update && \
  6. apt-get install -y --no-install-recommends git && \
  7. chmod 777 /opt
  8.  
  9. SHELL ["/bin/bash", "-c"]
  10.  
  11. # install miniconda into /opt/conda and delete downloaded file
  12. ENV CONDAROOT "/opt/conda"
  13. WORKDIR /root/
  14. ADD https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh /root/
  15. RUN mkdir ~/.conda && \
  16. bash Miniconda3-latest-Linux-x86_64.sh -b -p $CONDAROOT && \
  17. rm -rf Miniconda3-latest-Linux-x86_64.sh && \
  18. source $CONDAROOT/etc/profile.d/conda.sh
  19. #ln -s $CONDAROOT/etc/profile.d/conda.sh /etc/profile.d/conda.sh
  20.  
  21. # add conda to the path
  22. ENV PATH $CONDAROOT/bin:$PATH
  23.  
  24. # Install pytorch and fastai through conda
  25. RUN conda update -n base -c defaults conda && \
  26. conda create -n torch -y python=3.7 && \
  27. conda install -n torch pytorch torchvision cudatoolkit=10.1 -c pytorch && \
  28. conda install -n torch -c pytorch -c fastai fastai && \
  29. conda install -n torch -c conda-forge imageio matplotlib seaborn pandas jupyter jupyterlab scikit-image scikit-learn tqdm jupyter_contrib_nbextensions nodejs tensorboard grpcio nodejs
  30.  
  31. # This would install pillow-simd with optimized libjpeg
  32. # but currently this leads to a version clash of pillow 6.1 and pillow-simd 6.0
  33. # RUN conda uninstall -n torch -y --force pillow pil jpeg libtiff libjpeg-turbo && \
  34. # apt-get install -y gcc && \
  35. # source activate torch &&\
  36. # pip uninstall -y pillow pil jpeg libtiff libjpeg-turbo && \
  37. # conda install -n torch -yc conda-forge libjpeg-turbo && \
  38. # CFLAGS="${CFLAGS} -mavx2" pip install --upgrade --no-cache-dir --force-reinstall --no-binary :all: --compile pillow-simd
  39.  
  40. # activate the torch environment to install further packages with pip which are not available or outdated on conda
  41. ENV PATH $CONDAROOT/envs/torch/bin:$PATH
  42. RUN echo "source activate torch" >> ~/.bashrc && \
  43. source activate torch &&\
  44. pip install opencv-python albumentations pretrainedmodels efficientnet-pytorch torchsummary future absl-py jupyter-tensorboard hiddenlayer && \
  45. pip install --no-dependencies git+https://github.com/qubvel/segmentation_models.pytorch
  46. # pip install pytest-xdist pytest-sugar pytest-repeat pytest-picked pytest-forked pytest-flakefinder pytest-cov nbsmoke
  47.  
  48. # configure jupyter-lab to run in the docker image as root with bash as terminal and no password
  49. # notebook directory is /opt/notebooks ==> this should be your mount point
  50. RUN jupyter-lab --generate-config
  51. RUN sed -i '/c.NotebookApp.notebook_dir/c\c.NotebookApp.notebook_dir = "'"/opt/notebooks"'"' ~/.jupyter/jupyter_notebook_config.py && \
  52. sed -i '/c.NotebookApp.open_browser/c\c.NotebookApp.open_browser = False' ~/.jupyter/jupyter_notebook_config.py && \
  53. sed -i '/c.NotebookApp.quit_button/c\c.NotebookApp.quit_button = True' ~/.jupyter/jupyter_notebook_config.py && \
  54. sed -i '/c.NotebookApp.token/c\c.NotebookApp.token = "'""'"' ~/.jupyter/jupyter_notebook_config.py && \
  55. sed -i '/c.NotebookApp.ip/c\c.NotebookApp.ip = "'"0.0.0.0"'"' ~/.jupyter/jupyter_notebook_config.py && \
  56. sed -i '/c.NotebookApp.terminado_settings/c\c.NotebookApp.terminado_settings = {"'"shell_command"'":["'"bash"'"]}' ~/.jupyter/jupyter_notebook_config.py && \
  57. sed -i '/c.NotebookApp.allow_root/c\c.NotebookApp.allow_root = True' ~/.jupyter/jupyter_notebook_config.py && \
  58. jupyter labextension install @jupyter-widgets/jupyterlab-manager && \
  59. jupyter labextension install jupyterlab_tensorboard && \
  60. mkdir /opt/notebooks
  61. WORKDIR /opt/notebooks
  62.  
  63. # Set the random seed and copy the utility scripts to the image
  64. ENV RANDOM_SEED 2019
  65. COPY torchtest.py seed.py /opt/scripts/
  66.  
  67. # this script runs seed.py whenever an ipython kernel/console is started
  68. COPY ipython_config.py ~/.ipython/profile_default/
  69.  
  70. RUN mkdir /opt/cache && \
  71. pip freeze > ~/requirements.txt && \
  72. conda list -n torch --export --json > ~/requirements.json
  73. ENV TORCH_HOME ~/cache/torch
  74. ENV FASTAI_HOME ~/cache/fastai
  75. ENV HOME /root/
  76. RUN chmod -R a+rwX /root && \
  77. chmod -R a+rwX /opt
  78.  
  79. # Make port 8888 available to the world outside this container
  80. EXPOSE 8888
  81.  
  82. # Run the torchtest script when the container launches (and no other command is given)
  83. CMD ["ipython", "/opt/scripts/torchtest.py"]
  84.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement