content: FROM ubuntu:18.04
  LABEL maintainer "June Oh <me@juneoh.net>"
  
  RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates apt-transport-https gnupg curl && \
      rm -rf /var/lib/apt/lists/* && \
      curl -fsSL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub | apt-key add - && \
      echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/cuda.list && \
      echo "deb https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.list
  ENV CUDA_VERSION 9.0.176
  ENV CUDA_PKG_VERSION 9-0=$CUDA_VERSION-1
  RUN apt-get update && apt-get install -y --no-install-recommends \
          cuda-cudart-$CUDA_PKG_VERSION && \
      ln -s cuda-9.0 /usr/local/cuda && \
      rm -rf /var/lib/apt/lists/*
  # nvidia-docker 1.0
  LABEL com.nvidia.volumes.needed="nvidia_driver"
  LABEL com.nvidia.cuda.version="${CUDA_VERSION}"
  RUN echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf && \
      echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf
  ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
  ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64
  # nvidia-container-runtime
  ENV NVIDIA_VISIBLE_DEVICES all
  ENV NVIDIA_DRIVER_CAPABILITIES compute,utility
  ENV NVIDIA_REQUIRE_CUDA "cuda>=9.0"
  
  ENV NCCL_VERSION 2.3.5
  RUN apt-get update && apt-get install -y --no-install-recommends \
          cuda-libraries-$CUDA_PKG_VERSION \
          cuda-cublas-9-0=9.0.176.4-1 \
          libnccl2=$NCCL_VERSION-2+cuda9.0 && \
      apt-mark hold libnccl2 && \
      rm -rf /var/lib/apt/lists/*
  
  RUN apt-get update && apt-get install -y --no-install-recommends \
          cuda-libraries-dev-$CUDA_PKG_VERSION \
          cuda-nvml-dev-$CUDA_PKG_VERSION \
          cuda-minimal-build-$CUDA_PKG_VERSION \
          cuda-command-line-tools-$CUDA_PKG_VERSION \
          cuda-core-9-0=9.0.176.3-1 \
          cuda-cublas-dev-9-0=9.0.176.4-1 \
          libnccl-dev=$NCCL_VERSION-2+cuda9.0 && \
      rm -rf /var/lib/apt/lists/*
  ENV LIBRARY_PATH /usr/local/cuda/lib64/stubs
  
  ENV CUDNN_VERSION 7.1.2.21
  LABEL com.nvidia.cudnn.version="${CUDNN_VERSION}"
  RUN apt-get update && apt-get install -y --no-install-recommends \
              libcudnn7=$CUDNN_VERSION-1+cuda9.1 \
              libcudnn7-dev=$CUDNN_VERSION-1+cuda9.1 && \
      apt-mark hold libcudnn7 && \
      rm -rf /var/lib/apt/lists/*
  
  ENV TZ=Asia/Seoul
  RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
  RUN echo "XKBMODEL=\"pc105\"\n \
            XKBLAYOUT=\"us\"\n \
            XKBVARIANT=\"\"\n \
            XKBOPTIONS=\"\"" > /etc/default/keyboard
  
  RUN apt-get update && apt-get install -y --no-install-recommends \
           build-essential \
           cmake \
           git \
           curl \
           ca-certificates \
           libjpeg-dev \
           libpng-dev \
           g++ \
           openjdk-8-jdk \
           sudo \
           apt-utils \
           man \
           software-properties-common \
           tzdata \
           locales &&\
       rm -rf /var/lib/apt/lists/*
  
  RUN locale-gen ko_KR.UTF-8
  ENV LANG="ko_KR.UTF-8" LANGUAGE="ko_KR:en" LC_ALL="ko_KR.UTF-8"
  
  RUN curl -o ~/miniconda.sh -O  https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh  && \
       chmod +x ~/miniconda.sh && \
       ~/miniconda.sh -b -p /opt/conda && \     
       rm ~/miniconda.sh
  ENV PATH /opt/conda/bin:$PATH
  RUN conda install python=3.6 jupyter pip=9.0.1
  RUN conda clean -ya 
  RUN echo "export PATH=/opt/conda/bin:\$PATH" > /etc/profile.d/conda.sh
  
  RUN pip install scipy scikit-learn pandas cython visdom matplotlib konlpy
  
  RUN pip install tensorflow-gpu==1.12.0
  
  RUN pip install --upgrade pip
  RUN rm -rf ~/.ssh/pip
  
  ENV PYTHONUNBUFFERED=1
  WORKDIR /root
  
  CMD ["jupyter", "notebook", "--allow-root", "--ip=0.0.0.0", "--NotebookApp.custom_display_url='http://localhost:8888'"]
  