NVIDIA/nvidia-container-runtime

Name: nvidia-container-runtime

Owner: NVIDIA Corporation

Description: NVIDIA container runtime

Created: 2017-09-05 22:03:28.0

Updated: 2018-04-02 10:44:37.0

Pushed: 2018-03-29 18:54:22.0

Homepage: null

Size: 159314

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

nvidia-container-runtime

GitHub license Package repository

A modified version of runc adding a custom pre-start hook to all containers.
If environment variable NVIDIA_VISIBLE_DEVICES is set in the OCI spec, the hook will configure GPU access for the container by leveraging nvidia-container-cli from project libnvidia-container.

Usage example
tup a rootfs based on Ubuntu 16.04
(mktemp -d) && mkdir rootfs
 -sS http://cdimage.ubuntu.com/ubuntu-base/releases/16.04/release/ubuntu-base-16.04-core-amd64.tar.gz | tar --exclude 'dev/*' -C rootfs -xz

eate an OCI runtime spec
ia-container-runtime spec
-i 's;"sh";"nvidia-smi";' config.json
-i 's;\("TERM=xterm"\);\1, "NVIDIA_VISIBLE_DEVICES=0";' config.json

n the container
 nvidia-container-runtime run nvidia_smi
Installation
Ubuntu distributions
  1. Install the repository for your distribution by following the instructions here.
  2. Install the nvidia-container-runtime package:
     apt-get install nvidia-container-runtime
    
CentOS distributions
  1. Install the repository for your distribution by following the instructions here.
  2. Install the nvidia-container-runtime package:
     yum install nvidia-container-runtime
    
Docker Engine setup

To register the nvidia runtime, use the method below that is best suited to your environment.
You might need to merge the new argument with your existing configuration.

Systemd drop-in file
 mkdir -p /etc/systemd/system/docker.service.d
 tee /etc/systemd/system/docker.service.d/override.conf <<EOF
vice]
Start=
Start=/usr/bin/dockerd --host=fd:// --add-runtime=nvidia=/usr/bin/nvidia-container-runtime

 systemctl daemon-reload
 systemctl restart docker
Daemon configuration file
 tee /etc/docker/daemon.json <<EOF

"runtimes": {
    "nvidia": {
        "path": "/usr/bin/nvidia-container-runtime",
        "runtimeArgs": []
    }
}


 pkill -SIGHUP dockerd

You can optionally reconfigure the default runtime by adding the following to /etc/docker/daemon.json:

ault-runtime": "nvidia"
Command line
 dockerd --add-runtime=nvidia=/usr/bin/nvidia-container-runtime [...]
Environment variables (OCI spec)

Each environment variable maps to an command-line argument for nvidia-container-cli from libnvidia-container.
These variables are already set in our official CUDA images.

NVIDIA_VISIBLE_DEVICES

This variable controls which GPUs will be made accessible inside the container.

Possible values
NVIDIA_DRIVER_CAPABILITIES

This option controls which driver libraries/binaries will be mounted inside the container.

Possible values Supported driver capabilities
NVIDIA_REQUIRE_*

A logical expression to define constraints on the configurations supported by the container.

Supported constraints Expressions

Multiple constraints can be expressed in a single environment variable: space-separated constraints are ORed, comma-separated constraints are ANDed.
Multiple environment variables of the form NVIDIA_REQUIRE_* are ANDed together.

NVIDIA_DISABLE_REQUIRE

Single switch to disable all the constraints of the form NVIDIA_REQUIRE_*.

NVIDIA_REQUIRE_CUDA

The version of the CUDA toolkit used by the container. It is an instance of the generic NVIDIA_REQUIRE_* case and it is set by official CUDA images. If the version of the NVIDIA driver is insufficient to run this version of CUDA, the container will not be started.

Possible values
CUDA_VERSION

Similar to NVIDIA_REQUIRE_CUDA, for legacy CUDA images.
In addition, if NVIDIA_REQUIRE_CUDA is not set, NVIDIA_VISIBLE_DEVICES and NVIDIA_DRIVER_CAPABILITIES will default to all.

Copyright and License

This project is released under the BSD 3-clause license.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.