Docker compose GPU device selection as no effect

Hi all.
I recently added an Nvidia GP100 to my machine that already as an RTX A4000. My docker apps continue to see only my RTX A4000. I’ve verified that both GPUs are available and can be benchmarked separately using various tools.

I’m struggling to make docker-compose select 1 of 2 gpus in my Windows11 Docker Desktop Setup.

In short, switching device_ids=[‘0’] or device_ids=[‘1’] as no effect in the code below.

version: "3.9"

volumes:
  nas_frigate_media:
    external: true

services:
  frigate:
    container_name: frigate
    privileged: true # this may not be necessary for all setups
    restart: unless-stopped
    # image: ghcr.io/blakeblackshear/frigate:stable
    image: ghcr.io/blakeblackshear/frigate:stable-tensorrt
    shm_size: "512mb" # increased from 320mb to help stability

    deploy:   
      resources:
        reservations:
          devices:
            - driver: nvidia
              device_ids: ['0'] 
              # device 0 uuid = GPU-c5fd0137-8838-ee8e-2d16-e75c8e0d5f20 
              capabilities: [gpu]

    volumes:
      - \\wsl.localhost\Ubuntu\etc\localtime:/etc/localtime:ro
      - .\config:/config
      - .\frigate:/db
      - nas_frigate_media:/media/frigate

      - type: tmpfs # Optional: allocation of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    
    ports:
      - "5000:5000"
      - "8554:8554" # RTSP feeds
      - "8555:8555/tcp" # WebRTC over tcp
      - "8555:8555/udp" # WebRTC over udp

    environment:
      - TRT_MODEL_PREP_DEVICE=1 # Optionally, select which GPU is used for  model optimization
      - CUDA_MODULE_LOADING=LAZY
      - NVIDIA_VISIBLE_DEVICES=all
      - NVIDIA_DRIVER_CAPABILITIES=all

For testing, I ran docker run that DOES utilize the GP100, but I want to keep docker-compose for a host of network, volume, and configuration reasons.

docker run -d --name=frigate --privileged --restart=unless-stopped ^
  --shm-size="512mb" ^
  --gpus device=GPU-c5fd0137-8838-ee8e-2d16-e75c8e0d5f20 ^
  -v /etc/localtime:/etc/localtime:ro ^
  -v ./config:/config ^
  -v ./frigate:/db ^
  -v nas_frigate_media:/media/frigate ^
  --mount type=tmpfs,destination=/tmp/cache,tmpfs-size=1000000000 ^
  -p 5000:5000 ^
  -p 8554:8554 ^
  -p 8555:8555/tcp ^
  -p 8555:8555/udp ^
  -e TRT_MODEL_PREP_DEVICE=1 ^
  -e CUDA_MODULE_LOADING=LAZY ^
  -e NVIDIA_VISIBLE_DEVICES=all ^
  -e NVIDIA_DRIVER_CAPABILITIES=all ^
  ghcr.io/blakeblackshear/frigate:stable-tensorrt

Any pointers on want is going on and how I can troubleshoot this. Multiple dead-end days has me stumped.

I never used GPU on Docker Desktop for Windows, but one question that comes to my mind is which backend are you using? WSL2 or HyperV? GPU support works only with the WSL2 backend

I’m using WSL2. I’m not having any luck getting new images to use my GP0. Sad because I bought it because my other GPU is getting over taxed.

Did you manage to solve this issue? We are facing the same problem with 2 GPUs on WSL2 :slight_smile:

Also facing the same issue with DD and WSL2 backend. Selecting individual GPU devices does not work and all available GPUs are being made available to the container. Did anyone manage to get this working so far?