nvidia-docker2 installation

Yongsang Yoon·2022년 3월 17일
0

docker

목록 보기
2/2

docker install
https://league-cat.tistory.com/399

docker gpu 할당
https://kyumdoctor.co.kr/18

도커 설치 생성 커맨트 정리
https://keyog.tistory.com/43

도커 설치 생성 커맨트 정리2
https://soyoung-new-challenge.tistory.com/54

docker logout
docker login
docker info | grep Username

container

Pull image

sudo docker pull nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04

Commands

docker images : listing all images
docker ps -a : Listing all active containers

Docker Run

Run image

nvidia-docker run -it nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04 /bin/bash

Share direcotry

-v option은 시스템 볼륨을 마운트할때 사용.

docker run --v [호스트 폴더 경로]:[컨테이너 폴더 경로] [이미지] 

docker -v /on/my/host/1:/on/the/container/1 \
       -v /on/my/host/2:/on/the/container/2 \
       ...
       
-v $(pwd):/home

Tags

--name 는 컨테이너에 이름지정

docker run -it --name puma nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04 /bin/bash

Container remove

docker rm [container_id]
docker rm [container_name]

Container

container detach

ctrl+p ctrl+q

container attach

sudo docker attach [NAME]

Update name and tag

docker tag <IMAGE_ID> <NEW_IMAGE_NAME>:<NEW_TAG>
docker image tag <기존의 이미지명>:<기존의 태그명> <새로운 이미지명>:<새로운 태그명>

docker build

-t는 이미지 이름을 지정하는 옵션입니다

docker build -t ubuntu:git2 .

The differece between Base, Runtime and Devel.

CUDA images come in three flavors and are available through the NVIDIA public hub repository.

  • base: starting from CUDA 9.0, contains the bare minimum (libcudart) to deploy a pre-built CUDA application. Use this image if you want to manually select which CUDA packages you want to install.
  • runtime: extends the base image by adding all the shared libraries from the CUDA toolkit. Use this image if you have a pre-built application using multiple CUDA libraries.
  • devel: extends the runtime image by adding the compiler toolchain, the debugging tools, the headers and the static libraries. Use this image to compile a CUDA application from sources.

* devel로하면 nvcc가있는데 runtime의 경우 없다.

untime : base에서 build하였고 CUDA math 라이브러리와, NCLL을 포함합니다. 그리고 CUDNN을 포함합니다.

(CUDNN은 CUDA Deep Neural Network library로써 딥러닝 연산을 빠르게 해주는 라이브러리로 딥러닝을 하는 사람들에겐 필수로 설치해야 합니다)

devel : runtime 이미지에서 build하였고, 컴파일러 도구 모음, 디버깅 도구, 헤더 및 정적 라이브러리를 포함합니다. 이 이미지를 사용하여 소스에서 CUDA 애플리케이션을 컴파일 할 수 있습니다.

Docker 중지 없이 빠져나오기

Container를 running 상태로 두면서 빠져나오기 위해서는 Ctrl+p, Ctrl+q를 순서대로 입력(중간에 메세지가 안떠도 끝까지 입력)해주면 아래와 같이 메세지가 뜨면서 Container를 빠져나올 수 있다. 출처

Container SSH 접속

이 부분은 외부에서의 접속을 위해 꼭 해야합니다. (2)단계에서 생성한 Container에 접속한 후 아래 과정을 거칩니다.

ssh 설정에 필요한 것들 설치

nano, ssh-server, net-tools
apt-get update # update 해줘야 다른 프로그램 install이 됩니다
apt-get install nano net-tools openssh-server

ssh config 변경

ssh 접속 port 변경, 권한 부여
nano /etc/ssh/sshd_config
nano 명령어는 우분투에서 파일 내용을 수정할 때 사용합니다. 위 명령어로 sshd_config 파일에 접속하여 중간에 Port, PermitRootLogin 앞의 #을 지우고 아래와 같이 수정합니다.

여기서의 7001 port는 host machine이 아닌 Container의 port를 열어주는 것입니다.

passwd root

service ssh start

/usr/lib/cuda가 없는데 쿠다가된다... 신기하다.

import torch
print(torch.cuda.is_available())
print(torch.version.cuda)
print(torch.backends.cudnn.version())

profile
I'm a student

0개의 댓글