Containers and Machine Learning

Docker Engine Utility for NVIDIA GPUs

 

nvidia-gpu-docker

Assuming the NVIDIA drivers and Docker® Engine are properly installed (see installation)

Ubuntu distributions

# Install nvidia-docker and nvidia-docker-plugin
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker_1.0.1-1_amd64.deb
sudo dpkg -i /tmp/nvidia-docker*.deb && rm /tmp/nvidia-docker*.deb

# Test nvidia-smi
nvidia-docker run --rm nvidia/cuda nvidia-smi

CentOS distributions

# Install nvidia-docker and nvidia-docker-plugin
wget -P /tmp https://github.com/NVIDIA/nvidia-docker/releases/download/v1.0.1/nvidia-docker-1.0.1-1.x86_64.rpm
sudo rpm -i /tmp/nvidia-docker*.rpm && rm /tmp/nvidia-docker*.rpm
sudo systemctl start nvidia-docker

# Test nvidia-smi
nvidia-docker run --rm nvidia/cuda nvidia-smi

Installing Docker on Ubuntu

To install Docker CE, you need the 64-bit version of one of these Ubuntu versions:

  • Zesty 17.04
  • Xenial 16.04 (LTS)
  • Trusty 14.04 (LTS)

SET UP THE REPOSITORY

  1. Update the apt package index:
    $ sudo apt-get update
    
  2. Install packages to allow apt to use a repository over HTTPS:
    $ sudo apt-get install \
        apt-transport-https \
        ca-certificates \
        curl \
        software-properties-common
    
  3. Add Docker’s official GPG key:
    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    

    Verify that you now have the key with the fingerprint9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.

    $ sudo apt-key fingerprint 0EBFCD88
    
    pub   4096R/0EBFCD88 2017-02-22
          Key fingerprint = 9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
    uid                  Docker Release (CE deb) <docker@docker.com>
    sub   4096R/F273FCD8 2017-02-22
    
  4. Use the following command to set up the stablerepository. You always need the stable repository, even if you want to install builds from the edge or testrepositories as well. To add the edge or test repository, add the word edge or test (or both) after the word stable in the commands below.

    Note: The lsb_release -cs sub-command below returns the name of your Ubuntu distribution, such as xenial. Sometimes, in a distribution like Linux Mint, you might have to change $(lsb_release -cs) to your parent Ubuntu distribution. For example, if you are usingLinux Mint Rafaela, you could use trusty.

    amd64:

    $ sudo add-apt-repository \
       "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
       $(lsb_release -cs) \
       stable"

    INSTALL DOCKER CE

    1. Update the apt package index.
      $ sudo apt-get update
      
    2. Install the latest version of Docker CE, or go to the next step to install a specific version. Any existing installation of Docker is replaced.
      $ sudo apt-get install docker-ce

      Configure Docker to start on boot

      Most current Linux distributions (RHEL, CentOS, Fedora, Ubuntu 16.04 and higher) use systemd to manage which services start when the system boots. Ubuntu 14.10 and below use upstart.

      systemd

      $ sudo systemctl enable docker
      

      To disable this behavior, use disable instead.

      $ sudo systemctl disable docker
      

      If you need to add an HTTP Proxy, set a different directory or partition for the Docker runtime files, or make other customizations, see customize your systemd Docker daemon options.

      upstart

      Docker is automatically configured to start on boot usingupstart. To disable this behavior, use the following command:

      $ echo manual | sudo tee /etc/init/docker.override
      

      chkconfig

      $ sudo chkconfig docker on