Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nvidia Jetson ffmpeg + TensorRT support #6458

Merged
merged 9 commits into from
Jul 26, 2023

Conversation

madsciencetist
Copy link
Contributor

@madsciencetist madsciencetist commented May 10, 2023

This PR creates a new make jetson target and a new frigate-jetson docker image, which is based on Ubuntu 20.04 with L4T (the supported OS for Jetsons) rather than on Debian 11. This enables a rather seamless replacement of the rpi-accelerated ffmpeg with a jetson-accelerated version, and enables the use of the tensorrt detector, utilizing the Jetson's GPU or DLA. Note that Ubuntu 20.04 defaults to python3.8, so I forced it to upgrade to python3.9.

This is a smaller change than #2548 in that it still uses ffmpeg, rather than adding and using gstreamer.

The accelerated decoding and scaling cuts ffmpeg's CPU use 80-90% and saves >1W of power per stream. Switching from the default mobilenet CPU detector to yolov7-tiny-416 on the GPU saves another watt, and running the same on the DLA saves yet another half watt more.

Tested on a Jetson Xavier NX running Jetpack 5.0.2 (L4T 35.1) and Jetson Xavier AGX running Jetpack 4.6.1 (L4T 32.6.1). Theoretically works on most other Jetson platforms and versions.

@netlify
Copy link

netlify bot commented May 10, 2023

Deploy Preview for frigate-docs ready!

Name Link
🔨 Latest commit c57f640
🔍 Latest deploy log https://app.netlify.com/sites/frigate-docs/deploys/64bfdb70e3b7a7000805fc49
😎 Deploy Preview https://deploy-preview-6458--frigate-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

docs/docs/configuration/ffmpeg_presets.md Outdated Show resolved Hide resolved
docs/docs/configuration/hardware_acceleration.md Outdated Show resolved Hide resolved
frigate/app.py Outdated Show resolved Hide resolved
docs/docs/configuration/hardware_acceleration.md Outdated Show resolved Hide resolved
@blakeblackshear
Copy link
Owner

I'm still planning the right approach for adding "Community supported" boards in this repo. I think our approach will be to have official support for any boards that represent >1% of the docker pulls. Anything below that will be assigned a code owner similar to how home assistant has approached integration maintenance in core. With that, it will be important to create cleaner lines between official and community supported builds. We won't merge this until that is established.

@madsciencetist
Copy link
Contributor Author

Well...that's frustrating. Do you want me to close this PR or leave it open?

@blakeblackshear
Copy link
Owner

Leave it open. Almost all of this is fine. I just don't want to sign up to make sure it continues to work unless a significant portion of the user base runs a Jetson device. I just need to move a few things around.

@madsciencetist madsciencetist changed the title Add hwaccel support for Jetson platforms Nvidia Jetson ffmpeg + TensorRT support May 13, 2023
@madsciencetist

This comment was marked as resolved.

@blakeblackshear
Copy link
Owner

Nice. I think the way you have implemented this will fit nicely within how I have been thinking about community supported images. This may actually be clean enough to merge and then convert later. I do have a Jetson Xavier device to test with.

@madsciencetist

This comment was marked as resolved.

@bogdanr
Copy link

bogdanr commented May 21, 2023

Looking forward to having an image which I can pull from the repo :)

@bdherouville
Copy link

Hi, I have a Jetson Orin nano running HA + Frigate and I'm interested to test, especially with ffmpeg acceleration. Google coral M.2 works well but I can test other detectors if needed.

@madsciencetist

This comment was marked as outdated.

@damsma
Copy link

damsma commented Jun 4, 2023

@madsciencetist how to create a docker container from the source?

trying on Jetson Nano 2GB, already converted the models
which only supports CUDA 10.2 - will it work?

@madsciencetist

This comment was marked as outdated.

@bdherouville
Copy link

The build for my Orin Nano ends with this message. Not sure why.

+ apt-get -qq update
W: GPG error: https://packages.cloud.google.com/apt coral-edgetpu-stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B53DC80D13EDEF05
E: The repository 'https://packages.cloud.google.com/apt coral-edgetpu-stable InRelease' is not signed.
Error: building at STEP "RUN --mount=type=bind,source=docker/install_deps.sh,target=/deps/install_deps.sh /deps/install_deps.sh": while running runtime: exit status 100
make: *** [Makefile:28: jetson] Error 100

@NickM-27
Copy link
Sponsor Collaborator

NickM-27 commented Jun 4, 2023

This branch needs to be rebased on the latest dev

@damsma
Copy link

damsma commented Jun 5, 2023

Can confirm @bdherouville
@madsciencetist what is the best solution? Can you do the rebase, i would then fork and make my changes.
After that i would pull it to your fork?

the latest dev brings no error, also tested.

@NickM-27
Copy link
Sponsor Collaborator

NickM-27 commented Jun 5, 2023

it has already been rebased

@damsma
Copy link

damsma commented Jun 5, 2023

Ok, i just realized, that the changes are in the jetson_support branch

@bdherouville so had to clone it this way
git clone --branch jetson_support https://github.com/madsciencetist/frigate.git

@madsciencetist

This comment was marked as resolved.

@damsma
Copy link

damsma commented Jun 5, 2023

@madsciencetist that is amazing, i have also been trying around, stuck on add-apt-repository, needed for python 3.9, but i see you did it manually, will try that.
i wonder why you used nvcr.io/nvidia/l4t-tensorrt:r8.0.1-runtime instead of nvcr.io/nvidia/l4t-tensorrt:r8.2.1-runtime - that is the one for Cuda 10.2.

Edit: ok, i am on JetPack SDK 4.6.3

@bdherouville
Copy link

bdherouville commented Jun 6, 2023

Hi,

built and imported on my nano using following commnd. Did I missed something ?

docker compose up

docker import frigate-jetson.tar --change 'ENTRYPOINT ["/init"]'

[+] Running 1/0
 ✔ Container frigate  Created                                                                                                                                                                                   0.0s 
Attaching to frigate
Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error running hook #1: error running hook: exit status 1, stdout: , stderr: time="2023-06-06T09:04:56+02:00" level=error msg="failed to update ld.so.conf: failed to create config file: open /var/lib/docker/overlay2/d99e9045a3174f3e685482daff9c40ef1e027c2288493aa945fe8c07ecf7f7c6/merged/etc/ld.so.conf.d/nvcr-1579528121.conf: no such file or directory": unknown

docker-compose.yaml

version: "3.9"
services:
  frigate:
    container_name: frigate
    privileged: false # this may not be necessary for all setups
    restart: unless-stopped
    image: frigate:jetson
    shm_size: "1024mb" # update for your cameras based on calculation above
    devices:
      - /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions
      - /dev/apex_0:/dev/apex_0 # passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux
#      - /dev/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /usr/share/hassio/homeassistant/frigate_jetson.yml:/config/config.yml
      - /usr/share/hassio/media/frigate:/media/frigate
      - /usr/share/hassio/homeassistant/trt-models:/trt-models
      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 500000000
    ports:
      - "5000:5000"
      - "18554:8554" # RTSP feeds
      - "18555:8555/tcp" # WebRTC over tcp
      - "18555:8555/udp" # WebRTC over udp
    environment:
      FRIGATE_RTSP_PASSWORD: "xxx"
      NVIDIA_VISIBLE_DEVICES: all
      NVIDIA_DRIVER_CAPABILITIES: compute,video,utility

@madsciencetist
Copy link
Contributor Author

@bdherouville make sure you've installed and are using the nvidia container runtime. You'll need to sudo apt install nvidia-container-toolkit on your Jetson host and add runtime: nvidia to your frigate: service in docker-compose.yaml (or add --runtime=nvidia to a docker run command). It's similar to the desktop GPU instructions but replaces the --gpus=all flag.

@bdherouville
Copy link

Thanks, @madsciencetist we are progressing.

Now I have this :

frigate  | 2023-06-06 16:12:13.234109890  [INFO] Starting NGINX...
frigate  | Traceback (most recent call last):
frigate  |   File "/usr/local/go2rtc/create_config.py", line 11, in <module>
frigate  |     from frigate.ffmpeg_presets import (  # noqa: E402
frigate  |   File "/opt/frigate/frigate/ffmpeg_presets.py", line 9, in <module>
frigate  |     from frigate.version import VERSION
frigate  | ModuleNotFoundError: No module named 'frigate.version'
frigate  | 2023-06-06 16:12:13.598623322  [INFO] The go2rtc service exited with code 1 (by signal 0)
frigate  | 2023-06-06 16:12:14.606876385  [INFO] Preparing go2rtc config...
frigate  | Traceback (most recent call last):
frigate  |   File "/usr/local/go2rtc/create_config.py", line 11, in <module>
frigate  |     from frigate.ffmpeg_presets import (  # noqa: E402
frigate  |   File "/opt/frigate/frigate/ffmpeg_presets.py", line 9, in <module>
frigate  |     from frigate.version import VERSION
frigate  | ModuleNotFoundError: No module named 'frigate.version'
frigate  | 2023-06-06 16:12:14.970496382  [INFO] The go2rtc service exited with code 1 (by signal 0)
frigate  | 2023-06-06 16:12:15.190789423  Traceback (most recent call last):

@NickM-27
Copy link
Sponsor Collaborator

NickM-27 commented Jun 6, 2023

You need to run make version before running make jetson

@gjtjx
Copy link

gjtjx commented Aug 8, 2023

@madsciencetist
jetpack5.0.2 run docker no error,it's ok .thank you very much!

@madsciencetist
Copy link
Contributor Author

@gjtjx what platform do you have? Was it a stock nvidia 4.6.4 image or something custom? If there is a bug with stock 4.6.4 jetpack on platforms that require it, that would be good to know

@gjtjx
Copy link

gjtjx commented Aug 8, 2023

@madsciencetist Jetson Xavier NX, the nvidia 4.6.4 image is official release

@kerryland
Copy link

I'm attempting to install and run on my 2gb Nano (jetpack 4.6.1) by following the preview instructions, supplemented by studying this thread. I'm nearly there, but something's not quite right. I can access the website at :5000 (renamed to 5080 in my config), and I can view the camera, but...

  • the view does not update unless I refresh the page
  • Birdseye and 'Events' pages don't show anything

Here's the docker command I'm using:

sudo docker run --runtime=nvidia \
        --rm -it \
        --name frigate \
        --mount type=tmpfs,target=/tmp/cache,tmpfs-size=1000000000 \
        --device /dev/bus/usb:/dev/bus/usb \
        --shm-size=64m \
        -v /opt/frigate/media:/media/frigate \
        -v /etc/frigate/config/config.yml:/config/config.yml \
        -v /etc/frigate/config:/config \
        -v /etc/localtime:/etc/localtime:ro \
        -e FRIGATE_RTSP_PASSWORD='password' \
        -p 5000:5000 \
        -p 8554:8554 \
        -p 8555:8555/tcp \
        -p 8555:8555/udp \
        ghcr.io/blakeblackshear/frigate:dev-f8c0f74-tensorrt-jp4

and my configuration file:

mqtt:
  host: 192.168.1.25

cameras:
  driveway:
    ffmpeg:
      hwaccel_args: preset-jetson-h264
      inputs:
        - path: rtsp://<mild-redaction>:554/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif
          roles:
            - detect

detectors:
  tensorrt:
    type: tensorrt
    model:
      path: /config/model_cache/tensorrt/yolov7-320.trt

model:
  input_tensor: nchw
  width: 640
  height: 480

objects:
  track:
    - person
    - car

Frigate log contains one warning, which I don't understand, and think is irrelevant.
frigate.config WARNING : Customizing more than a detector model path is unsupported.

Full frigate log:

2023-08-09 15:22:29.380690522  [INFO] Preparing Frigate...
2023-08-09 15:22:29.569773570  [INFO] Starting Frigate...
2023-08-09 15:22:39.852598789  [2023-08-09 15:22:39] frigate.app                    INFO    : Starting Frigate (0.13.0-f8c0f74)
2023-08-09 15:22:41.488142334  [2023-08-09 15:22:41] frigate.config                 WARNING : Customizing more than a detector model path is unsupported.
2023-08-09 15:22:42.593750372  [2023-08-09 15:22:42] peewee_migrate.logs            INFO    : Starting migrations
2023-08-09 15:22:42.812849689  [2023-08-09 15:22:42] peewee_migrate.logs            INFO    : There is nothing to migrate
2023-08-09 15:22:42.836646012  [2023-08-09 15:22:42] frigate.app                    INFO    : Recording process started: 316
2023-08-09 15:22:42.845297530  [2023-08-09 15:22:42] frigate.app                    INFO    : go2rtc process pid: 98
2023-08-09 15:22:42.912250189  [2023-08-09 15:22:42] detector.tensorrt              INFO    : Starting detection process: 326
2023-08-09 15:22:42.958869008  [2023-08-09 15:22:42] frigate.app                    INFO    : Output process started: 328
2023-08-09 15:22:42.960823535  [2023-08-09 15:22:42] frigate.app                    INFO    : Camera processor started for driveway: 332
2023-08-09 15:22:42.960832911  [2023-08-09 15:22:42] frigate.app                    INFO    : Capture process started for driveway: 334
2023-08-09 15:22:46.944445006  [2023-08-09 15:22:46] frigate.detectors.plugins.tensorrt INFO    : [MemUsageChange] Init CUDA: CPU +225, GPU +0, now: CPU 281, GPU 1948 (MiB)
2023-08-09 15:22:47.061048694  [2023-08-09 15:22:47] frigate.detectors.plugins.tensorrt INFO    : Loaded engine size: 83 MiB
2023-08-09 15:22:50.495989867  [2023-08-09 15:22:50] frigate.detectors.plugins.tensorrt INFO    : [MemUsageChange] Init cuBLAS/cuBLASLt: CPU +159, GPU -5, now: CPU 532, GPU 1929 (MiB)
2023-08-09 15:22:54.594907439  [2023-08-09 15:22:54] frigate.detectors.plugins.tensorrt INFO    : [MemUsageChange] Init cuDNN: CPU +240, GPU +7, now: CPU 772, GPU 1936 (MiB)
2023-08-09 15:22:55.330347601  [2023-08-09 15:22:55] frigate.detectors.plugins.tensorrt INFO    : [MemUsageChange] TensorRT-managed allocation in engine deserialization: CPU +0, GPU +81, now: CPU 0, GPU 81 (MiB)
2023-08-09 15:22:55.540834724  [2023-08-09 15:22:55] frigate.detectors.plugins.tensorrt INFO    : [MemUsageChange] Init cuBLAS/cuBLASLt: CPU +0, GPU +0, now: CPU 689, GPU 1851 (MiB)
2023-08-09 15:22:55.541155565  [2023-08-09 15:22:55] frigate.detectors.plugins.tensorrt INFO    : [MemUsageChange] Init cuDNN: CPU +0, GPU +1, now: CPU 689, GPU 1852 (MiB)
2023-08-09 15:22:56.298401010  [2023-08-09 15:22:55] frigate.detectors.plugins.tensorrt INFO    : [MemUsageChange] TensorRT-managed allocation in IExecutionContext creation: CPU +0, GPU +68, now: CPU 0, GPU 149 (MiB)

go2rtc looks happy:

2023-08-09 15:22:29.570110870  [INFO] Preparing go2rtc config...
2023-08-09 15:22:31.070340781  [INFO] Starting go2rtc...
2023-08-09 15:22:31.362142901  15:22:31.362 INF go2rtc version 1.6.2 linux/arm64
2023-08-09 15:22:31.362899951  15:22:31.362 INF [api] listen addr=0.0.0.0:1984
2023-08-09 15:22:31.363644189  15:22:31.363 INF [rtsp] listen addr=0.0.0.0:8554
2023-08-09 15:22:31.364616505  15:22:31.363 INF [webrtc] listen addr=0.0.0.0:8555/tcp
2023-08-09 15:22:31.365256937  15:22:31.365 INF [srtp] listen addr=0.0.0.0:8443
2023-08-09 15:22:39.338835145  [INFO] Starting go2rtc healthcheck service...

And nginx seems mostly happy, apart from some errors at the start that might be because frigate isn't ready yet?

2023-08-09 15:22:29.380647969  [INFO] Starting NGINX...
2023-08-09 15:22:34.633363485  192.168.1.28 - - [09/Aug/2023:15:22:34 +1200] "GET / HTTP/1.1" 200 6637 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:22:34.843561018  2023/08/09 15:22:34 [error] 142#142: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.1.28, server: , request: "GET /api/config HTTP/1.1", upstream: "http://127.0.0.1:5001/config", host: "192.168.1.62:5080", referrer: "http://192.168.1.62:5080/"
2023-08-09 15:22:34.843764565  192.168.1.28 - - [09/Aug/2023:15:22:34 +1200] "GET /api/config HTTP/1.1" 502 157 "http://192.168.1.62:5080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:22:37.333744833  2023/08/09 15:22:37 [error] 142#142: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.1.28, server: , request: "GET /api/config HTTP/1.1", upstream: "http://127.0.0.1:5001/config", host: "192.168.1.62:5080", referrer: "http://192.168.1.62:5080/"
2023-08-09 15:22:37.333829210  192.168.1.28 - - [09/Aug/2023:15:22:37 +1200] "GET /api/config HTTP/1.1" 502 157 "http://192.168.1.62:5080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:22:39.990675930  2023/08/09 15:22:39 [error] 142#142: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.1.28, server: , request: "GET /api/config HTTP/1.1", upstream: "http://127.0.0.1:5001/config", host: "192.168.1.62:5080", referrer: "http://192.168.1.62:5080/"
2023-08-09 15:22:39.990812079  192.168.1.28 - - [09/Aug/2023:15:22:39 +1200] "GET /api/config HTTP/1.1" 502 157 "http://192.168.1.62:5080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:22:42.352088981  2023/08/09 15:22:42 [error] 142#142: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.1.28, server: , request: "GET /api/config HTTP/1.1", upstream: "http://127.0.0.1:5001/config", host: "192.168.1.62:5080", referrer: "http://192.168.1.62:5080/"
2023-08-09 15:22:42.352181119  192.168.1.28 - - [09/Aug/2023:15:22:42 +1200] "GET /api/config HTTP/1.1" 502 157 "http://192.168.1.62:5080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:22:55.341297405  192.168.1.28 - - [09/Aug/2023:15:22:55 +1200] "GET /api/config HTTP/1.1" 200 6832 "http://192.168.1.62:5080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:22:55.429030999  192.168.1.28 - - [09/Aug/2023:15:22:55 +1200] "GET //api/driveway/latest.jpg?h=100 HTTP/1.1" 499 0 "http://192.168.1.62:5080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:22:56.106014754  192.168.1.28 - - [09/Aug/2023:15:22:56 +1200] "GET //api/driveway/latest.jpg?h=462 HTTP/1.1" 200 14266 "http://192.168.1.62:5080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:22:59.811849815  192.168.1.28 - - [09/Aug/2023:15:22:59 +1200] "GET /ws HTTP/1.1" 101 51 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:22:59.903879818  192.168.1.28 - - [09/Aug/2023:15:22:59 +1200] "GET / HTTP/1.1" 200 6637 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:23:00.037409711  192.168.1.28 - - [09/Aug/2023:15:23:00 +1200] "GET /api/config HTTP/1.1" 200 6832 "http://192.168.1.62:5080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:23:00.182118683  192.168.1.28 - - [09/Aug/2023:15:23:00 +1200] "GET //api/driveway/latest.jpg?h=100 HTTP/1.1" 200 3555 "http://192.168.1.62:5080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:23:00.234316912  192.168.1.28 - - [09/Aug/2023:15:23:00 +1200] "GET //api/driveway/latest.jpg?h=462 HTTP/1.1" 200 56327 "http://192.168.1.62:5080/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:23:04.970438443  192.168.1.28 - - [09/Aug/2023:15:23:04 +1200] "GET /api/config HTTP/1.1" 200 6832 "http://192.168.1.62:5080/birdseye" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:23:06.286241252  192.168.1.28 - - [09/Aug/2023:15:23:06 +1200] "GET /live/jsmpeg/birdseye HTTP/1.1" 101 4 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:23:06.526522295  192.168.1.28 - - [09/Aug/2023:15:23:06 +1200] "GET /api/events?cameras=all&labels=all&zones=all&sub_labels=all&favorites=0&include_thumbnails=0&limit=25 HTTP/1.1" 200 3 "http://192.168.1.62:5080/events" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:23:06.530406611  192.168.1.28 - - [09/Aug/2023:15:23:06 +1200] "GET /api/labels HTTP/1.1" 200 3 "http://192.168.1.62:5080/events" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:23:06.642562220  192.168.1.28 - - [09/Aug/2023:15:23:06 +1200] "GET /api/sub_labels?split_joined=1 HTTP/1.1" 200 3 "http://192.168.1.62:5080/events" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:23:08.310061714  192.168.1.28 - - [09/Aug/2023:15:23:08 +1200] "GET /api/logs/frigate HTTP/1.1" 200 775 "http://192.168.1.62:5080/logs" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:23:08.310743606  192.168.1.28 - - [09/Aug/2023:15:23:08 +1200] "GET /api/logs/go2rtc HTTP/1.1" 200 271 "http://192.168.1.62:5080/logs" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:23:08.312000877  192.168.1.28 - - [09/Aug/2023:15:23:08 +1200] "GET /api/logs/nginx HTTP/1.1" 200 869 "http://192.168.1.62:5080/logs" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:23:33.757987314  192.168.1.28 - - [09/Aug/2023:15:23:33 +1200] "GET /api/logs/go2rtc HTTP/1.1" 200 271 "http://192.168.1.62:5080/logs" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:23:33.765347810  192.168.1.28 - - [09/Aug/2023:15:23:33 +1200] "GET /api/logs/nginx HTTP/1.1" 200 934 "http://192.168.1.62:5080/logs" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:23:33.767498072  192.168.1.28 - - [09/Aug/2023:15:23:33 +1200] "GET /api/config HTTP/1.1" 200 6832 "http://192.168.1.62:5080/logs" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:23:33.768224288  192.168.1.28 - - [09/Aug/2023:15:23:33 +1200] "GET /api/logs/frigate HTTP/1.1" 200 775 "http://192.168.1.62:5080/logs" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:24:17.496987479  192.168.1.28 - - [09/Aug/2023:15:24:17 +1200] "GET /api/config HTTP/1.1" 200 6832 "http://192.168.1.62:5080/logs" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:24:17.498855495  192.168.1.28 - - [09/Aug/2023:15:24:17 +1200] "GET /api/logs/frigate HTTP/1.1" 200 775 "http://192.168.1.62:5080/logs" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:24:17.540779977  192.168.1.28 - - [09/Aug/2023:15:24:17 +1200] "GET /api/logs/go2rtc HTTP/1.1" 200 271 "http://192.168.1.62:5080/logs" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:24:17.543876357  192.168.1.28 - - [09/Aug/2023:15:24:17 +1200] "GET /api/logs/nginx HTTP/1.1" 200 1021 "http://192.168.1.62:5080/logs" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:24:53.433960394  192.168.1.28 - - [09/Aug/2023:15:24:53 +1200] "GET /ws HTTP/1.1" 101 6301 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:25:42.598513740  192.168.1.28 - - [09/Aug/2023:15:25:42 +1200] "GET /api/config HTTP/1.1" 200 6832 "http://192.168.1.62:5080/logs" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"
2023-08-09 15:25:42.610872590  192.168.1.28 - - [09/Aug/2023:15:25:42 +1200] "GET /api/logs/frigate HTTP/1.1" 200 775 "http://192.168.1.62:5080/logs" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/116.0" "-"

Thanks for any help you can offer.

PS: The updated documentation really should explicitly mention the automatically generated model, and how to reference it
path: /config/model_cache/tensorrt/yolov7-320.trt

@madsciencetist
Copy link
Contributor Author

@kerryland the model width and height parameters need to match the model you're using, so for yolov7-320, you need to set both of those to 320.

I'm wondering if the issues you're seeing are just performance though? Run top and jtop and make sure that the CPU and GPU aren't saturated. You could try switching the model to yolov7-tiny-416 (which requires changing the model width and height parameters to 416).

@kerryland
Copy link

the model width and height parameters need to match

Thank you. It seems to be working.

@klutzzykitty
Copy link

klutzzykitty commented Sep 4, 2023

Few observation running madsciencetist/frigate-jetson:jetpack4.6.1 which I got working after reading over this thread.

  1. On the first run, object detection and motion recognition was ran fine. (yolov7-320.trt model used for detection)
  2. After briefly stopping the container and restarting it the next day, either motion recognition doesn't run,
    or object detection doesn't run or both don't run.
  3. This happens randomly and restarting the container for a few times fixes either one of the issues or both of them.
  4. Toggling them on frigate UI camera debug tab in the UI doesn't display motion boxes or detection boxes. Sometimes after restarting it shows either one of them (either motion or object detection - bounding boxes around objects). Hence thinking if its not displayed then it might not be running.
  5. However logs don't show any issues - frigate logs fine, go2rtc fine, nginx fine as well.

below are some reference images:

  1. no motion detection box but obj detection working:
    regions

  2. System stats when only obj detection is running:

system_usage_edited_

  1. After restart - when both motion and obj detection aren't shown:
    nothing_working_edited

  2. After restarting again (3-4 restarts later) - everything working (all bounding box, regions, motion boxes appear)
    all_working_gpu_edited

logs:

frigate log:

2023-09-04 17:58:22.383245793  [INFO] Preparing Frigate...
2023-09-04 17:58:22.679427548  [INFO] Starting Frigate...
2023-09-04 17:58:30.434592895  [2023-09-04 17:58:30] frigate.app                    INFO    : Starting Frigate (0.13.0-d3c029c1)
2023-09-04 17:58:30.628584258  [2023-09-04 17:58:30] frigate.config                 WARNING : Customizing more than a detector model path is unsupported.
2023-09-04 17:58:31.562691929  [2023-09-04 17:58:31] peewee_migrate.logs            INFO    : Starting migrations
2023-09-04 17:58:31.588030708  [2023-09-04 17:58:31] peewee_migrate.logs            INFO    : There is nothing to migrate
2023-09-04 17:58:31.625107999  [2023-09-04 17:58:31] frigate.app                    INFO    : Recording process started: 319
2023-09-04 17:58:31.633537227  [2023-09-04 17:58:31] frigate.app                    INFO    : go2rtc process pid: 102
2023-09-04 17:58:31.723656080  [2023-09-04 17:58:31] frigate.app                    INFO    : Output process started: 331
2023-09-04 17:58:31.742421762  [2023-09-04 17:58:31] detector.tensorrt              INFO    : Starting detection process: 329
2023-09-04 17:58:31.746483821  [2023-09-04 17:58:31] frigate.app                    INFO    : Camera processor started for testcam: 334
2023-09-04 17:58:31.766470359  [2023-09-04 17:58:31] frigate.app                    INFO    : Capture process started for testcam: 337
2023-09-04 17:58:35.587967977  [2023-09-04 17:58:35] frigate.detectors.plugins.tensorrt INFO    : [MemUsageChange] Init CUDA: CPU +225, GPU +0, now: CPU 281, GPU 3771 (MiB)
2023-09-04 17:58:35.703988381  [2023-09-04 17:58:35] frigate.detectors.plugins.tensorrt INFO    : Loaded engine size: 81 MiB
2023-09-04 17:58:38.103086288  [2023-09-04 17:58:38] frigate.detectors.plugins.tensorrt INFO    : [MemUsageChange] Init cuBLAS/cuBLASLt: CPU +158, GPU +14, now: CPU 529, GPU 3877 (MiB)
2023-09-04 17:58:40.678129580  [2023-09-04 17:58:40] frigate.detectors.plugins.tensorrt INFO    : [MemUsageChange] Init cuDNN: CPU +241, GPU -35, now: CPU 770, GPU 3842 (MiB)
2023-09-04 17:58:40.728178271  [2023-09-04 17:58:40] frigate.detectors.plugins.tensorrt INFO    : [MemUsageChange] TensorRT-managed allocation in engine deserialization: CPU +0, GPU +79, now: CPU 0, GPU 79 (MiB)
2023-09-04 17:58:40.890682193  [2023-09-04 17:58:40] frigate.detectors.plugins.tensorrt INFO    : [MemUsageChange] Init cuBLAS/cuBLASLt: CPU +0, GPU +1, now: CPU 689, GPU 3760 (MiB)
2023-09-04 17:58:40.910139398  [2023-09-04 17:58:40] frigate.detectors.plugins.tensorrt INFO    : [MemUsageChange] Init cuDNN: CPU +0, GPU +0, now: CPU 689, GPU 3760 (MiB)
2023-09-04 17:58:41.163473906  [2023-09-04 17:58:40] frigate.detectors.plugins.tensorrt INFO    : [MemUsageChange] TensorRT-managed allocation in IExecutionContext creation: CPU +0, GPU +68, now: CPU 0, GPU 147 (MiB)

go2rtc log:
2023-09-04 17:58:22.662342264 [INFO] Preparing go2rtc config...
2023-09-04 17:58:24.677192360 [INFO] Starting go2rtc...
2023-09-04 17:58:24.969281170 17:58:24.969 INF go2rtc version 1.6.2 linux/arm64
2023-09-04 17:58:24.970530986 17:58:24.970 INF [api] listen addr=0.0.0.0:1984
2023-09-04 17:58:24.971434754 17:58:24.971 INF [rtsp] listen addr=0.0.0.0:8554
2023-09-04 17:58:24.972459982 17:58:24.972 INF [webrtc] listen addr=0.0.0.0:8555/tcp
2023-09-04 17:58:24.973717663 17:58:24.973 INF [srtp] listen addr=0.0.0.0:8443
2023-09-04 17:58:32.362349772 [INFO] Starting go2rtc healthcheck service...

Nginx log:

2023-09-04 17:58:22.387168213  [INFO] Starting NGINX...
2023-09-04 17:59:03.000590560  172.18.0.1 - - [04/Sep/2023:17:59:02 +0530] "GET / HTTP/1.1" 200 6637 "-" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:04.381287269  172.18.0.1 - - [04/Sep/2023:17:59:04 +0530] "GET /api/config HTTP/1.1" 200 6616 "http://0.0.0.0:5000/" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:05.162953564  172.18.0.1 - - [04/Sep/2023:17:59:05 +0530] "GET //api/testcam/latest.jpg?h=100 HTTP/1.1" 200 4113 "http://0.0.0.0:5000/" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:05.219277587  172.18.0.1 - - [04/Sep/2023:17:59:05 +0530] "GET //api/testcam/latest.jpg?h=383 HTTP/1.1" 200 36610 "http://0.0.0.0:5000/" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:06.482368185  172.18.0.1 - - [04/Sep/2023:17:59:06 +0530] "GET /api/labels?camera=testcam HTTP/1.1" 200 3 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:09.655224117  172.18.0.1 - - [04/Sep/2023:17:59:09 +0530] "GET /live/jsmpeg/testcam HTTP/1.1" 101 4 "-" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:09.672216586  172.18.0.1 - - [04/Sep/2023:17:59:09 +0530] "GET /api/config HTTP/1.1" 200 6616 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:09.690607364  172.18.0.1 - - [04/Sep/2023:17:59:09 +0530] "GET //api/testcam/latest.jpg?h=100&cache=1693830549593&bbox=1&motion=1&timestamp=0&mask=0&regions=1&zones=0 HTTP/1.1" 200 4324 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:09.764091829  172.18.0.1 - - [04/Sep/2023:17:59:09 +0530] "GET //api/testcam/latest.jpg?h=480&cache=1693830549593&bbox=1&motion=1&timestamp=0&mask=0&regions=1&zones=0 HTTP/1.1" 200 65060 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:09.954285982  172.18.0.1 - - [04/Sep/2023:17:59:09 +0530] "GET //api/testcam/latest.jpg?h=480&cache=1693830549921&bbox=1&motion=1&timestamp=0&mask=0&regions=1&zones=0 HTTP/1.1" 200 65060 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:10.007434058  172.18.0.1 - - [04/Sep/2023:17:59:10 +0530] "GET //api/testcam/latest.jpg?h=480&cache=1693830549977&bbox=1&motion=1&timestamp=0&mask=0&regions=1&zones=0 HTTP/1.1" 200 65060 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:10.207226942  172.18.0.1 - - [04/Sep/2023:17:59:10 +0530] "GET //api/testcam/latest.jpg?h=480&cache=1693830550167&bbox=1&motion=1&timestamp=0&mask=0&regions=1&zones=0 HTTP/1.1" 200 65060 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:10.273588506  172.18.0.1 - - [04/Sep/2023:17:59:10 +0530] "GET //api/testcam/latest.jpg?h=480&cache=1693830550234&bbox=1&motion=1&timestamp=0&mask=0&regions=1&zones=0 HTTP/1.1" 200 65060 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:10.458685424  172.18.0.1 - - [04/Sep/2023:17:59:10 +0530] "GET //api/testcam/latest.jpg?h=480&cache=1693830550417&bbox=1&motion=1&timestamp=0&mask=0&regions=1&zones=0 HTTP/1.1" 200 65060 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:10.547493314  172.18.0.1 - - [04/Sep/2023:17:59:10 +0530] "GET //api/testcam/latest.jpg?h=480&cache=1693830550485&bbox=1&motion=1&timestamp=0&mask=0&regions=1&zones=0 HTTP/1.1" 200 65060 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:10.708634762  172.18.0.1 - - [04/Sep/2023:17:59:10 +0530] "GET //api/testcam/latest.jpg?h=480&cache=1693830550670&bbox=1&motion=1&timestamp=0&mask=0&regions=1&zones=0 HTTP/1.1" 200 65060 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:10.848607616  172.18.0.1 - - [04/Sep/2023:17:59:10 +0530] "GET //api/testcam/latest.jpg?h=480&cache=1693830550758&bbox=1&motion=1&timestamp=0&mask=0&regions=1&zones=0 HTTP/1.1" 200 65060 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:10.952923259  172.18.0.1 - - [04/Sep/2023:17:59:10 +0530] "GET //api/testcam/latest.jpg?h=480&cache=1693830550921&bbox=1&motion=1&timestamp=0&mask=0&regions=1&zones=0 HTTP/1.1" 200 65060 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:11.092490272  172.18.0.1 - - [04/Sep/2023:17:59:11 +0530] "GET //api/testcam/latest.jpg?h=480&cache=1693830551062&bbox=1&motion=1&timestamp=0&mask=0&regions=1&zones=0 HTTP/1.1" 200 65060 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:11.191867017  172.18.0.1 - - [04/Sep/2023:17:59:11 +0530] "GET //api/testcam/latest.jpg?h=480&cache=1693830551163&bbox=1&motion=1&timestamp=0&mask=0&regions=1&zones=0 HTTP/1.1" 200 65060 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:11.355757164  172.18.0.1 - - [04/Sep/2023:17:59:11 +0530] "GET //api/testcam/latest.jpg?h=480&cache=1693830551316&bbox=1&motion=1&timestamp=0&mask=0&regions=1&zones=0 HTTP/1.1" 200 65060 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"
2023-09-04 17:59:11.442673142  172.18.0.1 - - [04/Sep/2023:17:59:11 +0530] "GET //api/testcam/latest.jpg?h=480&cache=1693830551401&bbox=1&motion=1&timestamp=0&mask=0&regions=1&zones=0 HTTP/1.1" 200 65060 "http://0.0.0.0:5000/cameras/testcam" "Mozilla/5.0 (X11; Ubuntu; Linux aarch64; rv:109.0) Gecko/20100101 Firefox/113.0" "-"

config file:

mqtt:
  host: 172.x.x.x
  user: xxxxx
  password: xxxxx

cameras:
  testcam:
    ffmpeg:
      hwaccel_args: preset-jetson-h264
      inputs:
        - path: /media/frigate/Video11.mp4
          input_args: -re -stream_loop -1 -fflags +genpts
          roles:
            - detect

detectors:
  tensorrt:
    type: tensorrt
    model:
      path: /config/model_cache/tensorrt/yolov7-320.trt

model:
  input_tensor: nchw
  width: 320
  height: 320

objects:
  track:
    - person
    - car

Appreciated if anyone can suggest how it can be corrected or why it's behaving this way.

Specs:
Jetson nano 4GB Jetpack 4.6.1

@NickM-27
Copy link
Sponsor Collaborator

NickM-27 commented Sep 4, 2023

@klutzzykitty I would suggest using the up to date frigate dev builds that are being done, I don't think that build is up to date

@klutzzykitty
Copy link

klutzzykitty commented Sep 5, 2023

@NickM-27 Thank you !
I'm trying with the latest dev build for jetpack 4.6 - ghcr.io/blakeblackshear/frigate:dev-6e35c97-tensorrt-jp4

It's the same behavior with it as well. (Removed the previous container files completely along with docker volumes)
Here's a reference image with motion, detection boxes turned on but nothing appears.

new_frig_no_detection

This is how i'm starting the container:

frig_jetson: 
    container_name: gpu_jetson
    image: ghcr.io/blakeblackshear/frigate:dev-6e35c97-tensorrt-jp4
    privileged: true
    restart: unless-stopped
    volumes: 
      - /etc/localtime:/etc/localtime
      - /home/frigate_jetson/config/config.yml:/config/config.yml
      - /home/frigate_jetson/debug:/media/frigate
#     - /home/frigate_jetson/trt-models:/trt-models  # not required
      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 500000000
    ports:
      - 5000:5000
      - 18554:8554 # RTSP feeds
      - 18555:8555/tcp # WebRTC over tcp
      - 18555:8555/udp # WebRTC over udp

    runtime: nvidia
    environment:
      YOLO_MODELS: yolov7-320 

PS: after few restarts , sometimes everything works like in the references images above.
If the container is stopped and started again, then the issue repeats where nothing appears(no motion or detection boxes) until few more restarts.

@madsciencetist
Copy link
Contributor Author

madsciencetist commented Sep 5, 2023

@klutzzykitty I haven't encountered that. If it's failing to detect motion, but only when using tensorrt (verify that first), then the thread might be getting stuck. You could use something like py-spy, pyrasite or faulthandler.dump_traceback(all_threads=True) to see where the thread is stuck.

@klutzzykitty
Copy link

klutzzykitty commented Sep 6, 2023

Thanks for the hint @madsciencetist !

  1. I guess it's not restricted to tensorrt as I tried with a USB coral TPU on jetson nano 4GB and the results were the same.
    i) No motion or object detection or region boxes shown
    ii) Region and object detection boxes shown but no motion box
    iii) Motion, object and region boxes are all shown and everything works properly.

These are the 3 repetitive happenings (in random) up on restarting the container - latest jp4 frigate image.
Below is a screenshot with coral inference - no motion box but obj bounding box and region box are present.
no_motion_tpu

So the first case is verified - failing to detect motion but not limited to only when using tensorrt.

then the thread might be getting stuck. You could use something like py-spy, pyrasite or faulthandler.dump_traceback(all_threads=True) to see where the thread is stuck.

Can you throw more light on how I can take the stuck thread part forward ? where do I use the faulthandler : )

@NickM-27 has this occurred anytime during testing ? Any clue on why threads could be getting stuck ?
Thanks : )

Logs as i used TPU: nothing quirky noticeable in the logs.

2023-09-06 18:02:43.060902603  [INFO] Starting NGINX...
2023-09-06 18:02:43.061051144  [INFO] Preparing Frigate...
2023-09-06 18:02:43.102561640  [INFO] Preparing go2rtc config...
s6-rc: info: service legacy-services successfully started
2023-09-06 18:02:43.164374574  [INFO] Starting Frigate...
2023-09-06 18:02:44.124832846  [INFO] Starting go2rtc...
2023-09-06 18:02:44.418089281  18:02:44.414 INF go2rtc version 1.6.2 linux/arm64
2023-09-06 18:02:44.418096729  18:02:44.415 INF [api] listen addr=0.0.0.0:1984
2023-09-06 18:02:44.418102614  18:02:44.416 INF [rtsp] listen addr=0.0.0.0:8554
2023-09-06 18:02:44.418107302  18:02:44.416 INF [webrtc] listen addr=0.0.0.0:8555/tcp
2023-09-06 18:02:44.418606311  18:02:44.418 INF [srtp] listen addr=0.0.0.0:8443
2023-09-06 18:02:48.812762585  [2023-09-06 18:02:48] frigate.app                    INFO    : Starting Frigate (0.13.0-6e35c97)
2023-09-06 18:02:48.909130724  [2023-09-06 18:02:48] peewee_migrate.logs            INFO    : Starting migrations
2023-09-06 18:02:48.922797713  [2023-09-06 18:02:48] peewee_migrate.logs            INFO    : There is nothing to migrate
2023-09-06 18:02:48.937096523  [2023-09-06 18:02:48] frigate.app                    INFO    : Recording process started: 313
2023-09-06 18:02:48.946853993  [2023-09-06 18:02:48] frigate.app                    INFO    : go2rtc process pid: 99
2023-09-06 18:02:49.003858035  [2023-09-06 18:02:48] detector.coral                 INFO    : Starting detection process: 323
2023-09-06 18:02:49.010293900  [2023-09-06 18:02:49] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to load TPU as usb
2023-09-06 18:02:49.010701139  [2023-09-06 18:02:49] frigate.app                    INFO    : Output process started: 325

@NickM-27
Copy link
Sponsor Collaborator

NickM-27 commented Sep 6, 2023

At some point if object detection is occurring then motion detection has to have occurred. I must be honest I look at the debug view pretty often and I've never seen an issue with the boxes not showing.

With case i) I am not sure, but case ii) means I am not convinced this is a stuck thread issue or that there is any internal issue at all, could potentially just be motion boxes not being drawn on the debug image in some cases for some reason.

Either way, I've not seen this issue at all running the main dev image and corals

@klutzzykitty
Copy link

klutzzykitty commented Sep 9, 2023

At some point if object detection is occurring then motion detection has to have occurred.

@NickM-27 Yeah I agree as first motion detection happens and those regions are passed for object detection.

I tried with another Jetson Nano 4GB with an even latest image : dev-5658e5a-tensorrt-jp4
It's the same behavior there as well.
works fine on the first try, then after restarting either there are no boxes at all (no detection, motion, region) or there are only 1-2 region boxes and obj detection boxes even if there are other objects around.
After 3-4 restarts of the container, its back to normal and then the behavior repeats if I stop/start the container again.

Here's some py-spy outputs for which i think there had to be more activity . Thinking below two are important ones
as other processes are frigate.logger, frigate.recording_manager and frigate.output.

  1. tensorrt detector (frigate.detector): when everything is working properly, this shows a lot of activity , here this was the output for 3-4 minutes
    py_spy_top_none_working

  2. (frigate.capture) :
    py_spy_none_working_2

Can any direction be provided so I can try to figure what can be done? Currently im in complete open waters with this issue XD
(Haven't had an exposure with threading or profiling code, so directions or some info on how to try out some suggestion is appreciated : ) )

could potentially just be motion boxes not being drawn on the debug image in some cases for some reason.

If that's a case, how can that be checked ? can the video that comes to debug somehow be grabbed to verify?
Thanks !

@NickM-27
Copy link
Sponsor Collaborator

NickM-27 commented Sep 9, 2023

I'll look later, but the debug view is not video, it's just an image frame hitting the debug image endpoint 5 times a second.

@klutzzykitty
Copy link

Sure! Thanks Nick.
Let me know when you do start looking into it.
Sounds pretty interesting to investigate.

@madsciencetist
Copy link
Contributor Author

@klutzzykitty I think you'll get to the bottom of this fastest by adding debug prints to the process_frames() function in video.py. There you can verify that the function is getting called, that its call to motion_detector.detect(frame) works, that regions is non-empty and that detect() gets called.

@klutzzykitty
Copy link

@madsciencetist Thanks for the hints.
Was thinking of something similar but didn't know where to start tapping.
I'll also ask around and see if others who are using it on jetson come across the issue.

@the-master-r
Copy link

the-master-r commented Sep 28, 2023

i cant seem to get my stack to run

i get no web interface
i get no config file
i do get the yolo model

im running a jetson-nano 4G with portainer-ce to deploy the stack

im planning to add 1or2 cameras maybe with a coral (coral not ordered yet)

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:dev-0858859-tensorrt-jp4
    shm_size: "64mb" # update for your cameras based on calculation above
    devices:
      - /dev/bus/usb:/dev/bus/usb # passes the USB Coral, needs to be modified for other versions
      - /dev/apex_0:/dev/apex_0 # passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux
     # - /dev/dri/renderD128 # for intel hwaccel, needs to be updated for your hardware
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /home/jetson-nano/frigate/config:/config
      - /home/jetson-nano/frigate/storage:/media/frigate
      - type: tmpfs # Optional: 1GB 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:
      FRIGATE_RTSP_PASSWORD: "1"`
  currently learning github text layout (wall of text wasnt intentional) 

@NickM-27
Copy link
Sponsor Collaborator

i get no config file

you have to create the config file, I'd suggest reading the docs https://deploy-preview-6262--frigate-docs.netlify.app/guides/getting_started

@the-master-r
Copy link

so i have to open a cli text editor and write myself a full config file ? i get no web page at all

@NickM-27
Copy link
Sponsor Collaborator

at least a minimal config file, then the built in webui config editor can be used

@the-master-r
Copy link

the-master-r commented Sep 28, 2023

since i was not able to find it out on my own for a full day

you need to run

sudo nano /YOUR SAME PATH AS YOUR COMPOSE FILE CONFIG FILE/config.yml

then paste someting like

mqtt:
  enabled: False

cameras:
  name_of_your_camera: # <------ Name the camera
    ffmpeg:
      inputs:
        - path: rtsp://10.0.10.10:554/rtsp # <----- The stream you want to use for detection
          roles:
            - detect
    detect:
      enabled: False # <---- disable detection until you have a working camera feed
      ```
    
    then you get a web interface to figure out what you want to do 
    
    
   just a thought but cant you trow in a 
   
   if no config.yml 
   write basic info 
   into the startup 

@kerryland
Copy link

kerryland commented Sep 30, 2023

Is this still the correct image? : image: ghcr.io/blakeblackshear/frigate:dev-0858859-tensorrt-jp4

And if not, how would I find out what is the latest version?

(I randomly guessed at ghcr.io/blakeblackshear/frigate:stable-tensorrt-jp4 but that didn't work)

Thanks!

@the-master-r
Copy link

Is this still the correct image? : image: ghcr.io/blakeblackshear/frigate:dev-0858859-tensorrt-jp4

And if not, how would I find out what is the latest version

I just trew that web address into a browser and
Looked around

ghcr.io/blakeblackshear/frigate:dev-37379e6-tensorrt-jp4 has been released 7hrs ago and has 1 download

@kerryland
Copy link

I just trew that web address into a browser and Looked around

That's hysterical. Thanks!

@yuyoujiang
Copy link

Is there any documentation about how to deploy frigate on jetson?
I followed this connection https://github.com/blakeblackshear/frigate/blob/dev/docs/docs/frigate/installation.md earlier. ghcr.io/blakeblackshear/frigate:stable can work properly, but it can not inference with tensorrt. ghcr.io/blakeblackshear/frigate:stable-tensorrt-jp5 has failed.

PS: I have a Jetson Orin Nano 8G with Jetpack 5.1.1

@NickM-27
Copy link
Sponsor Collaborator

Jetson image is not stable yet, you'll need to use the 0.13 beta

@yuyoujiang
Copy link

Thank you for your reply, I have learned this information

@the-master-r
Copy link

I recently bought a new camera that's
H265 only
And I have 2 issues

  1. I can't get an image on frigate
  2. I don't think my ffmpeg build has h265 enabled

As far as I can see h265 is supported on the jetson nano

mqtt:
  enabled: False

cameras:
  camera-koen: # <------ Name the camera
    ffmpeg:
      inputs:
        - path: rtsp://camera-koen:[*********]@192.168.1.48:554/stream1  # <----- The stream you want to use for detection
          roles:
            - detect
            - record
    detect:
      enabled: true # <---- disable detection until you have a working camera feed
    objects:
      track:
        - person
        - car
        - truck
        - bicycle
        - motorcycle
        - dog
        - cat
        - horse
  camera-paarden: # <------ Name the camera
    ffmpeg:
      inputs:
        - path: rtsp://admin:[*******(]@192.168.1.56:554/onvif0
          # onvif://admin:[*******]@192.168.1.56:8899?subtype=000
          #rtsp://admin;[****]@192.168.1.56:554/channel=1/stream=0.sdp?real_stream   # <----- The stream you want to use for detection
          roles:
            - detect
            - record
    detect:
      enabled: true # <---- disable detection until you have a working camera feed
    objects:
      track:
        - person
        - car
        - truck
        - bicycle
        - motorcycle
        - dog
        - cat
        - horse
ffmpeg:
  hwaccel_args: preset-jetson-h264     
detectors:
  tensorrt:
    type: tensorrt
    device: 0 #This is the default, select the first GPU
model:
  path: /config/model_cache/tensorrt/yolov7-tiny-416.trt
  input_tensor: nchw
  input_pixel_format: rgb
  width: 416
  height: 416
record:
  enabled: true
telemetry:
  network_interfaces:
    - eth 

I'm talking about [camera-paarden] that's not working

@madsciencetist
Copy link
Contributor Author

@the-master-r you have hwaccel_args: preset-jetson-h264 in your config file. If your camera is H265 you need to use hwaccel_args: preset-jetson-h265 instead. Please read the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet