1. 発生したエラー
GPU を必要とする docker コンテナを立ち上げたところ、以下のような問題が発生した。
$ docker compose up -d
[+] up 24/25
✔ Image plantuml/plantuml-server:jetty Pulled 48.7s
✔ Network environments_hogehoge-network Created 0.0s
✔ Container plantuml-server Started 12.8s
⠸ Container hogehoge Starting 13.3s
✔ Container hogehoge-mlflow Started 13.1s
✔ Container hogehoge-docs Started 1.4s
Error response from daemon: failed to discover GPU vendor from CDI: no known GPU vendor found
Error response from daemon: failed to discover GPU vendor from CDI: no known GPU vendor found が手がかり。
**他のエラーの対処法もあるよ|・`ω・´)・`ω・´)**
「3-3.」では Error response from daemon: AMD CDI spec not found の対処法も書いているので、そちらで困っている方もご覧ください。
2. 実行環境
実行時の環境は以下の通り。
| items | version など |
|---|---|
| Host OS | Ubuntu 24.04 |
| NVIDIA driver | 595.91.07 |
| cuda | 13.2 |
| docker | 29.8.2, build 7fc2dff |
以下の通り、 host マシン側では nvidia-smi が実行できるので、問題は「docker コンテナ内から GPU にアクセスできていないこと」だとわかる。
$ nvidia-smi
Thu Oct 1 20:48:05 2026
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 595.91.07 Driver Version: 595.91.07 CUDA Version: 13.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 Tesla T4 Off | 00000000:0B:00.0 Off | 0 |
| N/A 34C P8 14W / 70W | 0MiB / 15360MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| No running processes found |
+-----------------------------------------------------------------------------------------+
3. 対策
docker から GPU にアクセスできない時の原因は、 NVIDIA Container Toolkit がインストールされていないことであることが多い。
本当に存在しないか確認してから、インストールを進めよう。
3-1. NVIDIA Container Toolkit のインストール状況確認
Docker コンテナ内ではなく、ホストマシン上で以下のコマンドを実行しよう。
$ nvidia-ctk --version
もしすでにインストールされていた場合は、以下のように表示される。
NVIDIA Container Toolkit CLI version 1.20.1
commit: dffc40b4f820ce5c512633bac9e0418d0e05a2ee
その場合は、この記事の方法では対処できないので、他の解決法を検討してほしい。
そうではなく、 nvidia-ctk がまだ存在しない場合には、以下の手順を進めていこう。
3-2. NVIDIA Container Toolkit をインストールする
基本的には以下の手順に従う。
一応、私が実行した手順を以下に記載しておく
2026/10/02 時点の NVIDIA Container Toolkit インストール手順
3-2-1. 前提パッケージの install
$ sudo apt-get update && sudo apt-get install -y --no-install-recommends \
ca-certificates \
curl \
gnupg2
[sudo] password for ubuntu:
Hit:1 https://download.docker.com/linux/ubuntu noble InRelease
Hit:2 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:3 http://archive.ubuntu.com/ubuntu noble InRelease
Get:4 http://archive.ubuntu.com/ubuntu noble-updates InRelease [126 kB]
Hit:5 http://archive.ubuntu.com/ubuntu noble-backports InRelease
Get:6 http://archive.ubuntu.com/ubuntu noble-updates/main amd64 Packages [1,364 kB]
Get:7 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages [1,699 kB]
Fetched 3,190 kB in 3s (951 kB/s)
# ... 省略
Service restarts being deferred:
/etc/needrestart/restart.d/dbus.service
systemctl restart docker.service
systemctl restart getty@tty1.service
systemctl restart systemd-logind.service
systemctl restart unattended-upgrades.service
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
3-2-2. どのバージョンの nvidia-container-toolkit をインストールするかを指定する
$ curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://nvidia.github.io/libnvidia-container/stable/deb/$(ARCH) /
#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://nvidia.github.io/libnvidia-container/experimental/deb/$(ARCH) /
3-2-3. apt のパッケージリストを更新
「3-2-2.」の結果を使って、更新しているので、必ず 3-2-2. を先に実施する。
$ sudo apt-get update
Get:1 https://nvidia.github.io/libnvidia-container/stable/deb/amd64 InRelease [1,477 B]
Hit:2 https://download.docker.com/linux/ubuntu noble InRelease
Get:3 https://nvidia.github.io/libnvidia-container/stable/deb/amd64 Packages [28.0 kB]
Hit:4 http://security.ubuntu.com/ubuntu noble-security InRelease
Hit:5 http://archive.ubuntu.com/ubuntu noble InRelease
Hit:6 http://archive.ubuntu.com/ubuntu noble-updates InRelease
Hit:7 http://archive.ubuntu.com/ubuntu noble-backports InRelease
Fetched 29.5 kB in 1s (22.6 kB/s)
Reading package lists... Done
3-2-4. NVIDIA Container Toolkit のインストール
$ export NVIDIA_CONTAINER_TOOLKIT_VERSION=1.20.1-1
sudo apt-get install -y \
nvidia-container-toolkit=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
nvidia-container-toolkit-base=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
libnvidia-container-tools=${NVIDIA_CONTAINER_TOOLKIT_VERSION} \
libnvidia-container1=${NVIDIA_CONTAINER_TOOLKIT_VERSION}
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
eatmydata libeatmydata1 python-babel-localedata python3-babel python3-jinja2 python3-json-pointer python3-jsonpatch python3-jsonschema python3-markupsafe
python3-pyrsistent python3-tz
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
libnvidia-container-tools libnvidia-container1 nvidia-container-toolkit nvidia-container-toolkit-base
0 upgraded, 4 newly installed, 0 to remove and 50 not upgraded.
Need to get 8,752 kB of archives.
After this operation, 37.7 MB of additional disk space will be used.
Get:1 https://nvidia.github.io/libnvidia-container/stable/deb/amd64 libnvidia-container1 1.20.1-1 [1,236 kB]
Get:2 https://nvidia.github.io/libnvidia-container/stable/deb/amd64 libnvidia-container-tools 1.20.1-1 [20.8 kB]
Get:3 https://nvidia.github.io/libnvidia-container/stable/deb/amd64 nvidia-container-toolkit-base 1.20.1-1 [5,993 kB]
# ... 省略
Service restarts being deferred:
/etc/needrestart/restart.d/dbus.service
systemctl restart docker.service
systemctl restart getty@tty1.service
systemctl restart systemd-logind.service
systemctl restart unattended-upgrades.service
No containers need to be restarted.
No user sessions are running outdated binaries.
No VM guests are running outdated hypervisor (qemu) binaries on this host.
3-2-5. インストール結果の確認
$ nvidia-ctk --version
NVIDIA Container Toolkit CLI version 1.20.1
commit: dffc40b4f820ce5c512633bac9e0418d0e05a2ee
NVIDIA Container Toolkit を install し終わったら以下を実行しよう。
- Docker に nvidia ランタイムを登録(/etc/docker/daemon.json を作成)して再起動
$ sudo nvidia-ctk runtime configure --runtime=docker
INFO[0000] Config file does not exist; using empty config
INFO[0000] Wrote updated config to /etc/docker/daemon.json
INFO[0000] It is recommended that docker daemon be restarted.
$ sudo systemctl restart docker
3-3. CDI spec も用意する
3-3-1. NVIDIA Container Toolkit だけでは足りない場合
ただし、 nvidia-ctk を install しただけだと、エラーが解消するわけではなく、実はエラーメッセージが変わるだけに終わることもある。
$ docker compose -f environments/compose.gpu.yml up -d
WARN[0000] /home/ubuntu/work/hoge/environments/compose.gpu.yml: the attribute `version` is obsolete, it will be ignored, please remove it to avoid potential confusion
[+] up 3/4
✔ Container plantuml-server Running 0.0s
✔ Container hogehoge-docs Running 0.0s
⠦ Container hogehoge Starting 2.6s
✔ Container hogehoge-mlflow Started 2.6s
Error response from daemon: AMD CDI spec not found
今度は Error response from daemon: AMD CDI spec not found というエラーが発生した。
このような場合に CDI spec 作成作業も行う必要がある。
3-3-2. CDI spec とはそもそも何か
Docker コンテナから GPU にアクセスできるようにするためには、 NVIDIA Container Toolkit がどのように GPU にアクセスすれば良いかを明示しておく必要がある。この、「どのように GPU にアクセスすれば良いか」を示す設定ファイルが CDI spec である。
では、 CDI spec が既に用意されているかどうかを確認しよう。
nvidia-ctk cdi list を実行して、以下のように Nvidia の GPU が認識されていれば良いが、そうではない場合は、 CDI spec を作成する必要がある。
$ nvidia-ctk cdi list
INFO[0000] Found 3 CDI devices
nvidia.com/gpu=0
nvidia.com/gpu=GPU-23082bf6-aa11-879f-3052-9250ccc91b25
nvidia.com/gpu=all
3-3-3. CDI spec を作成する
以下のように作成する。これも Docker コンテナ内ではなく、ホストマシン上で実行するコマンドである。
$ sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml
WARN[0000] Ignoring error in locating libnvidia-sandboxutils.so.1: libnvidia-sandboxutils.so.1: not found
libnvidia-sandboxutils.so.1: not found
WARN[0000] Failed to init nvsandboxutils: ERROR_LIBRARY_LOAD; ignoring
INFO[0000] Using /usr/lib/x86_64-linux-gnu/libnvidia-ml.so.595.91.07
INFO[0000] Auto-detected mode as 'nvml'
INFO[0000] Selecting /dev/nvidia0 as /dev/nvidia0
# ... 省略
WARN[0000] Could not locate nvidia/595.91.07/ucodes*.bin: nvidia/595.91.07/ucodes*.bin: not found
INFO[0000] Selecting /usr/bin/nvidia-smi as /usr/bin/nvidia-smi
INFO[0000] Selecting /usr/bin/nvidia-debugdump as /usr/bin/nvidia-debugdump
INFO[0000] Selecting /usr/bin/nvidia-persistenced as /usr/bin/nvidia-persistenced
INFO[0000] Selecting /usr/bin/nvidia-cuda-mps-control as /usr/bin/nvidia-cuda-mps-control
INFO[0000] Selecting /usr/bin/nvidia-cuda-mps-server as /usr/bin/nvidia-cuda-mps-server
WARN[0000] Could not locate nvidia-imex: nvidia-imex: not found
WARN[0000] Could not locate nvidia-imex-ctl: nvidia-imex-ctl: not found
INFO[0000] Generated CDI spec with version 0.7.0
ここまで実施すると CDI spec が用意され、 docker コンテナからホストマシンの GPU にアクセスできるようになるはずである。
4. 結果確認
結果を確認しよう。
$ docker info | grep -i runtimes
Runtimes: io.containerd.runc.v2 nvidia runc
上記のように nvidia が表示されれば、設定はうまくいっているはず。
次に、コンテナ内からホストマシン上の GPU にアクセスできるかを簡易的にではあるが、実際に確認してみよう。
$ docker run --rm --gpus all ubuntu nvidia-smi
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
d9b985643753: Pull complete
09923199ca0e: Pull complete
aff80cac5bd2: Download complete
Digest: sha256:da6fc2be547864451aa253836dd926da33623312df4a9a243e35dc877c378a78
Status: Downloaded newer image for ubuntu:latest
Fri Oct 2 02:44:25 2026
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 595.91.07 Driver Version: 595.91.07 CUDA Version: 13.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 Tesla T4 Off | 00000000:0B:00.0 Off | 0 |
| N/A 33C P8 14W / 70W | 0MiB / 15360MiB | 0% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| No running processes found |
+-----------------------------------------------------------------------------------------+
上記のように、 nvidia-smi の結果が正常に表示されれば作業完了!(∗˃̶ ᵕ ˂̶∗)