『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 1025|回复: 7

[经验分享] 使用N卡加速frigate对象识别

[复制链接]

19

主题

114

帖子

907

积分

论坛UI达人

积分
907
金钱
793
HASS币
10
发表于 2024-11-11 15:52:00 | 显示全部楼层 |阅读模式
白嫖了一张quadro T600,满载40W功耗,尝试放进nas里看看能做什么
之前发的一篇用核显跑frigate识别加速的一个在pve lxc中跑frigate+核显加速的详细指南 - 『HomeAssistant』综合讨论区 - 『瀚思彼岸』» 智能家居技术论坛 - Powered by Discuz!
这次换成N卡跑cuda看看效果
这次平台是物理黑群晖,使用矿神源的N卡驱动,版本535,cuda12.2,注意frigate要求的nvidia gpu计算能力版本要>5,型号大概就是9系之后,具体型号支持可以查询CUDA GPUs - Compute Capability | NVIDIA Developer,我这张T600是20系的图灵架构,计算能力版本7.5,符合条件
微信截图_20241111152915.png
4路 2K 25fps录制+4路 720P 6fps识别,显存占用500M左右,使用的是cc150 cpu 8c16t,占用基本可以忽略,GPU触发检测时大概占用10~20%,日常功耗多个十来瓦
检测延迟20ms出头,比核显高一些,貌似跑的模型不同,核显跑只识别到过人和车,相同配置n卡跑可以跑出来猫狗
(n卡跑转码也给力,jellyfin里同一部4K H265 10bit的片,加上HDR转换,核显转半天转不出来画面。换NVENC转码速度可以去到100多帧)
微信截图_20241111153131.png

docker-compose部署参考:
version: "3.9"
services:
  frigate:
    container_name: frigate
    privileged: true # this may not be necessary for all setups
    restart: unless-stopped
    image: ghcr.io/blakeblackshear/frigate:stable-tensorrt
    deploy:    # <------------- Add this section
      resources:
        reservations:
          devices:
            - driver: nvidia
             # device_ids: ['0'] # this is only needed when using multiple GPUs
              #count: 1 # number of GPUs
              capabilities: [gpu]
    shm_size: "128mb" # update for your cameras based on calculation above
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /volume1/docker/frigate/config:/config
      - /volume4/NVR/frigate:/media/frigate
      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - "8971:8971"
      - "5555:5000" # Internal unauthenticated access. Expose carefully.
      - "8554:8554" # RTSP feeds
      - "8555:8555/tcp" # WebRTC over tcp
      - "8555:8555/udp" # WebRTC over udp
    environment:
      - NVIDIA_VISIBLE_DEVICES=all # 映射NVIDIA显卡
      - NVIDIA_DRIVER_CAPABILITIES=all # 映射NVIDIA显卡
      - FRIGATE_RTSP_PASSWORD=password


frigate内检测器的相关配置:
其他配置可参考核显那篇,第一次启动需要构建模型,等待十来分钟的样子
detectors:
  tensorrt:
    type: tensorrt
    device: 0 #This is the default, select the first GPU
detect:
  width: 1280
  height: 720
  fps: 6
  enabled: true
model:
  path: /config/model_cache/tensorrt/yolov7-320.trt
  input_tensor: nchw
  input_pixel_format: rgb
  width: 320
  height: 320


评分

参与人数 1金钱 +10 收起 理由
flyice + 10 感谢楼主分享!

查看全部评分

回复

使用道具 举报

3

主题

49

帖子

1143

积分

金牌会员

Rank: 6Rank: 6

积分
1143
金钱
1094
HASS币
0
发表于 2024-11-13 01:56:01 | 显示全部楼层
请问一下这个配置好了为什么检测不到人呢?  是不是我配置有什么问题mqtt:
  host: 192.168.31.1
  port: 1883
  user: !!!!
  password: !!!
detectors:
  tensorrt:
    type: tensorrt
    device: 0 #This is the default, select the first GPU
detect:
  width: 704
  height: 576
  fps: 5
  enabled: true
model:
  path: /config/model_cache/tensorrt/yolov7-320.trt
  input_tensor: nchw
  input_pixel_format: rgb
  width: 320
  height: 32

objects:
  track:
    - person
    - bicycle
    - car
    - motorcycle
    - cat
    - dog
    - tree

record:
  enabled: True
  retain:
    days: 3
    mode: motion
  events:
    retain:
      default: 30
      mode: motion
snapshots:
  enabled: true
  retain:
    default: 30

cameras:
  keting: # <--- this will be changed to your actual camera later
    enabled: true
    ffmpeg:
      inputs:
        - path: rtsp://
          roles:
            - detect
  woshi:
    ffmpeg:
      inputs:
        - path: rtsp:
          roles:
            - detect #
  chezhan:
    ffmpeg:
      inputs:
        - path: rtsp:/
          roles:
            - detect #


auth:
  # Optional: Enable authentication
  enabled: false

version: 0.14
回复

使用道具 举报

19

主题

114

帖子

907

积分

论坛UI达人

积分
907
金钱
793
HASS币
10
 楼主| 发表于 2024-11-13 11:36:58 | 显示全部楼层
tinatiao 发表于 2024-11-13 01:56
请问一下这个配置好了为什么检测不到人呢?  是不是我配置有什么问题mqtt:
  host: 192.168.31.1
  port: 1 ...

没配置检测区域吗
回复

使用道具 举报

3

主题

49

帖子

1143

积分

金牌会员

Rank: 6Rank: 6

积分
1143
金钱
1094
HASS币
0
发表于 2024-11-13 13:54:13 | 显示全部楼层
看这个debug里面也检测不到人,我之前用核显的时候除了检测器配置,其他的也是一样设置的,可以检测到人。
1731477074989.jpg
回复

使用道具 举报

10

主题

224

帖子

1939

积分

金牌会员

Rank: 6Rank: 6

积分
1939
金钱
1715
HASS币
0
发表于 2024-12-1 23:26:52 | 显示全部楼层
您好,我跟你几乎一样的配置,但是Frigate部署完卡住启动不起来,显示 go2rtc healthy checking。在外网搜到好像是Frigate要下载模型,我没有梯子,所以不行。劳烦您可以把自动下好的模型分享一下吗,不知道是不是必须本机构建的。谢谢!
回复

使用道具 举报

19

主题

114

帖子

907

积分

论坛UI达人

积分
907
金钱
793
HASS币
10
 楼主| 发表于 2024-12-2 11:07:45 | 显示全部楼层
yangrusen 发表于 2024-12-1 23:26
您好,我跟你几乎一样的配置,但是Frigate部署完卡住启动不起来,显示 go2rtc healthy checking。在外网搜 ...

官方文档提到是需要本机构建,但是试下无妨
https://wwwq.lanzouj.com/iebJ12gws3tg
存放路径是/config/model_cache/tensorrt/8.5.3/yolov7-320.trt
回复

使用道具 举报

10

主题

224

帖子

1939

积分

金牌会员

Rank: 6Rank: 6

积分
1939
金钱
1715
HASS币
0
发表于 2024-12-2 18:37:21 | 显示全部楼层
非常感谢。我试了下确实不行,应该是需要自己的显卡来构建,因为错误日志里提到模型是计算能力7.5的显卡生成的,我的数据是6.1。正好对应了你的T600和我的P620显卡。
回复

使用道具 举报

10

主题

224

帖子

1939

积分

金牌会员

Rank: 6Rank: 6

积分
1939
金钱
1715
HASS币
0
发表于 2024-12-26 12:16:21 | 显示全部楼层
从 Github discussion里得到的指点,不使用 Yolov7_320的模型的话,也可以下载Yolonas的模型。我因为NAS连不上外网,就部署了Yolonas,但必须是 15.0 beta的版本才可以。

话说感觉这个模型还不如我13.1版本里的Openvino识别的效果和准确度高,有点失望了,以为用显卡跑模型要比核显强呢。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2025-3-6 23:57 , Processed in 0.059285 second(s), 33 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表