| 20 Nov 2024 |
@hexa:lossy.network | https://github.com/NixOS/nixpkgs/pull/357717 | 23:59:41 |
@hexa:lossy.network | untested | 23:59:48 |
| 21 Nov 2024 |
netpleb | In reply to @hexa:lossy.network https://github.com/NixOS/nixpkgs/pull/357717 whoa, you are amazing!!! ok I will test it and see what happens! | 00:01:14 |
netpleb | really dumb question -- when you test something like this, what is you usual method? I figured I would just change my nixpkgs input from nixos-unstable over to that PR branch you just published. That pretty much what you do? | 00:02:30 |
netpleb | sorry, maybe the better question is this: for home automation things, do you end up with multiple version of nixpkgs as inputs? Such as "nixpkgs-frigate" and "nixpkgs-home-assistant" so that you're able to bump along and pull in latest things? | 00:04:06 |
@hexa:lossy.network | I would probably override the package | 00:04:14 |
@hexa:lossy.network | https://search.nixos.org/options?channel=unstable&show=services.frigate.package&from=0&size=50&sort=relevance&type=packages&query=frigate.package | 00:04:47 |
@hexa:lossy.network | so this option defaults to pkgs.frigate | 00:04:52 |
@hexa:lossy.network | and you could in theory do the following | 00:04:59 |
@hexa:lossy.network | { lib, pkgs, ... }:
{
services.frigate.package = pkgs.frigate.overrideAttrs (oldAttrs: {
patches = oldAttrs.patches or [ ] ++ [
(substituteAll {
src = ./libedgetpu.patch;
libedgetpu = "${lib.getLib pkgs.libedgetpu}/lib/libedgetpu.so.1.0";
})
];
});
}
| 00:06:29 |
@hexa:lossy.network | and then drop the patch into the same directory | 00:06:47 |
netpleb | In reply to @hexa:lossy.network and then drop the patch into the same directory ok, I will try that, thanks! I have never done this type of patching. I presume I download the patch file from your github PR branch? | 00:08:36 |
netpleb | oh, I am dumb, you mean that actual libedgetpu.patch file that you included within that PR | 00:09:16 |
@hexa:lossy.network | yep | 00:11:34 |
netpleb | hmm, close but we are missing something:
error:
… while calling the 'seq' builtin
at /nix/store/hfz1qqd0z8amlgn8qwich1dvkmldik36-source/lib/modules.nix:334:18:
333| options = checked options;
334| config = checked (removeAttrs config [ "_module" ]);
| ^
335| _module = checked (config._module);
… while evaluating a branch condition
at /nix/store/hfz1qqd0z8amlgn8qwich1dvkmldik36-source/lib/modules.nix:273:9:
272| checkUnmatched =
273| if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
| ^
274| let
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: undefined variable 'substituteAll'
at /nix/store/zh6ixwqp7n0xv469hdqrmir0v82q21rx-source/home-assistant.nix:83:10:
82| patches = oldAttrs.patches or [ ] ++ [
83| (substituteAll {
| ^
84| src = ./patches/libedgetpu.patch;
| 00:16:08 |
@hexa:lossy.network | * { lib, pkgs, ... }:
{
services.frigate.package = pkgs.frigate.overrideAttrs (oldAttrs: {
patches = oldAttrs.patches or [ ] ++ [
(pkgs.substituteAll {
src = ./libedgetpu.patch;
libedgetpu = "${lib.getLib pkgs.libedgetpu}/lib/libedgetpu.so.1.0";
})
];
});
}
| 00:16:36 |
@hexa:lossy.network | updated | 00:16:38 |
netpleb | In reply to @netpleb:matrix.org
hmm, close but we are missing something:
error:
… while calling the 'seq' builtin
at /nix/store/hfz1qqd0z8amlgn8qwich1dvkmldik36-source/lib/modules.nix:334:18:
333| options = checked options;
334| config = checked (removeAttrs config [ "_module" ]);
| ^
335| _module = checked (config._module);
… while evaluating a branch condition
at /nix/store/hfz1qqd0z8amlgn8qwich1dvkmldik36-source/lib/modules.nix:273:9:
272| checkUnmatched =
273| if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
| ^
274| let
(stack trace truncated; use '--show-trace' to show the full, detailed trace)
error: undefined variable 'substituteAll'
at /nix/store/zh6ixwqp7n0xv469hdqrmir0v82q21rx-source/home-assistant.nix:83:10:
82| patches = oldAttrs.patches or [ ] ++ [
83| (substituteAll {
| ^
84| src = ./patches/libedgetpu.patch;
should it be lib.substituteAll? | 00:17:07 |
@hexa:lossy.network | no, pkgs.substituteAll | 00:17:43 |
netpleb | In reply to @hexa:lossy.network no, pkgs.substituteAll interesting, apparently there is a lib.substituteAll as well ;) | 00:18:54 |
@hexa:lossy.network | nix-repl> lib.substituteAll
error: attribute 'substituteAll' missing
| 00:20:00 |
netpleb | In reply to @hexa:lossy.network
{ lib, pkgs, ... }:
{
services.frigate.package = pkgs.frigate.overrideAttrs (oldAttrs: {
patches = oldAttrs.patches or [ ] ++ [
(pkgs.substituteAll {
src = ./libedgetpu.patch;
libedgetpu = "${lib.getLib pkgs.libedgetpu}/lib/libedgetpu.so.1.0";
})
];
});
}
unfortunately this did not work:
Nov 20 16:18:59 aleph0 frigate[5661]: OSError: libedgetpu.so.1.0: cannot open shared object file: No such file or directory
Nov 20 16:18:59 aleph0 frigate[5661]: Exception ignored in: <function Delegate.__del__ at 0x7f93e7ef0540>
Nov 20 16:18:59 aleph0 frigate[5661]: Traceback (most recent call last):
Nov 20 16:18:59 aleph0 frigate[5661]: File "/nix/store/y7wsnapb7w8pqkifah4v7s271n30d84z-python3.12-tensorflow-2.18.0/lib/python3.12/site-packages/tensorflow/lite/python/interpreter.py", line 109, in __del__
Nov 20 16:18:59 aleph0 frigate[5661]: if self._library is not None:
Nov 20 16:18:59 aleph0 frigate[5661]: ^^^^^^^^^^^^^
Nov 20 16:18:59 aleph0 frigate[5661]: AttributeError: 'Delegate' object has no attribute '_library'
| 00:24:54 |
@hexa:lossy.network | https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/python/interpreter.py#L133 | 00:26:11 |
@hexa:lossy.network | https://github.com/tensorflow/tensorflow/blob/master/tensorflow/lite/python/interpreter.py#L80 | 00:27:17 |
@hexa:lossy.network | LoadLibrary doesn't seem to want a path | 00:28:09 |
netpleb | hmm, so somehow we have to also patch tensorflow? | 00:28:36 |
@hexa:lossy.network | please no 😄 | 00:28:43 |
netpleb | ok, well I am officially befuddled then. | 00:29:30 |
netpleb | here is the full error:
Nov 20 16:18:59 aleph0 frigate[5614]: [2024-11-20 16:18:59] detector.coral INFO : Starting detection process: 5661
Nov 20 16:18:59 aleph0 frigate[5614]: [2024-11-20 16:18:59] frigate.detectors.plugins.edgetpu_tfl INFO : Attempting to load TPU as usb
Nov 20 16:18:59 aleph0 frigate[5661]: Process detector:coral:
Nov 20 16:18:59 aleph0 frigate[5661]: Traceback (most recent call last):
Nov 20 16:18:59 aleph0 frigate[5661]: File "/nix/store/px2nj16i5gc3d4mnw5l1nclfdxhry61p-python3-3.12.7/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
Nov 20 16:18:59 aleph0 frigate[5661]: self.run()
Nov 20 16:18:59 aleph0 frigate[5661]: File "/nix/store/px2nj16i5gc3d4mnw5l1nclfdxhry61p-python3-3.12.7/lib/python3.12/multiprocessing/process.py", line 108, in run
Nov 20 16:18:59 aleph0 frigate[5661]: self._target(*self._args, **self._kwargs)
Nov 20 16:18:59 aleph0 frigate[5661]: File "/nix/store/2p2ndg642zj286gjxhxl6ql1psvnmlb3-frigate-0.14.1/lib/python3.12/site-packages/frigate/object_detection.py", line 102, in run_detector
Nov 20 16:18:59 aleph0 frigate[5661]: object_detector = LocalObjectDetector(detector_config=detector_config)
Nov 20 16:18:59 aleph0 frigate[5661]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Nov 20 16:18:59 aleph0 frigate[5661]: File "/nix/store/2p2ndg642zj286gjxhxl6ql1psvnmlb3-frigate-0.14.1/lib/python3.12/site-packages/frigate/object_detection.py", line 53, in __init__
Nov 20 16:18:59 aleph0 frigate[5661]: self.detect_api = create_detector(detector_config)
Nov 20 16:18:59 aleph0 frigate[5661]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Nov 20 16:18:59 aleph0 frigate[5661]: File "/nix/store/2p2ndg642zj286gjxhxl6ql1psvnmlb3-frigate-0.14.1/lib/python3.12/site-packages/frigate/detectors/__init__.py", line 18, in create_detector
Nov 20 16:18:59 aleph0 frigate[5661]: return api(detector_config)
Nov 20 16:18:59 aleph0 frigate[5661]: ^^^^^^^^^^^^^^^^^^^^
Nov 20 16:18:59 aleph0 frigate[5661]: File "/nix/store/2p2ndg642zj286gjxhxl6ql1psvnmlb3-frigate-0.14.1/lib/python3.12/site-packages/frigate/detectors/plugins/edgetpu_tfl.py", line 41, in __init__
Nov 20 16:18:59 aleph0 frigate[5661]: edge_tpu_delegate = load_delegate("libedgetpu.so.1.0", device_config)
Nov 20 16:18:59 aleph0 frigate[5661]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Nov 20 16:18:59 aleph0 frigate[5661]: File "/nix/store/y7wsnapb7w8pqkifah4v7s271n30d84z-python3.12-tensorflow-2.18.0/lib/python3.12/site-packages/tensorflow/lite/python/interpreter.py", line 166, in load_delegate
Nov 20 16:18:59 aleph0 frigate[5661]: delegate = Delegate(library, options)
Nov 20 16:18:59 aleph0 frigate[5661]: ^^^^^^^^^^^^^^^^^^^^^^^^^^
Nov 20 16:18:59 aleph0 frigate[5661]: File "/nix/store/y7wsnapb7w8pqkifah4v7s271n30d84z-python3.12-tensorflow-2.18.0/lib/python3.12/site-packages/tensorflow/lite/python/interpreter.py", line 73, in __init__
Nov 20 16:18:59 aleph0 frigate[5661]: self._library = ctypes.pydll.LoadLibrary(library)
Nov 20 16:18:59 aleph0 frigate[5661]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Nov 20 16:18:59 aleph0 frigate[5661]: File "/nix/store/px2nj16i5gc3d4mnw5l1nclfdxhry61p-python3-3.12.7/lib/python3.12/ctypes/__init__.py", line 460, in LoadLibrary
Nov 20 16:18:59 aleph0 frigate[5661]: return self._dlltype(name)
Nov 20 16:18:59 aleph0 frigate[5661]: ^^^^^^^^^^^^^^^^^^^
Nov 20 16:18:59 aleph0 frigate[5661]: File "/nix/store/px2nj16i5gc3d4mnw5l1nclfdxhry61p-python3-3.12.7/lib/python3.12/ctypes/__init__.py", line 379, in __init__
Nov 20 16:18:59 aleph0 frigate[5661]: self._handle = _dlopen(self._name, mode)
Nov 20 16:18:59 aleph0 frigate[5661]: ^^^^^^^^^^^^^^^^^^^^^^^^^
Nov 20 16:18:59 aleph0 frigate[5661]: OSError: libedgetpu.so.1.0: cannot open shared object file: No such file or directory
Nov 20 16:18:59 aleph0 frigate[5661]: Exception ignored in: <function Delegate.__del__ at 0x7f93e7ef0540>
Nov 20 16:18:59 aleph0 frigate[5661]: Traceback (most recent call last):
Nov 20 16:18:59 aleph0 frigate[5661]: File "/nix/store/y7wsnapb7w8pqkifah4v7s271n30d84z-python3.12-tensorflow-2.18.0/lib/python3.12/site-packages/tensorflow/lite/python/interpreter.py", line 109, in __del__
Nov 20 16:18:59 aleph0 frigate[5661]: if self._library is not None:
Nov 20 16:18:59 aleph0 frigate[5661]: ^^^^^^^^^^^^^
Nov 20 16:18:59 aleph0 frigate[5661]: AttributeError: 'Delegate' object has no attribute '_library'
| 00:32:50 |
netpleb | hexa: is that error consistent with what your patch does? or did we patch the wrong thing (sorry that I do not know frigate/tensorflow/python codebase at all) | 00:34:56 |