Nvidia:Docker
How to install
(2024-04-08) 최신버전 확인된 Ubuntu 20.04 설치 버전
- Installing the NVIDIA Container Toolkit — NVIDIA Container Toolkit 1.14.5 documentation <- 이곳 매뉴얼 참조.
- Running a Sample Workload — NVIDIA Container Toolkit 1.14.5 documentation
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
Configure the container runtime by using the nvidia-ctk command:
위 명령을 치면 다음과 같은 로그가 출력된다.
WARN[0000] Ignoring runtime-config-override flag for docker
INFO[0000] Config file does not exist; using empty config
INFO[0000] Wrote updated config to /etc/docker/daemon.json
INFO[0000] It is recommended that docker daemon be restarted.
The nvidia-ctk command modifies the /etc/docker/daemon.json
file on the host. The file is updated so that Docker can use the NVIDIA Container Runtime.
docker 서비스 재시작한다:
Running a Sample Workload with Docker:
(2022-10-27) 최신버전 확인된 Ubuntu 20.04 설치 버전
Setting up Docker
Docker-CE on Ubuntu can be setup using Docker’s official convenience script:
Setting up NVIDIA Container Toolkit
Setup the package repository and the GPG key:
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) \
&& curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/$distribution/libnvidia-container.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
WARNING |
NVIDIA Container Toolkit 1.6.0 이전 버전의 경우 위의 libnvidia-container 저장소 대신 nvidia-docker 저장소를 사용해야 합니다. |
경우에 따라 다운로드한 목록 파일에 패키지가 호환되는 모든 배포판에 사용될 수 있으므로 예상되는 배포판 값과 일치하지 않는 URL이 포함될 수 있습니다. 예를 들면 다음과 같습니다.
- ubuntu20.04 또는 ubuntu22.04 배포 값의 경우 파일에 ubuntu18.04 URL이 포함됩니다.
- debian11 배포 값의 경우 파일에 debian10 URL이 포함됩니다.
WARNING |
리포지토리를 구성한 후 apt update를 실행하면 Signed-By 옵션의 충돌과 관련된 오류가 발생하면 관련 문제 해결 섹션을 참조하십시오. |
Install the nvidia-docker2 package (and dependencies) after updating the package listing:
Restart the Docker daemon to complete the installation after setting the default runtime:
At this point, a working setup can be tested by running a base CUDA container:
This should result in a console output shown below:
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.51.06 Driver Version: 450.51.06 CUDA Version: 11.0 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 Tesla T4 On | 00000000:00:1E.0 Off | 0 |
| N/A 34C P8 9W / 70W | 0MiB / 15109MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
Ubuntu 16.04/18.04/20.04, Debian Jessie/Stretch/Buster
# Add the package repositories
$ 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
CentOS 7.X/8.X (docker-ce), RHEL 7.X/8.X (docker-ce), Amazon Linux 1/2
$ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
$ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.repo | sudo tee /etc/yum.repos.d/nvidia-docker.repo
$ sudo yum install -y nvidia-container-toolkit
$ sudo systemctl restart docker
Usage
#### Test nvidia-smi with the latest official CUDA image
docker run --gpus all nvidia/cuda:10.0-base nvidia-smi
# Start a GPU enabled container on two GPUs
docker run --gpus 2 nvidia/cuda:10.0-base nvidia-smi
# Starting a GPU enabled container on specific GPUs
docker run --gpus '"device=1,2"' nvidia/cuda:10.0-base nvidia-smi
docker run --gpus '"device=UUID-ABCDEF,1"' nvidia/cuda:10.0-base nvidia-smi
# Specifying a capability (graphics, compute, ...) for my container
# Note this is rarely if ever used this way
docker run --gpus all,capabilities=utility nvidia/cuda:10.0-base nvidia-smi
Legacy 버전에서는 --gpus all
대신 --runtime=nvidia
를 사용 했었다.
nvidia-docker-compose
nvidia-docker-compose 항목 참조.
Troubleshooting
libnvidia-tls.so no search file
다음과 같은 에러가 발생될 수 있다.
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: conatiner init caused \"process_linux.go:432: running prestart hook 0 caused \\\"error running hook: exit status 1, stdout: , stderr: nvidia-container-cli: detection error: open failed: /usr/lib/x86_64-linux-gnu/libnvidia-tls.so.450.36.06: no such file or directory
/usr/lib/x86_64-linux-gnu/libnvidia-tls.so.450.36.06
파일을 찾을 수 없다. 아마 nvidia-container-cli -V
명령을 실행해도 정상적으로 실행되지 않을 것이다.
nvidia-docker를 다시 설치하자.
could not select device driver
다음과 같은 에러 출력됨:
컨테이너 툴킷을 다시 설치하자:
See also
Favorite site
- Repository configuration (nvidia-docker)
- [추천] NVIDIA NGC (Docker 이미지 목록 확인)
- Github - nvidia-container-runtime
- DGX-1 DOCKER USER GUIDE 17.08
- Docker를 활용한 deep learning 개발 환경 구축 1
- (Docker) NVIDIA Container Toolkit(NVIDIA Docker)의 동작원리
References
-
EXPERIENTIA_DOCET_-_nvidia_docker_ngc.pdf ↩