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

frigate: coral tpu support, audio model, nvidia ffmpeg hwaccel, other fixes #357717

Merged
merged 12 commits into from
Nov 23, 2024

Conversation

mweinelt
Copy link
Member

@mweinelt mweinelt commented Nov 20, 2024

Supersedes: #332689
Closes: #320512, #344114

cc @nagisa

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 6.topic: hardware labels Nov 21, 2024
@mweinelt mweinelt force-pushed the frigate-libedgetpu branch 2 times, most recently from d3d85e5 to 475a6c3 Compare November 21, 2024 15:02
@mweinelt mweinelt changed the title frigate: provide absolute path to libedgetpu frigate: edgetpu support, audio model, nvidia ffmpeg hwaccel, other fixes Nov 21, 2024
@mweinelt mweinelt marked this pull request as ready for review November 21, 2024 15:17
@mweinelt mweinelt changed the title frigate: edgetpu support, audio model, nvidia ffmpeg hwaccel, other fixes frigate: edgetpu/coral support, audio model, nvidia ffmpeg hwaccel, other fixes Nov 21, 2024
Copy link
Contributor

@nagisa nagisa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The nginx changes seem good to me. The gasket/edgetpu changes LGTM.

Can't comment on tensorflow/model/label or nvidia changes.

@mweinelt mweinelt added the backport release-24.11 Backport PR automatically label Nov 21, 2024
@JManch
Copy link
Contributor

JManch commented Nov 21, 2024

I haven't tested this PR but on my system I need the following for the PCIe Coral to work as described here

users.groups.apex = {};

services.udev.extraRules = ''
  SUBSYSTEM=="apex", MODE="0660", GROUP="apex"
'';

systemd.services.frigate.serviceConfig.SupplementaryGroups = "apex";

@mweinelt
Copy link
Member Author

mweinelt commented Nov 21, 2024

Okay, renamed the edgetpu module to hardware.coral and also named the group for access to coral devices that.

@JManch Thanks for the pointer, I've integrated those changes.

@netpleb
Copy link

netpleb commented Nov 21, 2024

Sorry, I had originally commented on the wrong issue (#188719). @mweinelt I am happy to give this a try. It is pretty much exactly the fix I have been looking for! I have a flakes based system with a nixpkgs input pointed at nixpkgs-unstable. How would you suggest is the best way for me to try out your PR and report back? Do I need to somehow disable the existing nixpkgs frigate module?

@SigmaSquadron SigmaSquadron mentioned this pull request Nov 21, 2024
13 tasks
@GoogleBot42
Copy link
Contributor

This looks pretty good! I'll see if I can give it a try later today. It looks like it should be able to replace what I have already. https://github.com/GoogleBot42/nix-config/blob/eb6a50664cb3efbecde19cb9316a682cf64e983d/machines/storage/s0/frigate.nix#L143

@JManch
Copy link
Contributor

JManch commented Nov 21, 2024

Just tested my PCIe Coral with this PR and can confirm it works as expected!

@mweinelt mweinelt changed the title frigate: edgetpu/coral support, audio model, nvidia ffmpeg hwaccel, other fixes frigate: coral tpu support, audio model, nvidia ffmpeg hwaccel, other fixes Nov 21, 2024
@JManch
Copy link
Contributor

JManch commented Nov 21, 2024

ExecStartPre = "-rm /var/cache/frigate/*.mp4";

Just as an extra small fix could this be replaced with something like:

ExecStartPre = pkgs.writeShellScript "frigate-clear-cache" ''
  rm -f /var/cache/frigate/*.mp4
'';

Currently I get frigate.service: Unable to locate executable 'rm': No such file or directory every time the service starts and I don't think the wildcard expansion works in this context.

@github-actions github-actions bot added 8.has: documentation This PR adds or changes documentation 8.has: changelog labels Nov 22, 2024
@mweinelt
Copy link
Member Author

mweinelt commented Nov 22, 2024

Last call everyone! If you have further feedback, send it now.

The plan is to merge this later tonight (in ~6 hours).

mweinelt and others added 11 commits November 22, 2024 17:59
Provides a small wrapper to enable support for Coral USB and PCIe
devices.
Shell expansions apparently do not work correctly in systemd command
lines.

Co-Authored-By: Joshua Manchester <JManch@protonmail.com>
The `render` group is required to acces the graphic cards decoding,
encoding and transcoding capabilities.

It is required for using fancy `ffmpeg.hwaccel-args` values, like
`preset-vaapi`.
In my testing this helped steer VA-API towards the correct card and also
made it show GPU statistics in performance monitoring.
@netpleb
Copy link

netpleb commented Nov 22, 2024

@frederictobiasc I have been trying to test this with my coral USB and frigate but to no avail. Would it be possible for you to share the relevant parts of the configuration you used to test this PR?

@netpleb
Copy link

netpleb commented Nov 22, 2024

Actually, a reboot seemed to fix the issue and now it properly detects the usb tpu it seems. I am still new to frigate so not totally able to test the detection functionality itself yet, but this was a huge step! Thanks so much @mweinelt !!!

@ofborg ofborg bot requested review from frenetic00 and kylehendricks November 22, 2024 21:31
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 11-100 labels Nov 22, 2024
@mweinelt mweinelt merged commit 7eb0c19 into NixOS:master Nov 23, 2024
34 of 35 checks passed
@mweinelt mweinelt deleted the frigate-libedgetpu branch November 23, 2024 00:05
Copy link
Contributor

@mweinelt
Copy link
Member Author

Hey everyone, feel free to join #homeautomation:nixos.org on Matrix to stay connected. We talk a lot about Home Assistant, Frigate as well as Zigbee, Matter and Z-Wave in there.

Atemu added a commit to Atemu/nixpkgs that referenced this pull request Nov 24, 2024
With NixOS#354952, the regular ffmpeg-headless
should now have all the deps required for frigate to make use of hardware
acceleration on all hardware.

This is progress towards NixOS#271863

This reverts commit 7e33e47.

This may be surprising as it's quite soon after
7e33e47 was merged but we decided in
NixOS#357717 (comment) to merge it
quickly to unbreak master and backport to 24.11. Non-full ffmpeg can be pursued
in master using a simple revert which is where we are now.
@cole-h cole-h removed the ofborg-internal-error Ofborg encountered an error label Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: hardware 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog 8.has: documentation This PR adds or changes documentation 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 11-100 backport release-24.11 Backport PR automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

frigate: enables nginx.recommendedProxySettings by default
10 participants