microsoft / vscode-remote-release

Visual Studio Code Remote Development: Open any folder in WSL, in a Docker container, or on a remote machine using SSH and take advantage of VS Code's full feature set.
https://aka.ms/vscode-remote
Other
3.69k stars 297 forks source link

hostRequirements: gpu: missing driver option #10124

Open lpasselin opened 4 months ago

lpasselin commented 4 months ago

Same as this issue which is for windows: https://github.com/microsoft/vscode-remote-release/issues/9385

docker info -f '{{.Runtimes.nvidia}}' --> returns nvidia-container-runtime

Temporary fix is to add this to our docker-compose.yml but it breaks for users without gpu

    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

When reverting to using a dockerfile instead of docker-compose, "runArgs": [ "--gpus", "all" ] does work

RaphaelMelanconAtBentley commented 3 months ago

Having the same issue, and it's a pain for my team, as we have multiple people working with Macbooks... Really hoping for this to be fixed.

RaphaelMelanconAtBentley commented 3 months ago

For docker compose, I have a hacky fix:

I simply use this script I created and extend my docker-compose.yml's devcontainer service with the file created:

#!/bin/bash

target_file="environments/devcontainer/gpu_optional.docker-compose.yml"
snippets_path="environments/devcontainer/build_utils/snippets"
if ! nvidia-smi >/dev/null; then
    cp "${snippets_path}/without_gpu.docker-compose.yml" "${target_file}"
else
    cp "${snippets_path}/with_gpu.docker-compose.yml" "${target_file}"
fi

where ${snippets_path}/without_gpu.docker-compose.yml contains:

services:
  devcontainer:
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

and ${snippets_path}/with_gpu.docker-compose.yml contains:

services:
  devcontainer:

Hope this helps!

chrmarti commented 3 months ago

docker info -f '{{.Runtimes.nvidia}}' --> returns nvidia-container-runtime

@lpasselin This case should work. Please append the Dev Containers log from when you rebuild the container. (F1 > Dev Containers: Show Container Log)

PanTheDev commented 3 months ago

@chrmarti in my case, what I found what that although the runtime is nvidia-container-runtime, the docker compose config used has a deploy section that looks like this:

services:
  devcontainer-service:
    deploy:
      resources:
        reservations:
          devices:
            - capabilities: [gpu]
              count: all

The driver: nvidia part is missing...

chrmarti commented 2 months ago

Could you share the output from docker info --format '{{json .}}'?