raspi-cam-srv
raspi-cam-srv copied to clipboard
Package it in Docker / `docker-compose.yml`
Hello,
Any way that the project would have a docker-compose.yml for easy deployment?
Hi, thanks for this suggestion.
This is on my ToDo list since long.
Hi, so far, my effort to containerize this application was not (yet?) successful. See picamera2 issue 1216 - picamera2 in Docker - Cannot allocate memory The issue is that cameras use CMA memory and I currently do not know how this can be allocated by Docker. (Just got the answer that Pi 5 does not use CMA but I/O MMU)
In the test application mentioned in Issue 1216 it is seen that it works for small image sizes but it fails for larger ones as for the Model 3 camera, even for just taking a photo, not to talk about video recording.
If this cannot be resolved, it is unlikely that containerizing raspiCamSrv can be successful.
Also, I did not find any Docker projects using picamera2, except for very specific ones and demo cases. If you know some, please tell me.
Heya,
Have you tried adding:
shm_size: '1gb'
deploy:
resources:
limits:
memory: '2g' # with zram if not enough memory
and see how it goes?
Also is dmesg printing anything special?
Hi thanks for your suggestion.
However, the result is the same as before, except for the error message
! picamera2-test Your kernel does not support memory limit capabilities or the cgroup is not mounted. Limitation discarded.
Since docker info also reports
..
WARNING: No memory limit support
WARNING: No swap limit support
this is probably to be expected.
dmesg sais, among others:
cma: cma_alloc: linux,cma: alloc failed, req-size: 729 pages, ret: -12
cat /proc/meminfo shows:
...
CmaTotal: 65536 kB
CmaFree: 49056 kB
Since, according to the picamera2-manual ch. 8.3, the 12MP Model 3 image requires 48 MB, this will probably be the bottleneck.
I increased cma by replacing
dtoverlay=vc4-kms-v3d
with
dtoverlay=vc4-kms-v3d,cma-512
in /boot/firmware/config.txt
Now, after reboot, I have:
CmaTotal: 524288 kB
CmaFree: 507808 kB
Now, the Cannot allocate memory error is gone when running the docker container with the Model 3 camera and a 12MP image is created.
This looks promising. I'll continue trying
Hi, if you like, you can try using Docker as described in Running raspiCamSrv as Docker Container
This has been added in V2.13.
Up to now, I have tested it on a Pi 5 and a Pi 4.