3
1

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.

日記:docker run --gpus all でエラーになった

Last updated at Posted at 2021-11-30

環境

  • ubuntu 20.04
  • GPU GeForce GTX 1060

ローカルのGPU設定

  • NVIDIA-SMI 460.39
  • Driver Version: 460.39
  • CUDA Version: 11.2

ことの経緯

  1. tensorflow公式からGPUサポートのtensorflowイメージをpull
  2. run --gpus all
  3. ERRO[0000] error waiting for container: context canceled
  4. 確認

1. tensorflow公式からGPUサポートのtensorflowイメージをpull

公式に従ってタグlatest-gpuのイメージをプル

docker pull tensorflow/tensorflow:latest-gpu

2. run

sudo docker run --gpus all -it -v マウントしたいローカルのディレクトリ:コンテナ内のマウント先 --shm-size 8G --name コンテナの名前 tensorflow/tensorflow:latest-gpu

3. ERRO[0000] error waiting for container: context canceled

docker: Error response from daemon: could not select device driver "" with capabilities: [[gpu]].
ERRO[0000] error waiting for container: context canceled

うーーん、この

対策

nvidia-container-runtimeなどを入れる。

sudo apt-get install nvidia-container-runtime
curl -s -L https://nvidia.github.io/nvidia-container-runtime/gpgkey | \
  sudo apt-key add -

distribution=$(. /etc/os-release;echo $ID$VERSION_ID)

curl -s -L https://nvidia.github.io/nvidia-container-runtime/$distribution/nvidia-container-runtime.list | \
  sudo tee /etc/apt/sources.list.d/nvidia-container-runtime.list

sudo apt-get update
sudo apt-get install nvidia-container-runtime
service docker restart

気を取り直して

sudo docker run --gpus all -it -v マウントしたいローカルのディレクトリ:コンテナ内のマウント先 --shm-size 8G --name コンテナの名前 tensorflow/tensorflow:latest-gpu

4. 確認

(コンテナ内で) nvidia-smi

よし

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.39       Driver Version: 460.39       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 106...  Off  | 00000000:1D:00.0  On |                  N/A |
| 27%   34C    P8     9W / 120W |    242MiB /  6077MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
+-----------------------------------------------------------------------------+
3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?