blakeblackshear / frigate

NVR with realtime local object detection for IP cameras
https://frigate.video
MIT License
18.46k stars 1.68k forks source link

[HW Accel Support]: Multi GPU Support - Setup Container on Unraid to use the right GPU #9212

Closed cm86 closed 9 months ago

cm86 commented 9 months ago

Describe the problem you are having

i would like to configure my container on my unraid system so that it only uses the second gpu. unfortunately, it always accesses the first gpu. of course, i have specified the id of the second gpu as "NVIDIA_VISIBLE_DEVICES". however, both gpus are always visible in the system page

Here you can see the screenshots of the config parameters... Bildschirmfoto 2024-01-04 um 21 04 05 Bildschirmfoto 2024-01-04 um 21 04 49

And here you can see the system-settings page Bildschirmfoto 2024-01-04 um 21 07 26

And here the nvidia-smi output Bildschirmfoto 2024-01-04 um 21 08 22 as you can see here, frigate just uses gpu0, not gpu1...

i have also found the section in the documentation (Docker Compose - Nvidia GPU), but i don't know how to set this correctly in unraid...

maybe someone can help here...

Mit freundlichen Grüßen Chris

Version

0.13.0-C35C7DA

Frigate config file

logger:
  default: info
  logs:
    frigate.event: debug
mqtt:
  host: x.x.x.x
  port: 1883
  user: suer
  password: password
  topic_prefix: frigate
  client_id: frigate
  stats_interval: 60

ffmpeg:
  hwaccel_args: preset-nvidia-h264
  input_args: preset-http-reolink

detectors:
  coral:
    type: edgetpu
    device: usb

birdseye:
  enabled: true
  width: 1792
  height: 1344
  quality: 1
  mode: continuous
objects:
  track:
  - person
  - car
  - bicycle
  - motorcycle

go2rtc:
  streams:
    Front:
    - rtsp://user:password@x.x.x.x/0
    Garten:
    - ffmpeg:http://10.0.4.2/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=user&password=password#video=copy
    Garten_sub:
    - ffmpeg:http://10.0.4.2/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=user&password=password
    Gartenhaus:
    - ffmpeg:http://10.0.4.3/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=user&password=password#video=copy
    Gartenhaus_sub:
    - ffmpeg:http://10.0.4.3/flv?port=1935&app=bcs&stream=channel0_ext.bcs&user=user&password=password

record:
  enabled: true
  expire_interval: 10
  retain:
    days: 7
    mode: motion
  events:
    pre_capture: 10
    post_capture: 10
    retain:
      default: 7
      mode: motion

cameras:
  Front:
    ffmpeg:
      inputs:
      - path: rtsp://127.0.0.1:8554/Front
        input_args: preset-rtsp-restream
        roles:
        - detect
    detect:
      fps: 5
    motion:
      mask:
      - 0,0,931,0,1867,0,1890,138,1664,165,1349,296,993,477,671,634,391,808,0,1068
    record:
      events:
        required_zones:
        - VorgartenStr
    snapshots:
      required_zones:
      - VorgartenStr
    zones:
      VorgartenStr:
        coordinates: 
          0,1075,612,675,1140,387,1371,289,1661,168,1889,146,1873,0,2560,0,2560,1440,0,1440
    ui:
      order: 0

  Garten:
    ffmpeg:
      inputs:
      - path: rtsp://127.0.0.1:8554/Garten?video=copy
        input_args: preset-rtsp-restream
        roles:
        - record
      - path: rtsp://127.0.0.1:8554/Garten_sub?video=copy
        input_args: preset-rtsp-restream
        roles:
        - detect
    detect:
      fps: 7
    motion:
      mask:
      - 0,0,896,0,896,140,896,155,830,145,837,112,646,19,551,21,383,21,185,21,33,99,32,125,0,111
    ui:
      order: 1
  Gartenhaus:
    ffmpeg:
      - path: rtsp://127.0.0.1:8554/Gartenhaus
        input_args: preset-rtsp-restream
        roles:
        - record
      - path: rtsp://127.0.0.1:8554/Gartenhaus_sub?video=copy
        input_args: preset-rtsp-restream
        roles:
        - detect
    detect:
      fps: 7
    motion:
      mask:
      - 896,0,896,253,692,213,701,169,700,130,705,106,506,10,260,21,168,54,141,86,0,84,0,0
    ui:
      order: 2

docker-compose file or Docker CLI command

docker run
  -d
  --name='frigate'
  --net='bond0'
  --ip='10.0.100.12'
  --privileged=true
  -e TZ="Europe/Berlin"
  -e HOST_OS="Unraid"
  -e HOST_HOSTNAME="UnraidServer"
  -e HOST_CONTAINERNAME="frigate"
  -e 'TCP_PORT_5000'='5000'
  -e 'TCP_PORT_8554'='8554'
  -e 'FRIGATE_RTSP_PASSWORD'='password'
  -e 'PLUS_API_KEY'='18d49093-cc82-4e0e-b9ef-6ea8e676fda3:9bcdd79f62f9494bee3d988678f76ad4049c697d'
  -e 'TCP_PORT_8555'='8555'
  -e 'UDP_PORT_8555'='8555'
  -e 'TCP_PORT_1984'='1984'
  -e 'NVIDIA_VISIBLE_DEVICES'='GPU-ccefd14b-740b-bebe-78e1-af586954fd66'
  -e 'NVIDIA_DRIVER_CAPABILITIES'='compute,utility,video'
  -l net.unraid.docker.managed=dockerman
  -l net.unraid.docker.webui='http://[IP]:[PORT:5000]'
  -l net.unraid.docker.icon='https://raw.githubusercontent.com/yayitazale/unraid-templates/main/frigate.png'
  -v '/mnt/user/appdata/frigate':'/config':'rw'
  -v '/mnt/user/frigate/media/':'/media/frigate':'rw'
  -v '/etc/localtime':'/etc/localtime':'rw'
  --device='/dev/usb/'
  --shm-size=5G
  --mount type=tmpfs,target=/tmp/cache,tmpfs-size=100000000
  --restart unless-stopped
  --runtime=nvidia 'ghcr.io/blakeblackshear/frigate:0.13.0-beta7'

Relevant log output

i think it's not needed.

FFprobe output from your camera

also not needed i think.

Operating system

UNRAID

Install method

Docker CLI

Network connection

Wired

Camera make and model

Reolink

Any other information that may be helpful

No response

NickM-27 commented 9 months ago

you need to remove --runtime nvidia and instead use --gpus=GPU_ID

cm86 commented 9 months ago

so i tried your parameters but i had no luck... removed --runtime nvidia and used --gpus device=GPU-ccefd14b-740b-bebe-78e1-af586954fd66

NickM-27 commented 9 months ago

I'd try

--gpus '"device=0"'

Also you probably can't run as privileged as that usually gives access to all gpus

cm86 commented 9 months ago

That was the hint i needed... :)

i remove the privileged flag and then it worked with the standard config i have done before...

Thanks

cm86 commented 9 months ago

closed