Development/Docker

[Docker] Install nvidia-docker2 on Ubuntu

jstar0525 2022. 10. 21. 00:44
반응형

이전 내용

https://jstar0525.tistory.com/352

 

[Docker] Install Docker Engine on Ubuntu

https://docs.docker.com/engine/install/ubuntu/ Install Docker Engine on Ubuntu docs.docker.com 위 링크로 접속하면 설치하는 방법이 나와있으나, 처음 Docker를 접하는 사람들을 위하여 정리해보고자 한다...

jstar0525.tistory.com

이전 글에 이어서

Docker에서

Nvidia GPU를 사용하기 위해서

Nvidia Docker2를 추가적으로 설치해야한다.

 

설치 가이드 링크

https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html#installing-on-ubuntu-and-debian

 

Installation Guide — NVIDIA Cloud Native Technologies documentation

On RHEL 7, install the nvidia-container-toolkit package (and dependencies) after updating the package listing: Restart the Docker daemon to complete the installation after setting the default runtime: Note Depending on how your RHEL 7 system is configured

docs.nvidia.com

위 링크로 접속하면

설치하는 방법이 나와있으나,

처음 Docker를 접하는 사람들을 위하여 정리해보고자 한다.

 

Env.

테스트 환경은

Ubuntu 18.04를 설치하고

Docker를 이미 설치한다고 가정을 했다. (이전 글 참고)

 

1. Setting up Docker

curl https://get.docker.com | sh \
  && sudo systemctl --now enable docker

 

2. Setting up NVIDIA Container Toolkit

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
sudo apt-get update
sudo apt-get install -y nvidia-docker2
sudo systemctl restart docker

 

3. Test CUDA container:

$ sudo docker run --rm --gpus all nvidia/cuda:11.0.3-base-ubuntu20.04 nvidia-smi
Thu Oct 20 15:42:24 2022       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.76       Driver Version: 515.76       CUDA Version: 11.7     |
|-------------------------------+----------------------+----------------------+
| 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  NVIDIA GeForce ...  Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   58C    P0    N/A /  N/A |      0MiB /  2048MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
반응형