-
nvidia-docker가 지원되는 docker 최신 버전으로 업그레이드카테고리 없음 2020. 3. 20. 13:02
원래는 docker conatiner 내에서 nvidia GPU를 사용하기 위해 nvidia-docker 혹은 nvidia-docker2를 따로 설치해줘야했다. 하지만 docker 19.03 버전부터는 docker 자체적으로 nvidia GPU를 지원하고 nvidia-docker는 사용하지 않는다.
다시 말해서 기존에는 컨테이너 생성 시에 아래처럼 입력해야 GPU를 지원했지만,
$ nvidia-docker run ... -e NVIDIA_VISIBLE_DEVICES=1,2,3 ... $ docker --runtime=nvidia ... -e NVIDIA_VISIBLE_DEVICES=1,2,3 ...
이제는 아래처럼 컨테이너를 생성해서 GPU를 사용할 수 있다.
$ docker run ... --gpus "device=1,2,3" ... $ docker run ... --gpus all ...
실행 방법이 조금 바뀌는 것이야 어쨌든 nvidia-docker는 deprecated 될 예정이므로 업그레이드를 하는 것이 좋겠다.
Ubuntu 기준
기존 docker 삭제
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get purge nvidia-docker2
$ sudo apt-get remove docker docker-engine docker.io containerd runc $ sudo apt-get purge nvidia-docker2
nvidia-driver 업그레이드
$ sudo add-apt-repository ppa:graphics-drivers/ppa $ sudo apt-get update $ sudo apt-get install build-essential dkms $ sudo apt-get install nvidia-driver-xxx
nvidia-driver- 까지 타이핑하고 Tab키를 두 번 누르면 드라이버 목록이 나오는데 가장 최신 버전을 설치하면 된다.
docker-ce 설치
$ sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - $ sudo apt-key fingerprint 0EBFCD88 $ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" $ sudo apt-get install docker-ce docker-ce-cli containerd.io
NVIDIA container toolkit 설치
$ 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 nvidia-container-toolkit $ sudo systemctl restart docker
User group, namespace 세팅
컨테이너 생성 시 -v 옵션으로 컨테이너와 호스트 간의 볼륨 공유를 하는 경우, 컨테이너 내에서 만든 파일의 owner가 root로 된다. '나'로 owner가 설정되도록 하려면 다음과 같이 설정해야 한다.
$ sudo usermod -aG docker your-user-name $ sudo vim /etc/docker/daemon.json ###################################################### # damon.json파일이 비어있을 경우 아래의 내용을 입력 { "userns-remap": "hskim" # hskim을 본인의 ID로 대체 } # damon.json에 기존 내용이 있을 경우 아래와 같이 추가 { "userns-remap": "hskim", "defau... # other settings } ###################################################### $ sudo systemctl restart docker.service
#나의 user id를 확인 $ cat /etc/subuid | grep $USER hskim:1345184:65536 #나의 ID를 이름으로 가진 폴더가 있는지 확인 $ sudo ls -l /var/lib/docker
끝.
참고
https://docs.docker.com/install/linux/docker-ce/ubuntu/
Get Docker Engine - Community for Ubuntu
To get started with Docker Engine - Community on Ubuntu, make sure you meet the prerequisites, then install Docker. Prerequisites Docker EE customers To install Docker Enterprise Edition (Docker EE),...
docs.docker.com
Workstation Setup for Docker with the New NVIDIA Container Toolkit (nvidia-docker2 is deprecated)
It's time for a "Docker with NVIDIA GPU support" update. This post will guide you through a useful Workstation setup (including User-name-spaces and performance tuning) with the new versions of Docker and the NVIDIA GPU container toolkit.
www.pugetsystems.com
How-To Setup NVIDIA Docker and NGC Registry on your Workstation - Part 3 Setup User-Namespaces
In this post I'll go through setting up Docker to use User-Namespaces. This is a very important step to achieving a comfortable docker work-flow on a personal Workstation. I will show you how to configure Docker so that instead of files and processes being
www.pugetsystems.com