5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

GPUが動くDocker環境を立ち上げる(Google Colabと同等の環境)

Last updated at Posted at 2022-12-29

Google ColabでさくっとGPUが使えるように、自分のローカル環境にも同様の環境を作りたい。

nvidia-smi

で自分のホストOSのGPUバージョン、Cuda Driverバージョン、CUDAバージョンを確認。
対応するCUDAバージョンをメモする。

docker pull nvidia/cuda:11.2.0-cudnn8-devel-ubuntu20.04

対応するDockerバージョンをpull。

docker run \
--gpus all \
--shm-size=2gb \
-v /home/my/Documents/anomalib:/root/anomalib/ \
-v /tmp/.X11-unix:/tmp/.X11-unix:rw \
-e DISPLAY=$DISPLAY \
--device /dev/video0:/dev/video0:mwr \
--device /dev/video1:/dev/video1:mwr \
-it \
nvidia/cuda:11.2.0-cudnn8-devel-ubuntu20.04

run。後々のことを考えてGPU利用や、メモリサイズ確保、ホストPCとのフォルダ共有、USBカメラ利用などの設定をしておく。

コンテナにCUDA Toolkitが必要だが、nvidia/cudaのDockerイメージには既に入っている。

5b208976-b632-11e5-8406-38d379ec46aa.png

nvidia-smi
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.27.04    Driver Version: 460.27.04    CUDA Version: 11.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GTX 1080    On   | 00000000:01:00.0 Off |                  N/A |
| N/A   47C    P3    27W /  N/A |    274MiB /  8119MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
+-----------------------------------------------------------------------------+

その他

python、pipがない。
nvidia/cudaでもpipが入っていないのか。

apt-get update
apt-get install -y python3 python3-pip

gitもいない。

apt-get install -y git

参考
https://skmkuma.com/ubuntuos%E3%81%A7gpu%E7%92%B0%E5%A2%83%E3%82%92%E4%BD%BF%E3%81%86/

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?