Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save qmaruf/329a16c4fb0f675fc299ea81bde115ed to your computer and use it in GitHub Desktop.

Select an option

Save qmaruf/329a16c4fb0f675fc299ea81bde115ed to your computer and use it in GitHub Desktop.

Revisions

  1. @Brainiarc7 Brainiarc7 revised this gist Feb 8, 2018. 1 changed file with 9 additions and 1 deletion.
    10 changes: 9 additions & 1 deletion nvidia-docker2-deploy-ubuntu-16.04LTS.md
    Original file line number Diff line number Diff line change
    @@ -84,7 +84,7 @@ To register the nvidia runtime, use either method below on Ubuntu 16.04LTS+. It
    `nvidia-docker` registers a new container runtime to the Docker daemon.
    You must select the nvidia runtime when using docker run, as illustrated below (with nvidia-smi):

    docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi
    sudo docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi



    @@ -111,6 +111,14 @@ You can use:

    To check if you can run docker without sudo.

    For the snippet above, you can now run it as:

    docker run -u $(USER) --runtime=nvidia --rm nvidia/cuda nvidia-smi

    Or directly IF you're logged in as a user that's a member of the `docker` group:

    docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi




  2. @Brainiarc7 Brainiarc7 revised this gist Feb 8, 2018. 1 changed file with 18 additions and 0 deletions.
    18 changes: 18 additions & 0 deletions nvidia-docker2-deploy-ubuntu-16.04LTS.md
    Original file line number Diff line number Diff line change
    @@ -93,6 +93,24 @@ You must select the nvidia runtime when using docker run, as illustrated below (

    If the systemd unit method fails, skip straight to the configuration file method. The result is the same.

    If you do not want to run Docker as a root user, the smart approach is as follows:

    Add the docker group if it doesn't already exist:

    sudo groupadd docker

    Add the connected user "$USER" to the docker group. Change the user name to match your preferred user if you do not want to use your current user:

    sudo gpasswd -a $USER docker

    Either do a newgrp docker or log out/in to activate the changes to groups.

    You can use:

    docker run hello-world

    To check if you can run docker without sudo.




  3. @Brainiarc7 Brainiarc7 revised this gist Feb 8, 2018. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion nvidia-docker2-deploy-ubuntu-16.04LTS.md
    Original file line number Diff line number Diff line change
    @@ -53,7 +53,7 @@ Followed by `nvidia-docker2`:

    To register the nvidia runtime, use either method below on Ubuntu 16.04LTS+. It is recommended that you use the systemd drop-in file method to prevent docker upgrades from directly overwriting the docker daemon configuration file.

    **(a).Systemd drop-in file (Recommended approach):**
    **(a).Systemd drop-in file (Recommended approach, but see notes below):**

    sudo mkdir -p /etc/systemd/system/docker.service.d
    sudo tee /etc/systemd/system/docker.service.d/override.conf <<EOF
    @@ -100,3 +100,4 @@ If the systemd unit method fails, skip straight to the configuration file method




  4. @Brainiarc7 Brainiarc7 revised this gist Feb 8, 2018. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions nvidia-docker2-deploy-ubuntu-16.04LTS.md
    Original file line number Diff line number Diff line change
    @@ -85,7 +85,13 @@ To register the nvidia runtime, use either method below on Ubuntu 16.04LTS+. It
    You must select the nvidia runtime when using docker run, as illustrated below (with nvidia-smi):

    docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi




    **Notes:**

    If the systemd unit method fails, skip straight to the configuration file method. The result is the same.



  5. @Brainiarc7 Brainiarc7 created this gist Feb 8, 2018.
    96 changes: 96 additions & 0 deletions nvidia-docker2-deploy-ubuntu-16.04LTS.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,96 @@
    **How to install NVIDIA Docker 2 package on Ubuntu and Debian:**

    If you came to this result (from Google or elsewhere) after realizing that Nvidia-docker's entry on this subject does not result in a working installation, here are the basic steps needed to install this package correctly:

    For starters, ensure that you've installed the latest Docker Community edition by following the steps below:


    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    sudo apt-key fingerprint 0EBFCD88
    sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
    sudo apt-get update
    sudo apt-get install docker-ce
    sudo service docker restart


    Then, proceed to adding the required repositories and installing the needed software:

    Start with `nvidia-docker-runtime`:

    **For Ubuntu distributions (Xenial x86_64):**

    First, if you have older nvidia-docker installations, purge the installation and all associated GPU containers:

    docker volume ls -q -f driver=nvidia-docker | xargs -r -I{} -n1 docker ps -q -a -f volume={} | xargs -r docker rm -f
    sudo apt-get purge -y nvidia-docker

    Then proceed:

    curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | \
    sudo apt-key add -
    curl -s -L https://nvidia.github.io/nvidia-container-runtime/ubuntu16.04/amd64/nvidia-container-runtime.list | \
    sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
    sudo apt-get update

    **For Debian distributions (Stretch x86_64):**

    curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | \
    sudo apt-key add -
    curl -s -L https://nvidia.github.io/nvidia-container-runtime/debian9/amd64/nvidia-container-runtime.list | \
    sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list
    sudo apt-get update


    Install the `nvidia-container-runtime` package:

    sudo apt-get install nvidia-container-runtime

    Followed by `nvidia-docker2`:

    sudo apt-get install nvidia-docker2

    **Docker Engine setup:**

    To register the nvidia runtime, use either method below on Ubuntu 16.04LTS+. It is recommended that you use the systemd drop-in file method to prevent docker upgrades from directly overwriting the docker daemon configuration file.

    **(a).Systemd drop-in file (Recommended approach):**

    sudo mkdir -p /etc/systemd/system/docker.service.d
    sudo tee /etc/systemd/system/docker.service.d/override.conf <<EOF
    [Service]
    ExecStart=
    ExecStart=/usr/bin/dockerd --host=fd:// --add-runtime=nvidia=/usr/bin/nvidia-container-runtime
    EOF
    sudo systemctl daemon-reload
    sudo systemctl restart docker

    **(b). Daemon configuration file (Use if you're on a distribution such as [Devuan](https://devuan.org/), without a systemd dependency):**

    sudo tee /etc/docker/daemon.json <<EOF
    {
    "runtimes": {
    "nvidia": {
    "path": "/usr/bin/nvidia-container-runtime",
    "runtimeArgs": []
    }
    }
    }
    EOF
    sudo pkill -SIGHUP dockerd


    **Basic usage:**

    `nvidia-docker` registers a new container runtime to the Docker daemon.
    You must select the nvidia runtime when using docker run, as illustrated below (with nvidia-smi):

    docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi