https://sseongju1.tistory.com/16
[Docker] nvidia-docker2 설치하기 (Ubuntu 20.04)
1. Setting Up Docker (이미 도커가 설치 되어있는경우 이 과정을 Skip하자!!!!) $ curl https://get.docker.com | sh \ && sudo systemctl --now enable docker % Total % Received % Xferd Aver..
sseongju1.tistory.com
https://docs.docker.com/engine/install/ubuntu/
Install Docker Engine on Ubuntu
docs.docker.com
Nvidia Docker
NVIDIA Container Toolkit은 GPU accelerated Docker container를 구축하고 실행 할 수 있다. 즉 NVIDIA GPU를 활용할 수 있도록 컨테이너를 자동으로 구성해주는 다양한 요소를 포함하고 있다.
설치
https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/install-guide.html
https://github.com/NVIDIA/nvidia-docker
- Pre-Requisites
- Linux kernel >= 3.10 (GNU/Linux x86_64)
- Nvidia driver >= 418.81.07
- Docker >= 19.03
- Nvidia GPU Architecture >= Kepler
기본적으로 적절한 Linux kernel의 버전의 OS와 Nvidia driver는 설치되어 있다고 가정한다.
Docker 설치
이전 버전 삭제
sudo apt-get remove docker docker-engine docker.io containerd runc
if there is docker-ce, ..
sudo apt-get remove docker-ce
set up the repository
- https를 통해 repository를 사용할 수 있도록 패키지 설치.
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
- Add Docker’s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- Stable repo로 설정
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
install Docker Engine
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
특정 버전을 설치 하고자 한다면 아래와 같이 버전을 확인하고 버전을 지정해서 설치 한다.
apt-cache madison docker-ce # [print example] # docker-ce | 5:20.10.12~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages # docker-ce | 5:20.10.11~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages # docker-ce | 5:20.10.10~3-0~ubuntu-focal | https://download.docker.com/linux/ubuntu focal/stable amd64 Packages # ...
설치 후 단계 (option)
https://docs.docker.com/engine/install/linux-postinstall/
- add docker group
# Create the docker group.
sudo groupadd docker
# Add your user to the docker group.
sudo usermod -aG docker $USER
sudo usermod -aG docker {other user}
# reboot or type below for activate new group
newgrp docker
- docker test
docker run hello-world
Nvidia Container Toolkit 설정
- Stable repository 및 GPG key 설정
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
- install nvidia-docker
sudo apt-get update
sudo apt-get install -y nvidia-docker2
- restart docker daemon
sudo systemctl restart docker
- base CUDA container 테스트
sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.86 Driver Version: 470.86 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| 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 RTX A6000 Off | 00000000:0B:00.0 Off | Off |
| 30% 40C P8 24W / 300W | 17MiB / 48685MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 1 NVIDIA RTX A6000 Off | 00000000:0C:00.0 Off | Off |
| 30% 36C P8 20W / 300W | 5MiB / 48685MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
+-----------------------------------------------------------------------------+
Nvidia-docker images
tensorflow와 pytorch 버전 정보와 compatibility, 그리고 사용방법은 다음글에서 자세히 다룬다.
tensorflow/tensorflow
https://hub.docker.com/r/tensorflow/tensorflow/
다음과 같이 원하는 버전의 tensoflow image를 받아서 사용하면 된다.
docker pull tensorflow/tensorflow:2.7.0-gpu-jupyter
pytorch/pytorch
https://hub.docker.com/r/pytorch/pytorch
다음과 같이 원하는 버전의 pytorch image를 받아서 사용하면 된다. pytorch에서 제공해주는 이미지는 기본적으로 jupyter notebook을 제공하고 있지 않으나 anaconda를 기반으로 동작하고 있기 때문에 conda install -c conda-forge jupyterlab 을 통해 쉽게 설치 하고 사용 할 수 있다.
docker pull pytorch/pytorch:1.10.0-cuda11.3-cudnn8-runtime