-
Notifications
You must be signed in to change notification settings - Fork 120
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
New rknn detector not working on home assistant add on. #145
New rknn detector not working on home assistant add on. #145
Comments
thanks for the logs, I hope #146 will fix this |
Hello, I see the fix is already merged and I was able to re-install updated frigate HA Addon. However I still get the same error as stated above. (using odroid M1 with rockchip 3568) in addition to this when I try to run it without rknn detector I get ffmpeg failure as also seen in the screenshot bellow: here is my config birdseye: detectors: cameras: |
It's possible running as an addon may be more complicated due to needing access to the devices hardware |
@MarcA711 we are going to need to get some more info from users here, based on the addon config docs I think the device tree may be mounted as |
unfortunately the files needed for ffmpeg also seem to be missing, we may need to make the rockchip addon beta only for 0.13 while we work out if the addon will be possible |
It does mount on the /device-tree folder. Isn`t it better to mount the volume directly from supervisor.sh ? I dont realy know if it works.
|
That's not in the addon's control. If it is mounted in device-tree then the rknn detector should simply check both locations |
Thank you for reporting. Unfortunately, I don't have home assistant installed and can't do so, because I have only remote access to my machine. I wonder why the detector can't find /proc/device-tree/compatible even though the directory was mounted into the container. Maybe it is a permission issue? |
I think issue is as Nick shared, addons are very limited to what they can get access to. if I understand right frigate addon for rockchip is using "full_access" mode and still seem to have issues. if I could be of any help to retrieve useful info let me know. |
Ah, so I got it wrong. The issue is not that the rknn plugin can't open the /proc/device-tree/compatible file. The problem is that docker is not able to mount this file to the container. Is this right? |
I think is does mount Any chance of changing the mais frigate code to use the same folder as home assistant ? |
Ah okay, now I got it. I could change my code to also check /device-tree/compatible if there is no file in /proc/device-tree/compatible. However, the rknn detector also needs this file and I think it searches only in /proc/device-tree/compatible. Therefore I propose the following solution:
Is this possibly the way to handle this? Edit: |
I think this could work. Any idea if this will get on the 13 beta 6/7 version or just after 13.0 release ? |
Yes, it should also work using this mount. I will try to update the code to avoid this issue. |
Simbolic link workaround is not working, I cannot overwrite existing one /proc/device-tree and it links a non existing folder into a read only file system.
Any other option? |
@juanjoSanz what about |
Try creating the symbolic link for the folder instead |
@pedrol3001 you can try this as well by the way, just need to run |
From docker shell this is not modificable:
|
I am testing other approach:
|
Maybe changing the privileged mode on the confi.yaml enable us to change this file system? I couldn`t find any documentation on what it exactly does. I can see 2 option here, but none of them works because of the permission inside docker:
|
it is documented at https://developers.home-assistant.io/docs/add-ons/configuration#optional-configuration-options only one I can think of is SYS_ADMIN |
This can be reopened, I didn't expect that my comment on the PR would close the issue |
after being sure to update the addon and making sure that protected mode is disabled, would be good to know if anything has changed |
Nothing has changed... |
@MarcA711 Tried to git clone & copy the frigate rochchip folder to /usr/share/hassio/addons folder I can get Hardware acceleration working, but not npu. |
Hey @nyok92, Thanks a lot for testing! This is great news, it worked as expected and at least hardware video processing works now. Otherwise, try adding: However, I am not sure if it is possible to apply these changes. |
@MarcA711 From host working with: but not seen on HASS Addons UI (somehow not linked to HASS supervisor), should be as expected as this has not been launched from HASS supervisor |
This is great. This means the Home Assistant devs only need to add an option to the addon config to add the option |
i've seen this (is in my issue in haos i think) but effectively is on old kernel...not in mainline... |
Всем привет, попытался всё сделать по инструкции, добавил фрегат рокчип в список аддонов и установил. Но при настройки камеры вылазит ошибка с ffmpeg. В командной строке orangepi 5 есть проблема с этими пакетами: Есть идеи как можно исправить? |
Hi ! I have board OrangePi 5, installed deb 12, installed HOAS supervised. The whole problem is that the container in the addon is launched in unprivileged mode, if you launch the container in privileged mode through the terminal, then everything works out of the box. Trying to run "docker run -it --rm --publish=5000:5000 --security-opt systempaths=unconfined --security-opt apparmor=unconfined -v /usr/share/hassio/addons/local/frigate-rockchipOpi5- dev/config:/config -v /sys/firmware/devicetree/base:/sys/firmware/devicetree/base #########"solves the issue with device-tree, but there are other errors with "MPP". mpp[792]: mpp_info: mpp version: 1844ec5 author: MarcA711 2023-11-12 add -lstdc++ to Libs.private mpp[792]: mpp_rt: can NOT found any allocator mpp[792]: mpp_log: allocator_std_open Warning: std allocator should be used on simulation mode only mpp[792]: mpp_allocator: mpp_allocator_get type 1 failed mpp[792]: mpp_buffer: Assertion p->allocator failed at get_group:936 mpp[792]: mpp_buffer: Assertion p->alloc_api failed at get_group:937 mpp[792]: vcodec_service: open vcodec_service (null) failed mpp[792]: hal_h265d_api: mpp_dev_init failed ret: -1 mpp[792]: mpp_hal: mpp_hal_init hal h265d_rkdec init failed ret -1 mpp[792]: mpp_hal: mpp_hal_init could not found coding type 16777220 mpp[792]: mpp_dec: mpp_dec_init could not init hal mpp[792]: mpp_time: mpp_clock_put invalid clock (nil) To summarize, the simplest method would be if the Home Assist developers added the ability to run a container in the add-on in privileged mode. |
in the course of the conversation root@hass:~# docker run -it --rm --publish=5000:5000 --security-opt systempaths=unconfined --security-opt apparmor=unconfined -v /uhare/hassio/addons/local/frigate-rockchipOpi5-dev/config:/config -v /sys/firmware/devicetree/base:/sys/firmware/devicetree/base -v /dri:/dev/dri ########## s6-rc: info: service s6rc-fdholder: starting s6-rc: info: service s6rc-oneshot-runner: starting s6-rc: info: service s6rc-oneshot-runner successfully started s6-rc: info: service fix-attrs: starting s6-rc: info: service s6rc-fdholder successfully started s6-rc: info: service fix-attrs successfully started s6-rc: info: service legacy-cont-init: starting s6-rc: info: service legacy-cont-init successfully started s6-rc: info: service log-prepare: starting s6-rc: info: service log-prepare successfully started s6-rc: info: service nginx-log: starting s6-rc: info: service go2rtc-log: starting s6-rc: info: service frigate-log: starting s6-rc: info: service frigate-log successfully started s6-rc: info: service nginx-log successfully started s6-rc: info: service go2rtc-log successfully started s6-rc: info: service go2rtc: starting s6-rc: info: service go2rtc successfully started s6-rc: info: service go2rtc-healthcheck: starting s6-rc: info: service frigate: starting s6-rc: info: service frigate successfully started s6-rc: info: service nginx: starting s6-rc: info: service nginx successfully started 2024-02-11 20:41:20.131192270 [INFO] Preparing Frigate... 2024-02-11 20:41:20.132533620 [INFO] Starting NGINX... s6-rc: info: service go2rtc-healthcheck successfully started s6-rc: info: service legacy-services: starting 2024-02-11 20:41:20.136112014 [INFO] Preparing new go2rtc config... s6-rc: info: service legacy-services successfully started 2024-02-11 20:41:20.179971475 [INFO] Starting Frigate... 2024-02-11 20:41:20.770805467 [INFO] Starting go2rtc... 2024-02-11 20:41:20.892877728 20:41:20.892 INF go2rtc version 1.8.4 linux/arm64 2024-02-11 20:41:20.893461926 20:41:20.893 INF [rtsp] listen addr=:8554 2024-02-11 20:41:20.893836419 20:41:20.893 INF [api] listen addr=:1984 2024-02-11 20:41:20.893846044 20:41:20.893 INF [webrtc] listen addr=:8555 2024-02-11 20:41:22.679752320 [2024-02-11 20:41:22] frigate.app INFO : Starting Frigate (0.13.0-fdecad4) 2024-02-11 20:41:22.680058564 [2024-02-11 20:41:22] frigate.app INFO : Creating directory: /media/frigate/reings 2024-02-11 20:41:22.680453182 [2024-02-11 20:41:22] frigate.app INFO : Creating directory: /media/frigate/cl 2024-02-11 20:41:22.680514140 [2024-02-11 20:41:22] frigate.app INFO : Creating directory: /tmp/cache 2024-02-11 20:41:22.680695553 [2024-02-11 20:41:22] frigate.app INFO : Creating directory: /media/frigate/exs 2024-02-11 20:41:22.714361739 [2024-02-11 20:41:22] peewee_migrate.logs INFO : Starting migrations 2024-02-11 20:41:22.722846169 [2024-02-11 20:41:22] peewee_migrate.logs INFO : There is nothing to migrate 2024-02-11 20:41:22.735119573 [2024-02-11 20:41:22] frigate.app INFO : Recording process started: 454 2024-02-11 20:41:22.739487203 [2024-02-11 20:41:22] frigate.app INFO : go2rtc process pid: 89 2024-02-11 20:41:22.807944804 [2024-02-11 20:41:22] detector.rknn INFO : Starting detection process: 464 2024-02-11 20:41:22.812570555 [2024-02-11 20:41:22] frigate.app INFO : Output process started: 466 2024-02-11 20:41:22.839255824 [2024-02-11 20:41:22] frigate.app INFO : Camera processor started for cam_1: 4 2024-02-11 20:41:22.853247406 [2024-02-11 20:41:22] frigate.app INFO : Capture process started for cam_1: 47 2024-02-11 20:41:23.367910310 E RKNN: [20:41:23.367] failed to open rknpu module, need to insmod rknpu dirver! 2024-02-11 20:41:23.368231138 E RKNN: [20:41:23.367] failed to open rknn device! 2024-02-11 20:41:23.469635104 E Catch exception when init runtime! 2024-02-11 20:41:23.474013526 E Traceback (most recent call last): 2024-02-11 20:41:23.474030442 File "/usr/local/lib/python3.9/dist-packages/rknnlite/api/rknn_lite.py", line 148, in init_runtime 2024-02-11 20:41:23.474053483 self.rknn_runtime.build_graph(self.rknn_data, self.load_model_in_npu) 2024-02-11 20:41:23.474067483 File "rknnlite/api/rknn_runtime.py", line 875, in rknnlite.api.rknn_runtime.RKNNRuntime.build_grap 2024-02-11 20:41:23.474141273 Exception: RKNN init failed. error code: RKNN_ERR_FAIL 2024-02-11 20:41:23.474147398 2024-02-11 20:41:23.481709887 [2024-02-11 20:41:23] frigate.detectors.plugins.rknn E : Error initializing rknn runtime. Do yun docker in privileged mode? mpp[477]: mpp_info: mpp version: 1844ec5 author: MarcA711 2023-11-12 add -lstdc++ to Libs.private mpp[477]: mpp_rt: can NOT found any allocator mpp[477]: mpp_log: allocator_std_open Warning: std allocator should be used on simulation mode only mpp[477]: mpp_allocator: mpp_allocator_get type 1 failed mpp[477]: mpp_buffer: Assertion p->allocator failed at get_group:936 mpp[477]: mpp_buffer: Assertion p->alloc_api failed at get_group:937 mpp[477]: vcodec_service: open vcodec_service (null) failed mpp[477]: hal_h265d_api: mpp_dev_init failed ret: -1 mpp[477]: mpp_hal: mpp_hal_init hal h265d_rkdec init failed ret -1 mpp[477]: mpp_hal: mpp_hal_init could not found coding type 16777220 mpp[477]: mpp_dec: mpp_dec_init could not init hal mpp[477]: mpp_time: mpp_clock_put invalid clock (nil) mpp[477]: mpp_time: mpp_clock_put invalid clock (nil) mpp[477]: mpp_time: mpp_clock_put invalid clock (nil) mpp[477]: mpp_time: mpp_clock_put invalid clock (nil) |
Hey @YuryMcv, I guess the Home Assistant devs left out the option to run add-ons in privileged mode on purpose for security reasons. And I don't think they will add it. I guess there are some capabilities and security options that one can add in order to allow containers to access the hardware devices. I will do some research and see if I am able to run it on my system without privileged mode. |
Hey @Ra3eR63, I have problems understanding your setup and issue. Are you using HA supervised? Please check if your Kernel has the required drivers using:
|
Hey @MarcA711, I'm also exploring the possibility of running it in normal mode, to understand what settings are needed for this. At the moment, you can only access the device tree with " --security-opt systempaths=unconfined --security-opt apparmor=unconfined" and mount "/sys/firmware/devicetree/base:/sys/firmware/devicetree/base", Otherwise it doesn't work. Next, I look at what other configuration is needed for a successful launch. As for launching the add-on in privileged mode, you need to ask the Home Assist developers what they think about this. |
I guess you don't need this mount: "/sys/firmware/devicetree/base:/sys/firmware/devicetree/base" The option: --security-opt systempaths=unconfined should mount it automatically |
Привет @Ra3eR63 , Проверки что написал MarcA711 надо сделать из контейнера, |
@YuryMcv Забавно, но я не успеваю это сделать) Айди контейнера меняется с какой-то супер скоростью)) |
@Ra3eR63 Это значит контейнер останавливается. посмотрите логи фрегата, рекомендую пока использовать фрегат с CPU |
@MarcA711 yes, the option is really enough: --security-opt systempaths=unconfined --security-opt apparmor=unconfined, I previously tried to use it but for some reason it didn’t work, apparently I made some mistake. 2024-02-12 14:45:17.901981929 E RKNN: [14:45:17.901] failed to open rknpu module, need to insmod rknpu dirver! 2024-02-12 14:45:17.902072636 E RKNN: [14:45:17.902] failed to open rknn device! 2024-02-12 14:45:18.003171540 E Catch exception when init runtime! 2024-02-12 14:45:18.006222319 E Traceback (most recent call last): 2024-02-12 14:45:18.006239818 File "/usr/local/lib/python3.9/dist-packages/rknnlite/api/rknn_lite.py", line 148, in init_runtime 2024-02-12 14:45:18.006260526 self.rknn_runtime.build_graph(self.rknn_data, self.load_model_in_npu) 2024-02-12 14:45:18.006272484 File "rknnlite/api/rknn_runtime.py", line 875, in rknnlite.api.rknn_runtime.RKNNRuntime.build_graph 2024-02-12 14:45:18.006350941 Exception: RKNN init failed. error code: RKNN_ERR_FAIL |
rknn detector works using these options: |
Using these options rknpu and ffmpeg using hardware works: |
Moreover, Home Assistant Addons already support the |
@MarcA711 So what is better to use for testing, leave the rockchip addon for homeassistant or build a container in docker from your repository? And configure it in the home assistant via a proxy frigate? |
The Home Assistant Addon will not work until this got fixed: home-assistant/supervisor#4863 |
doesn't work unfortunately, same error 2024-02-12 19:35:55.670507576 E RKNN: [19:35:55.670] failed to open rknpu module, need to insmod rknpu dirver! 2024-02-12 19:35:55.670597116 E RKNN: [19:35:55.670] failed to open rknn device! 2024-02-12 19:35:55.771905809 E Catch exception when init runtime! 2024-02-12 19:35:55.775398747 E Traceback (most recent call last): 2024-02-12 19:35:55.775412746 File "/usr/local/lib/python3.9/dist-packages/rknnlite/api/rknn_lite.py", line 148, in init_runtime 2024-02-12 19:35:55.775469329 self.rknn_runtime.build_graph(self.rknn_data, self.load_model_in_npu) 2024-02-12 19:35:55.775485953 File "rknnlite/api/rknn_runtime.py", line 875, in rknnlite.api.rknn_runtime.RKNNRuntime.build_graph 2024-02-12 19:35:55.775591535 Exception: RKNN init failed. error code: RKNN_ERR_FAIL 2024-02-12 19:35:55.775595618 2024-02-12 19:35:55.781402015 [2024-02-12 19:35:55] frigate.detectors.plugins.rknn E : Error initializing rknn runtime. Do you run docker in privileged mode? |
Looks like there are not enough permissions, privileged mode makes changes to cgroup |
Maybe the problem is a missing capability. Try adding: If this does not work, try adding |
I already tried this, it didn't help. Exactly the same error is caused by launching rknpu without sudo |
This issue was accidently closed, but the problem has still not been solved. It should be reopened. This issue depends on home-assistant/supervisor#4863. Unfortunately, I don't know if the developers have time to add this feature in the near future. This blocks the Rockchip addon. I think the fix is quite simple. We need to add an option I am not very familiar with the Home Assistant source code, and I have currently no time to work on this. Maybe someone is interested in contributing this feature. This could perhaps speed things up a bit. I am not sure if this solves the issue completely (maybe there are some other changes necessary) but I am quite convinced that this would be a big step in finally having a rockchip addon in HA. |
Description
I can`t start the add on on 13 beta-6 version when testing the new rknn detector. I am using an orangepi 5 with a Rockchip RK3588S. But i gives the following error when starting.
The file does exists from a ssh connection to the orangepi, but i don`t know if is really a bug or i am missing any configuration to make the docker container access this file (I already disabled protection mode).
The text was updated successfully, but these errors were encountered: