devcontainers / spec

Development Containers: Use a container as a full-featured development environment.
https://containers.dev
Creative Commons Attribution 4.0 International
3.28k stars 200 forks source link

Optional GPU host requirement does not work with docker compose. #469

Open RaphaelMelanconAtBentley opened 2 months ago

RaphaelMelanconAtBentley commented 2 months ago

When setting "host_requirements": {"gpu": "optional"}, the override adds the capability without the driver and count sections.

[2024-06-12T18:58:55.598Z] Stop (1970 ms): Run: docker build -f /tmp/devcontainercli-rmelancon/updateUID.Dockerfile-0.62.0 -t vsc-booster-ai-8960dda54929ced7aedbc1d531258379f1613874a876c5691c3e0f3082d263f1-uid --platform linux/amd64 --build-arg BASE_IMAGE=booster-ai-devcontainer:latest --build-arg REMOTE_USER=nonRootUser --build-arg NEW_UID=1000 --build-arg NEW_GID=1000 --build-arg IMAGE_USER=root /tmp/devcontainercli-rmelancon/empty-folder
[2024-06-12T18:58:55.599Z] Start: Run: docker info -f {{.Runtimes.nvidia}}
[2024-06-12T18:58:55.691Z] Stop (92 ms): Run: docker info -f {{.Runtimes.nvidia}}
[2024-06-12T18:58:55.692Z] Docker Compose override file for creating container:
services:
  'devcontainer':
    image: vsc-booster-ai-8960dda54929ced7aedbc1d531258379f1613874a876c5691c3e0f3082d263f1-uid
    entrypoint: ["/bin/sh", "-c", "echo Container started\n
trap \"exit 0\" 15\n
/usr/local/share/docker-init.sh\n
exec \"$$@\"\n
while sleep 1 & wait $$!; do :; done", "-"]
    environment:
      - IS_INSIDE_DEVCONTAINER=true
    labels:
      - 'devcontainer.local_folder=\\wsl.localhost\Ubuntu-22.04\home\rmelancon\repositories\Booster-AI'
      - 'devcontainer.config_file=/home/rmelancon/repositories/Booster-AI/.devcontainer/devcontainer.json'
    volumes:
      - /var/run/docker.sock:/var/run/docker-host.sock
      - profile:/root
      - /root/.vscode-server
      - vscode:/vscode
    deploy:
      resources:
        reservations:
          devices:
            - capabilities: [gpu]
volumes:

  profile:

  vscode:
    external: true

This results in the gpu not being available in the container.

zuriel5zurielg20 commented 2 months ago

Alistair Thomson

El mié., 12 jun. 2024 13:34, RaphaelMelanconAtBentley < @.***> escribió:

When setting "host_requirements": {"gpu": "optional"}, the override adds the capability without the driver and count sections.

[2024-06-12T18:58:55.598Z] Stop (1970 ms): Run: docker build -f /tmp/devcontainercli-rmelancon/updateUID.Dockerfile-0.62.0 -t vsc-booster-ai-8960dda54929ced7aedbc1d531258379f1613874a876c5691c3e0f3082d263f1-uid --platform linux/amd64 --build-arg BASE_IMAGE=booster-ai-devcontainer:latest --build-arg REMOTE_USER=nonRootUser --build-arg NEW_UID=1000 --build-arg NEW_GID=1000 --build-arg IMAGE_USER=root /tmp/devcontainercli-rmelancon/empty-folder [2024-06-12T18:58:55.599Z] Start: Run: docker info -f {{.Runtimes.nvidia}} [2024-06-12T18:58:55.691Z] Stop (92 ms): Run: docker info -f {{.Runtimes.nvidia}} [2024-06-12T18:58:55.692Z] Docker Compose override file for creating container: services: 'devcontainer': image: vsc-booster-ai-8960dda54929ced7aedbc1d531258379f1613874a876c5691c3e0f3082d263f1-uid entrypoint: ["/bin/sh", "-c", "echo Container started\ntrap \"exit 0\" 15\n/usr/local/share/docker-init.sh\nexec \"$$@\"\nwhile sleep 1 & wait $$!; do :; done", "-"] environment:

  • IS_INSIDE_DEVCONTAINER=true labels:
  • 'devcontainer.local_folder=\wsl.localhost\Ubuntu-22.04\home\rmelancon\repositories\Booster-AI'
  • 'devcontainer.config_file=/home/rmelancon/repositories/Booster-AI/.devcontainer/devcontainer.json' volumes:
  • /var/run/docker.sock:/var/run/docker-host.sock
  • profile:/root
  • /root/.vscode-server
  • vscode:/vscode deploy: resources: reservations: devices:

    • capabilities: [gpu] volumes:

    profile:

    vscode: external: true

This results in the gpu not being available in the container.

— Reply to this email directly, view it on GitHub https://github.com/devcontainers/spec/issues/469, or unsubscribe https://github.com/notifications/unsubscribe-auth/BGCT5DPIFFXUTZN4EIEJ4MTZHCPCPAVCNFSM6AAAAABJG7T2L2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGM2DSNJUGEZTCMY . You are receiving this because you are subscribed to this thread.Message ID: @.***>