fix: use gpus:all for GPU passthrough, detect Docker Desktop in start.sh

This commit is contained in:
Andrew-AAAA committed 2026-09-29 11:49:54 +07:00
1 parent 7f5fc7fea3
commit 4b33af54ae
3 files changed
+29 -33

No files matched your search

+1 -2
View File
@@ -1,4 +1,3 @@
services:
backend:
devices:
- nvidia.com/gpu=all
gpus: all
+5 -3
View File
@@ -405,8 +405,10 @@ would wipe the class and leave only the drawings.
- `docker-compose.yml` — a `backend` service (GPU passthrough, `./data` volume, video archive
mounted read-write (REQ-178), `.env` for `HF_TOKEN`) and a `frontend` service (nginx: static
files + `/api` proxy, `client_max_body_size 20g`).
- GPU access uses **CDI** (`devices: nvidia.com/gpu=all`), not the legacy `runtime: nvidia`.
Docker Engine 27+ discovers `nvidia.com/gpu` through the container toolkit; the runtime
entry in `/etc/docker/daemon.json` is not registered with the daemon here.
- GPU access uses compose **`gpus: all`** (same path as the `docker run --gpus all` CLI flag).
The earlier CDI form (`devices: nvidia.com/gpu=all`) fails on Docker Desktop's WSL2 backend
with `unresolvable CDI devices` because no CDI spec exists there; `gpus: all` works on both
Docker Desktop and a native engine with the NVIDIA container toolkit.
The runtime entry in `/etc/docker/daemon.json` is not registered with the daemon here.
- The frontend pins **Vite 7**. Vite 8's default bundler (Rolldown) ships a native binding
that dies with a bus error on this machine; Vite 7's Rollup path works.
+23 -28
View File
@@ -10,42 +10,37 @@ rm -f docker-compose.override.yml
if command -v nvidia-smi &> /dev/null; then
echo "✅ NVIDIA GPU detected."
# 2. Check if the NVIDIA Container Toolkit is installed
# 2. Docker Desktop ships its own GPU support; a native engine needs the NVIDIA Container Toolkit
if ! command -v nvidia-ctk &> /dev/null; then
echo "⚠️ NVIDIA Container Toolkit is missing."
echo " Without it, Docker cannot access your GPU, and the app will run in CPU-only mode."
read -p "Would you like to install it automatically now? (requires sudo) [y/N] " install_choice
if [[ "$install_choice" =~ ^[Yy]$ ]]; then
echo "Installing NVIDIA Toolkit..."
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor --yes -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
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
echo "✅ NVIDIA Toolkit installed successfully!"
if docker info --format '{{.Name}}' 2>/dev/null | grep -q docker-desktop; then
echo "🐳 Docker Desktop detected — GPU support is built in, no toolkit needed."
else
echo "⚠️ Skipping installation. Proceeding without GPU support."
echo "⚠️ NVIDIA Container Toolkit is missing."
echo " Without it, Docker cannot access your GPU, and the app will run in CPU-only mode."
read -p "Would you like to install it automatically now? (requires sudo) [y/N] " install_choice
if [[ "$install_choice" =~ ^[Yy]$ ]]; then
echo "Installing NVIDIA Toolkit..."
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor --yes -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
sudo apt-get update
sudo apt-get install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker
echo "✅ NVIDIA Toolkit installed successfully!"
else
echo "⚠️ Skipping installation. Proceeding without GPU support."
fi
fi
fi
# 3. If Toolkit is available, configure CDI and enable GPU passthrough
if command -v nvidia-ctk &> /dev/null; then
if [ ! -f "/etc/cdi/nvidia.yaml" ]; then
echo "⚙️ Generating Docker CDI configuration..."
sudo nvidia-ctk cdi generate --output=/etc/cdi/nvidia.yaml
fi
echo "🔌 Enabling GPU support via docker-compose.override.yml..."
cat <<EOF > docker-compose.override.yml
echo "🔌 Enabling GPU support via docker-compose.override.yml..."
cat <<EOF > docker-compose.override.yml
services:
backend:
devices:
- nvidia.com/gpu=all
gpus: all
EOF
fi
else
echo "ℹ️ No NVIDIA GPU detected. Running in CPU-only mode."
fi