Set up Docker to use Nvidia GPU compatible container [Ubuntu 18.04]
Docker has native support for "Container Acceleration with Nvidia GPUs" since version 19.03.This feature is made available by using the NVIDIA Container Toolkit.Here, make the initial settings required for it.
Environment
OS: Ubuntu 18.04 LTS
GPU: GTX1080
- 1. Step XNUMX: Check the prerequisites
- 2. Nvidia docker 2 installation procedure and prerequisite confirmation [Ubuntu 18.04]
- 3. Step XNUMX: Install Docker
- 4. Install the latest version of Docker CE on Ubuntu 18.04 [Document compliant]
- 5. Step XNUMX: Install Nvidia GPU Driver
- 6. Two ways to install NVIDIA GPU driver [Ubuntu 18.04]
- 7. Step XNUMX: Make GPU container available in Docker
- 8. Check the operation
Step XNUMX: Check the prerequisites
Before using Docker's "acceleration of containers by GPU", let's check the environment.GPU containers cannot be used in environments that are too old.
- GNU / Linux x86_64 (kernel version> 3.10) ← Ubuntu 18.04 so OK
- NVIDIA GPU with Architecture> Fermi (2.1) ← If GPU is for desktop, GTX 600 or later is OK
- NVIDIA driver version ≧ 361.93 ← See step XNUMX below
Please see the following page for details.
Step XNUMX: Install Docker
If you haven't installed Docker yet, follow the steps below to install it.
Step XNUMX: Install Nvidia GPU Driver
The Nvidia driver is required to run the GPU container (CUDA container).
The version of the Nvidia driver should be more than the version of CUDA you want to use (for example, tensorflow requires exactly the CUDA version depending on the version you use).
As long as you install the Nvidia driver properly, you do not need to install CUDA toolkit or NVIDIA Container Toolkit separately.
The installation method of Nvidia Driver is summarized below.
Step XNUMX: Make GPU container available in Docker
Enter the following from the terminal.
Official reference: https://github.com/NVIDIA/nvidia-docker
#Add package repository distribution = $ (. / Etc / os-release; echo $ ID $ VERSION_ID) curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add- curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit sudo systemctl restart docker
Check the operation
#Tested with the latest official CUDA image docker run --gpus all nvidia / cuda: 9.0-base nvidia-smi
If all goes well, you will see this display.
To use the GPU container from now on, add the "–gpus" option to "docker run".
If you just installed docker, it may not run unless you add sudo before docker run.
[Ubuntu] Settings and precautions for running docker without the sudo command
These are the initial settings required to use Docker's GPU-compatible container on Ubuntu.
Reference books
In-Depth Discussions
Comment list
There are not any comments yet