OS : Ubuntu 22.04
docker에서 GPU를 사용하려면 docker-nvidia가 설치되어 있어야 한다.
docker nvidia 버전 확인은 다음과 같이 할 수 있다.
(base) $ docker version
Client: Docker Engine - Community
Version: 27.3.1
API version: 1.47
Go version: go1.22.7
Git commit: ce12230
Built: Fri Sep 20 11:41:00 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 27.3.1
API version: 1.47 (minimum version 1.24)
Go version: go1.22.7
Git commit: 41ca978
Built: Fri Sep 20 11:41:00 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.7.24
GitCommit: 88bf19b2105c8b17560993bee28a01ddc2f97182
runc:
Version: 1.2.2
GitCommit: v1.2.2-0-g7cb3632
docker-init:
Version: 0.19.0
GitCommit: de40ad0
docker에서 제대로 설치되었는지 확인하려면 가장 간단한 방법은 도커 이미지 안에 있는 환경에서 torch가 설치되어있고, 이 torch가 gpu를 인식하는지 확인하는 것이다.
1) GPU를 활성화해서 도커 이미지 실행
(base) kna35@aelcdml05089d:~$ docker run --gpus '"device=0"' -it feint225/dl:20210219
(base) root@be28ec91b7ea:/# conda activate yolov5
(yolov5) root@be28ec91b7ea:/# python
Python 3.8.5 (default, Sep 4 2020, 07:30:14)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
True
2) GPU 활성화 제외하고 도커 이미지 실행
(base) $ docker run -it feint225/dl:20210219
(base) root@8c2d28406105:/# conda activate yolov5
(yolov5) root@8c2d28406105:/# python
Python 3.8.5 (default, Sep 4 2020, 07:30:14)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.cuda.is_available()
/root/anaconda3/envs/yolov5/lib/python3.8/site-packages/torch/cuda/__init__.py:52: UserWarning: CUDA initialization: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx (Triggered internally at /pytorch/c10/cuda/CUDAFunctions.cpp:100.)
return torch._C._cuda_getDeviceCount() > 0
False
'프로그래밍 Programming' 카테고리의 다른 글
[Ubuntu] 유저 생성 - 원하는 UID, GID 지정 (0) | 2024.12.20 |
---|---|
[딥러닝] 도커(docker)에서 딥러닝 환경 구축하기 (1) (for JAX) (0) | 2024.12.18 |
[에러기록] libcuda.so is not in found but libcuda.so.1 (0) | 2024.11.08 |
[WSL] WSL 2 설치 및 설정 (0) | 2024.09.03 |
[Gym] Gymnasium custom environment (0) | 2024.06.02 |