리눅스, 서버
Docker 도커로 GPU 사용하여 우분투 서버 실행시키기
WinGyu
2024. 3. 20. 09:18
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
우선 위에 명령어를 사용 후
apt-get update
apt-get install -y nvidia-docker2
systemctl restart docker
위 명령어로 설치 후 도커를 재 실행 시켜주면 된다.
필자는 아래의 명령어로 서버를 가동했다
docker run --gpus all -d --name gpu_docker -p 2024:22 ubuntu:20.04 /bin/bash -c "while true; do sleep 1000; done"
--gpus all : 모든 GPU 사용
--name : 컨테이너 이름
-p : 컨테이너 접속 포트
-d : 실행 유지
실행되는 애플리케이션이 없으면 종료 시켜버리니 아래와 같은 명령어를 썼다
/bin/bash -c "while true; do sleep 1000; done"