Cant get Zoneminder to use CUDA

Previous development branch now released as 1.36
Locked
trumee
Posts: 69
Joined: Tue Mar 08, 2011 3:33 pm

Cant get Zoneminder to use CUDA

Post by trumee »

I am running Zoneminder v1.35.14 frm iconnor PPA. I have compiled ffmpeg with cuda support using options,

Code: Select all

./configure --enable-nonfree --enable-cuda-nvcc  --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --prefix=/opt/ffmpeg
and can confirm cuda is working

Code: Select all

$ /opt/ffmpeg/bin/ffmpeg -hwaccels
ffmpeg version N-99932-g17a0dfebf5 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --prefix=/opt/ffmpeg
  libavutil      56. 60.100 / 56. 60.100
  libavcodec     58.112.103 / 58.112.103
  libavformat    58. 64.100 / 58. 64.100
  libavdevice    58. 11.102 / 58. 11.102
  libavfilter     7. 90.100 /  7. 90.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
Hardware acceleration methods:
cuda
I tested ffmpeg on the camera and it uses 3% CPU which is significantly less than what ZM uses without CUDA.

Code: Select all

/opt/ffmpeg/bin/ffmpeg -hwaccel cuda -i "rtsp://admin:admin@192.168.1.1:554/cam/realmonitor?channel=1&subtype=0" -an -f rawvideo -y /dev/null
Unfortunately, I have not been able to get ZM working with CUDA. I changed PATH_FFMPEG option to my compiled version. Also, set DecoderHWAccelName to CUDA. However, still zmc is still using higher cpu.

Is there any way to find out whether ZM is using my ffmpeg instead of native one? ps -auxww does not show any ffmpeg. Wonder if ffmpeg is being used at all. The Camera source type is set to 'ffmpeg' with 'H264 passthrough'.
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: Cant get Zoneminder to use CUDA

Post by Magic919 »

If you run an lsof and look for zmc/zma you can see it using the underlying libraries.
-
User avatar
iconnor
Posts: 2881
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Cant get Zoneminder to use CUDA

Post by iconnor »

zoneminder will use the system libavcodec libraries and not your custom built ones. You would have to recompile zoneminder against your newer libs.

We recently did some testing on this and ffmpeg 4.1 wasn't working, but a docker upgrade to use ffmpeg 4.2 did work.
trumee
Posts: 69
Joined: Tue Mar 08, 2011 3:33 pm

Re: Cant get Zoneminder to use CUDA

Post by trumee »

1. I there any place i can get libavcodec with CUDA support?
2. Where does PATH_FFMPEG option fit in this discussion?
Magic919
Posts: 1381
Joined: Wed Sep 18, 2013 6:56 am

Re: Cant get Zoneminder to use CUDA

Post by Magic919 »

You must already have it as you compiled it.
-
trumee
Posts: 69
Joined: Tue Mar 08, 2011 3:33 pm

Re: Cant get Zoneminder to use CUDA

Post by trumee »

I would like to stick with the convenience of iconnor PPA rather than compiling my own zoneminder. Is there a PPA of Zoneminder and ffmpeg with cuda support?
trumee
Posts: 69
Joined: Tue Mar 08, 2011 3:33 pm

Re: Cant get Zoneminder to use CUDA

Post by trumee »

https://wiki.zoneminder.com/GPU_passthrough_in_VMWare page seems to suggest that 20.04 ships with CUDA enabled ffmpeg.

@iconnor Does your ZM package in 20.04 support CUDA?
User avatar
iconnor
Posts: 2881
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Cant get Zoneminder to use CUDA

Post by iconnor »

It does if the underlying ffmpeg libs do.
trumee
Posts: 69
Joined: Tue Mar 08, 2011 3:33 pm

Re: Cant get Zoneminder to use CUDA

Post by trumee »

Thanks. I moved to a Ubuntu 20.04 LXD container. CUDA works out of the box,

Code: Select all

$ nvidia-smi 
Sat Nov 21 03:46:59 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 455.38       Driver Version: 455.38       CUDA Version: 11.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GTX 1650    Off  | 00000000:05:00.0 Off |                  N/A |
| 35%   40C    P2    N/A /  75W |   2040MiB /  3911MiB |      2%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      5140      G   /usr/lib/Xorg                       4MiB |
|    0   N/A  N/A     17286      C   ...media/vzmlapi/bin/python3     1610MiB |
|    0   N/A  N/A    522239      C   /usr/bin/zmc                      137MiB |
|    0   N/A  N/A    522289      C   /usr/bin/zmc                      137MiB |
|    0   N/A  N/A    531994      C   /usr/bin/zmc                      145MiB |
+-----------------------------------------------------------------------------+
Locked