fix: use gpus:all for GPU passthrough, detect Docker Desktop in start.sh
This commit is contained in:
1 parent
7f5fc7fea3
commit
4b33af54ae
3 files changed
+29
-33
No files matched your search
@@ -1,4 +1,3 @@
|
|||||||
services:
|
services:
|
||||||
backend:
|
backend:
|
||||||
devices:
|
gpus: all
|
||||||
- nvidia.com/gpu=all
|
|
||||||
+5
-3
@@ -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
|
- `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
|
mounted read-write (REQ-178), `.env` for `HF_TOKEN`) and a `frontend` service (nginx: static
|
||||||
files + `/api` proxy, `client_max_body_size 20g`).
|
files + `/api` proxy, `client_max_body_size 20g`).
|
||||||
- GPU access uses **CDI** (`devices: nvidia.com/gpu=all`), not the legacy `runtime: nvidia`.
|
- GPU access uses compose **`gpus: all`** (same path as the `docker run --gpus all` CLI flag).
|
||||||
Docker Engine 27+ discovers `nvidia.com/gpu` through the container toolkit; the runtime
|
The earlier CDI form (`devices: nvidia.com/gpu=all`) fails on Docker Desktop's WSL2 backend
|
||||||
entry in `/etc/docker/daemon.json` is not registered with the daemon here.
|
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
|
- 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.
|
that dies with a bus error on this machine; Vite 7's Rollup path works.
|
||||||
@@ -10,42 +10,37 @@ rm -f docker-compose.override.yml
|
|||||||
if command -v nvidia-smi &> /dev/null; then
|
if command -v nvidia-smi &> /dev/null; then
|
||||||
echo "✅ NVIDIA GPU detected."
|
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
|
if ! command -v nvidia-ctk &> /dev/null; then
|
||||||
echo "⚠️ NVIDIA Container Toolkit is missing."
|
if docker info --format '{{.Name}}' 2>/dev/null | grep -q docker-desktop; then
|
||||||
echo " Without it, Docker cannot access your GPU, and the app will run in CPU-only mode."
|
echo "🐳 Docker Desktop detected — GPU support is built in, no toolkit needed."
|
||||||
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
|
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 3. If Toolkit is available, configure CDI and enable GPU passthrough
|
echo "🔌 Enabling GPU support via docker-compose.override.yml..."
|
||||||
if command -v nvidia-ctk &> /dev/null; then
|
cat <<EOF > docker-compose.override.yml
|
||||||
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
|
|
||||||
services:
|
services:
|
||||||
backend:
|
backend:
|
||||||
devices:
|
gpus: all
|
||||||
- nvidia.com/gpu=all
|
|
||||||
EOF
|
EOF
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
echo "ℹ️ No NVIDIA GPU detected. Running in CPU-only mode."
|
echo "ℹ️ No NVIDIA GPU detected. Running in CPU-only mode."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in new issue
Block a user