CPU charge to more than 100% with nvenc encoding.
Added by Fouad ToutCourt over 6 years ago
Hello everybody !
I have a rather strange problem that has appeared since a tvheadend update but now occure with all versions :
when I stream with transcoding (hardware nvenc with quadro m2000) the cpu utilization is over 100%.
After going back to a stable version of tvheadend 4.2 the problem persists. I suspect that ffmpeg is the source of this problem, because at each compilation a new version is downloaded.
Has anyone had this kind of problem ? I have not done any tests with an old version of ffmpeg yet. I only changed the CPU to see the result that is the same.
My old cpu was an intel celeron g3900 my new cpu is an i7-6700k and for the rest a nvidia quadro m2000, 16gb of ddr4, hdd 4tb, 2 cards tuner tbs6209, 1 hdmi capture card tbs6304.
Ubuntu server 16.4 is installed, I can't change my setup os because my computer hosts my forum server, my mail server.
P.S. : I have downgraded my tvheadend from 4.3.xxx to 4.2.6 because the epg grabber over the air (EIT) stopped working.
Thanks for your help.
Replies (9)
RE: CPU charge to more than 100% with nvenc encoding. - Added by saen acro over 6 years ago
When use Nvidia GPU use nvidia-smi to see is gpu used or no.
Are you use some repo or build tvh yourself?
RE: CPU charge to more than 100% with nvenc encoding. - Added by Fouad ToutCourt over 6 years ago
Thank you for your response, I did not know this tool it is very useful
Apparently the gpu is used (even if it is not much used) the tvheadend process is detected by nvidia-smi
NVIDIA-SMI 390.48 Driver Version: 390.48 GPU-Util 2% Processes: 1331 C /usr/local/bin/tvheadend memory usage 59MiB
I used the standard procedure :
Download the source from github https://github.com/tvheadend/tvheadend (4.3.xxx and 4.2 actualy 4.2.6)
download and copy nvEncodeAPI.h to /usr/include
I've tested many nvidia drivers
./configure --enable-nvenc
make && make install
There is no errors.
RE: CPU charge to more than 100% with nvenc encoding. - Added by Fouad ToutCourt over 6 years ago
At most I run stream at the most CPU load increases (see top screenshoot)
But this is very strange : At the same time the cpu load increases, the gpu seems to be sollicited.
1) As you can see on the image (gpu usage.png) the profile of power is set to P0 (P8 when idle or when there is no stream encode)
2) Energy consumption increases (~10w when idle)
3) GPU usage 0% o_O why ?
4) GPU ram usage increases (~10mb when no activity)
5) You can see tvheadend is here.
Formerly I could run 10 streams simultaneously with a poor celeron
cpu load with 3 streams.png (169 KB) cpu load with 3 streams.png | |||
gpu usage.png (14 KB) gpu usage.png | |||
cpu load with 3 streams.png (169 KB) cpu load with 3 streams.png | |||
gpu usage.png (14 KB) gpu usage.png |
RE: CPU charge to more than 100% with nvenc encoding. - Added by saen acro over 6 years ago
Make picture of tvheadend config profile
hint
when use TOP press "1" to see cores load
or for to be more easy use HTOP
nvidia-smi interactive version command
watch -d nvidia-smi
RE: CPU charge to more than 100% with nvenc encoding. - Added by Fouad ToutCourt over 6 years ago
Thank you for your valuable answers, I discover new things :)
I have 3 profils nvenc.
Can a change of dvb drivers cause these kinds of problems ? Can we do without vaapi support ?
I will try to install an old version of linux and start from scratch on another machine.
Thank you very much for your help.
RE: CPU charge to more than 100% with nvenc encoding. - Added by Fouad ToutCourt over 6 years ago
Hello everybody !
After testing different versions of ubuntu, drivers and tvheadend, I finally found that the problem came from elsewhere, I suspected a little. I encounter the same problem when I want to convert a video with ffmpeg.
I use the minimal parameters (input format video codec output). Any ideas ?
The "hwaccel cuvid c:v h264_cuvid" parameters offers the same performance with much less CPU power :-)
it looks like it is decoding that requires a lot of CPU resources and not encoding. how to integrate cuvid and nvdec in tvheadend?
htopffmpeg.png (56.6 KB) htopffmpeg.png | |||
nvidia-smi.png (13.8 KB) nvidia-smi.png |
RE: CPU charge to more than 100% with nvenc encoding. - Added by saen acro over 6 years ago
"NVENChd|720p-2Mbit|GPU:0 ffmpeg -fflags +genpts -user_agent NVidia_Transcode -nostats -nostdin -hide_banner -loglevel quiet -hwaccel cuvid -c:v h264_cuvid -deint 1 -surfaces 8 -drop_second_field 1 -vsync 0 -resize 1280x720 -i -map 0:v -c:v h264_nvenc -preset slow -profile:v high -level 4.1 -rc vbr -cq 1 -bf 2 -g 25 -b:v 2200k -minrate 2200k -maxrate 2200k -bufsize 1002k -map 0:a -c:a libfdk_aac -ac 2 -b:a 128k -strict experimental" "NVENChd|720p-2Mbit|GPU:1 ffmpeg -fflags +genpts -user_agent NVidia_Transcode -nostats -nostdin -hide_banner -loglevel quiet -gpu 1 -hwaccel cuvid -c:v h264_cuvid -deint 1 -surfaces 8 -drop_second_field 1 -vsync 0 -resize 1280x720 -i -map 0:v -c:v h264_nvenc -preset slow -profile:v high -level 4.1 -rc vbr -cq 1 -bf 2 -g 25 -b:v 2200k -minrate 2200k -maxrate 2200k -bufsize 1002k -map 0:a -c:a libfdk_aac -ac 2 -b:a 128k -strict experimental" "NVENChd|720p-2Mbit|subs ffmpeg -fflags +genpts -user_agent NVidia_Transcode -nostats -nostdin -hide_banner -loglevel quiet -hwaccel cuvid -c:v h264_cuvid -deint 1 -surfaces 8 -drop_second_field 1 -vsync 0 -canvas_size 720x576 -resize 1280x720 -i -filter_complex [0:v]hwdownload!format=nv12[base];[0:s:0]scale=1280:720[subtitle];[base][subtitle]overlay[v];[v]hwupload_cuda[v] -map [v] -c:v h264_nvenc -preset slow -profile:v high -level 4.1 -rc vbr -cq 1 -bf 2 -g 25 -b:v 2200k -minrate 2200k -maxrate 2200k -bufsize 1002k -map 0:a -c:a libfdk_aac -ac 2 -b:a 128k -strict experimental" "NVENCsd-2Mbit ffmpeg -fflags +genpts -user_agent NVidia_Transcode -nostats -nostdin -hide_banner -loglevel quiet -hwaccel cuvid -c:v mpeg2_cuvid -deint 2 -surfaces 8 -drop_second_field 1 -vsync 0 -i -map 0:v -c:v h264_nvenc -preset slow -profile:v high -level 4.1 -rc vbr -cq 1 -bf 2 -g 25 -no-scenecut 1 -forced-idr 0 -b:v 1808k -minrate 1808k -maxrate 1808k -bufsize 904k -map 0:a -c:a libfdk_aac -ac 2 -b:a 128k -strict experimental"
ffmpeg-release-64bit-static.tar.xz needed
https://johnvansickle.com not provide it anymore
so you need to build it yourself
./ffmpeg -hide_banner -buildconf -hwaccels configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libfribidi --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libzimg ./ffmpeg -hide_banner -hwaccels Hardware acceleration methods: vaapi cuvid
RE: CPU charge to more than 100% with nvenc encoding. - Added by Fouad ToutCourt over 6 years ago
Thank you for your help. I've already compiled the latest ffmpeg with the necessary codecs x264 x265 and encoders/decoders nvenc/nvdec/cuvid and with the support of vdpau/vaapi
Is it possible to create a custom profil codec in tvheadend other than proposed in webinterface with the presets that you mentionned ?
RE: CPU charge to more than 100% with nvenc encoding. - Added by saen acro over 6 years ago
Not possible in UI for now
Just Spawn profile for now.