Public Repository

Last pushed: 15 days ago
Short Description
Image used as a base for ML development with GPU support
Full Description

So this system uses a build that pulls different pieces from many different containers to get an image that works for us including the corresponding nvidia driver.

Here is the Dockerfile (unable to get it to build in hub).

    FROM ubuntu:16.04

    #
    # Note: This single docker image is one that I am using a number of internal solutions and was
    #  a collaboration of many different sources, these sources are all listed in the README.
    #

    ###############################
    ## Install Nvidia Driver into the container
    ###############################
    ENV DRIVER_VERSION 367.57

    RUN apt-get -y update \
            && apt-get -y install wget git bc make dpkg-dev libssl-dev module-init-tools \
            && apt-get autoremove \
            && apt-get clean

    ## Kernel Modules
    RUN  mkdir -p /usr/src/kernels \
            && cd /usr/src/kernels \
            && git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git --single-branch --depth 1 --branch v`uname -r | sed -e "s/-.*//" | sed -e "s/\.[0]*$//"`  linux \
            && cd linux \
            && git checkout -b stable v`uname -r | sed -e "s/-.*//" | sed -e "s/\.[0]*$//"` \
            && zcat /proc/config.gz > .config \
            && make modules_prepare \
            && sed -i -e "s/`uname -r | sed -e "s/-.*//" | sed -e "s/\.[0]??*$//"`/`uname -r`/" include/generated/utsrelease.h # In case a '+' was added

    ## NVIDIA driver
    RUN mkdir -p /opt/nvidia && cd /opt/nvidia/ \
            && wget http://us.download.nvidia.com/XFree86/Linux-x86_64/${DRIVER_VERSION}/NVIDIA-Linux-x86_64-${DRIVER_VERSION}.run -O /opt/nvidia/driver.run \ 
            && chmod +x /opt/nvidia/driver.run \
            && /opt/nvidia/driver.run -a -x --ui=none

    ENV NVIDIA_INSTALLER /opt/nvidia/NVIDIA-Linux-x86_64-${DRIVER_VERSION}/nvidia-installer
    CMD ${NVIDIA_INSTALLER} -q -a -n -s --kernel-source-path=/usr/src/kernels/linux/ \
            && modprobe nvidia \
            && modprobe nvidia-uvm


    ###############################
    ## Install CUDA
    ###############################
    RUN /opt/nvidia/driver.run --silent --no-kernel-module --no-unified-memory --no-opengl-files

    RUN NVIDIA_GPGKEY_SUM=d1be581509378368edeec8c1eb2958702feedf3bc3d17011adbf24efacce4ab5 && \
            NVIDIA_GPGKEY_FPR=ae09fe4bbd223a84b2ccfce3f60f4b3d7fa2af80 && \
            apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub && \
            apt-key adv --export --no-emit-version -a $NVIDIA_GPGKEY_FPR | tail -n +5 > cudasign.pub && \
            echo "$NVIDIA_GPGKEY_SUM  cudasign.pub" | sha256sum -c --strict - && rm cudasign.pub && \
            echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/cuda.list

    ENV CUDA_VERSION 8.0.61
    LABEL com.nvidia.cuda.version="${CUDA_VERSION}"

    ENV CUDA_PKG_VERSION 8-0=$CUDA_VERSION-1
    RUN apt-get update && apt-get install -y --no-install-recommends \
                    cuda-nvrtc-$CUDA_PKG_VERSION \
                    cuda-nvgraph-$CUDA_PKG_VERSION \
                    cuda-cusolver-$CUDA_PKG_VERSION \
                    cuda-cublas-8-0=8.0.61.1-1 \
                    cuda-cufft-$CUDA_PKG_VERSION \
                    cuda-curand-$CUDA_PKG_VERSION \
                    cuda-cusparse-$CUDA_PKG_VERSION \
                    cuda-npp-$CUDA_PKG_VERSION \
                    cuda-cudart-$CUDA_PKG_VERSION && \
            ln -s cuda-8.0 /usr/local/cuda && \
            rm -rf /var/lib/apt/lists/*

    RUN echo "/usr/local/cuda/lib64" >> /etc/ld.so.conf.d/cuda.conf && \
            ldconfig

    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


    ###############################
    ## Install CUDNN
    ###############################
    RUN echo "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.list

    ENV CUDNN_VERSION 5.1.10
    LABEL com.nvidia.cudnn.version="${CUDNN_VERSION}"

    RUN apt-get update && apt-get install -y --no-install-recommends \
                            libcudnn5=$CUDNN_VERSION-1+cuda8.0 && \
            rm -rf /var/lib/apt/lists/*


    ###############################
    ## Install Python 3
    ###############################

    ## Install Web Requests
    RUN apt-get update && apt-get install -y --no-install-recommends \
            ca-certificates \
            curl \
            wget \
        && rm -rf /var/lib/apt/lists/*

    ## Install SCM support
    RUN apt-get update && apt-get install -y --no-install-recommends \
            git \
            openssh-client \
            procps \
        && rm -rf /var/lib/apt/lists/*

    ## Install the common libraries for python extensions
    RUN set -ex; \
        apt-get update; \
        apt-get install -y --no-install-recommends \
            autoconf \
            automake \
            bzip2 \
            file \
            g++ \
            gcc \
            imagemagick \
            libbz2-dev \
            libc6-dev \
            libcurl4-openssl-dev \
            libdb-dev \
            libevent-dev \
            libffi-dev \
            libgdbm-dev \
            libgeoip-dev \
            libglib2.0-dev \
            libjpeg-dev \
            libkrb5-dev \
            liblzma-dev \
            libmagickcore-dev \
            libmagickwand-dev \
            libncurses-dev \
            libpng-dev \
            libpq-dev \
            libreadline-dev \
            libsqlite3-dev \
            libssl-dev \
            libtool \
            libwebp-dev \
            libxml2-dev \
            libxslt-dev \
            libyaml-dev \
            make \
            patch \
            xz-utils \
            zlib1g-dev \
            $( \
                if apt-cache show 'default-libmysqlclient-dev' 2>/dev/null | grep -q '^Version:'; then \
                    echo 'default-libmysqlclient-dev'; \
                else \
                    echo 'libmysqlclient-dev'; \
                fi \
            ) \
        ; \
        rm -rf /var/lib/apt/lists/*

    ## Runtime Dependencies
    RUN apt-get update && apt-get install -y --no-install-recommends \
            tcl \
            tk \
        && rm -rf /var/lib/apt/lists/*

    ENV GPG_KEY 0D96DF4D4110E5C43FBFB17F2D347EA6AA65421D
    ENV PYTHON_VERSION 3.6.1

    RUN set -ex \
        && buildDeps=' \
            dpkg-dev \
            tcl-dev \
            tk-dev \
        ' \
        && apt-get update && apt-get install -y $buildDeps --no-install-recommends && rm -rf /var/lib/apt/lists/* \
        && wget -O python.tar.xz "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz" \
        && wget -O python.tar.xz.asc "https://www.python.org/ftp/python/${PYTHON_VERSION%%[a-z]*}/Python-$PYTHON_VERSION.tar.xz.asc" \
        && export GNUPGHOME="$(mktemp -d)" \
        && gpg --keyserver ha.pool.sks-keyservers.net --recv-keys "$GPG_KEY" \
        && gpg --batch --verify python.tar.xz.asc python.tar.xz \
        && rm -r "$GNUPGHOME" python.tar.xz.asc \
        && mkdir -p /usr/src/python \
        && tar -xJC /usr/src/python --strip-components=1 -f python.tar.xz \
        && rm python.tar.xz \
        && cd /usr/src/python \
        && gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)" \
        && ./configure \
            --build="$gnuArch" \
            --enable-loadable-sqlite-extensions \
            --enable-shared \
            --without-ensurepip \
        && make -j "$(nproc)" \
        && make install \
        && ldconfig \
        && apt-get purge -y --auto-remove $buildDeps \
        && find /usr/local -depth \
            \( \
                \( -type d -a -name test -o -name tests \) \
                -o \
                \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
            \) -exec rm -rf '{}' + \
        && rm -rf /usr/src/python

    ## Symlinks
    RUN cd /usr/local/bin \
        && ln -s idle3 idle \
        && ln -s pydoc3 pydoc \
        && ln -s python3 python \
        && ln -s python3-config python-config


    ###############################
    ## Install PIP
    ###############################
    ENV PYTHON_PIP_VERSION 9.0.1

    RUN set -ex; \
        wget -O get-pip.py 'https://bootstrap.pypa.io/get-pip.py'; \
        python get-pip.py \
            --disable-pip-version-check \
            --no-cache-dir \
            "pip==$PYTHON_PIP_VERSION" \
        ; \
        pip --version; \
        find /usr/local -depth \
            \( \
                \( -type d -a -name test -o -name tests \) \
                -o \
                \( -type f -a -name '*.pyc' -o -name '*.pyo' \) \
            \) -exec rm -rf '{}' +; \
        rm -f get-pip.py
Docker Pull Command
Owner
resero

Comments (0)