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
docker run -it --gpus all --name prj_gorio pytorch/pytorch:1.6.0-cuda10.1-cudnn7-devel /bin/bash
pip freeze
python -V
python
import torch
# GPU check
torch.cuda.is_available()
# GPU 정보 확인
torch.cuda.get_device_name(0)
# 사용 가능한 GPU 개수
torch.cuda.device_count()
# 현재 GPU 번호
torch.cuda.current_device()
# device 정보 반환
torch.cuda.device(0)
daemon.json 내용 수정
sudo vim /etc/docker/daemon.json
{
"default-runtime": "nvidia",
"runtimes": {
"nvidia": {
"path": "nvidia-container-runtime",
"runtimeArgs": []
}
}
}
dockerd --config-file /etc/docker/daemon.json