Envec h264 encoding does not work with GTX 1660Ti/1660 Super with Ubuntu Linux 22.04

I used to run OBS and ffmpeg on Ubuntu 21.10 and older ubuntu linux distribution on
21.10 the Nvidia 470 is working and I can run OBS for streaming and Davinci Resolve 18 fine.
But lifetime is ower for 21.10 kernal and was force to update my Linux.

I can install Nvidia 470 and even Nvidia 510 on Ubuntu 22.04 - I have tried Mint, PopOs and none of them allows me to do any encoding like I was able to do on ubunto 21.10 so I am very sad I can enjoy the cards with newer Ubuntu 22.04 LTS every thing else is working fine.

The ffmpeg is and OBS is from the normal ppa repositori - the bug or problem maybe only on GTX 1660 ti and the GTX 1660 super.

Any sugestions on how to solve this ?

I installed the sudo apt install nvidia-modprobe as it was not installed

I can se lsmod the nvidia-uvm module is loaded

When i try get this error

dl_fn->cuda_dl->cuInit(0) failed → CUDA_ERROR_SYSTEM_NOT_READY: system not yet initialized
warning: [NVENC encoder: ‘streaming_h264’] Failed to open NVENC codec: Unknown error occurred

or

nfo: ------------------------------------------------
info: ---------------------------------
info: [NVENC encoder: ‘recording_h264’] settings:
rate_control: CBR
bitrate: 2500
cqp: 0
keyint: 50
preset: hq
profile: high
width: 1920
height: 1080
2-pass: false
b-frames: 2
psycho-aq: 0
GPU: 0

[h264_nvenc @ 0x5579fc2c5b40] The selected preset is deprecated. Use p1 to p7 + -tune or fast/medium/slow.
[h264_nvenc @ 0x5579fc2c5b40] dl_fn->cuda_dl->cuInit(0) failed → CUDA_ERROR_SYSTEM_NOT_READY: system not yet initialized

Please run nvidia-bug-report.sh as root and attach the resulting nvidia-bug-report.log.gz file to your post.

I installed the sudo apt install nvidia-modprobe as it was not installed

I can se lsmod the nvidia-uvm module is loaded

When i try get this error

dl_fn->cuda_dl->cuInit(0) failed → CUDA_ERROR_SYSTEM_NOT_READY: system not yet initialized
warning: [NVENC encoder: ‘streaming_h264’] Failed to open NVENC codec: Unknown error occurred

or

nfo: ------------------------------------------------
info: ---------------------------------
info: [NVENC encoder: ‘recording_h264’] settings:
rate_control: CBR
bitrate: 2500
cqp: 0
keyint: 50
preset: hq
profile: high
width: 1920
height: 1080
2-pass: false
b-frames: 2
psycho-aq: 0
GPU: 0

[h264_nvenc @ 0x5579fc2c5b40] The selected preset is deprecated. Use p1 to p7 + -tune or fast/medium/slow.
[h264_nvenc @ 0x5579fc2c5b40] dl_fn->cuda_dl->cuInit(0) failed → CUDA_ERROR_SYSTEM_NOT_READY: system not yet initialized

nvidia-bug-report.log.gz (298.6 KB)

Nothing unusual. Please post the output of
ls -l /dev/nvid*

Forget about it, found the reason:

00:00.0 RAM memory: NVIDIA Corporation MCP61 Host Bridge (rev a1)
	Subsystem: ASUSTeK Computer Inc. M4N68T series motherboard

You have an old board with an nvidia chipset. For whatever reasons, cuda broke on those after ~460 driver.
Seemingly not fixed in latest driver, did you try with that?

ls -l /dev/nvid*
crw-rw-rw- 1 root root 195, 0 aug 9 20:11 /dev/nvidia0
crw-rw-rw- 1 root root 195, 255 aug 9 20:11 /dev/nvidiactl
crw-rw-rw- 1 root root 195, 254 aug 9 20:11 /dev/nvidia-modeset
crw-rw-rw- 1 root root 234, 0 aug 9 20:11 /dev/nvidia-uvm
crw-rw-rw- 1 root root 234, 1 aug 9 20:11 /dev/nvidia-uvm-tools

/dev/nvidia-caps:
total 0
cr-------- 1 root root 237, 1 aug 9 20:26 nvidia-cap1
cr–r–r-- 1 root root 237, 2 aug 9 20:26 nvidia-cap2

Well I have another computer with another board also gtx1660 super and this have the same problems bug
Also the M4N68T have been working before with ubuntu 21.10 and running obs with the nvidia 470 but I was forced to update to as the 21.10 is not supported anymore.

Odd. What cpu/chipset has the other system?

I installed the sudo apt install nvidia-modprobe as it was not installed

I can se lsmod the nvidia-uvm module is loaded

When i try get this error

dl_fn->cuda_dl->cuInit(0) failed → CUDA_ERROR_SYSTEM_NOT_READY: system not yet initialized
warning: [NVENC encoder: ‘streaming_h264’] Failed to open NVENC codec: Unknown error occurred

or

nfo: ------------------------------------------------
info: ---------------------------------
info: [NVENC encoder: ‘recording_h264’] settings:
rate_control: CBR
bitrate: 2500
cqp: 0
keyint: 50
preset: hq
profile: high
width: 1920
height: 1080
2-pass: false
b-frames: 2
psycho-aq: 0
GPU: 0

[h264_nvenc @ 0x5579fc2c5b40] The selected preset is deprecated. Use p1 to p7 + -tune or fast/medium/slow.
[h264_nvenc @ 0x5579fc2c5b40] dl_fn->cuda_dl->cuInit(0) failed → CUDA_ERROR_SYSTEM_NOT_READY: system not yet initialized

I have even run older Davincy Resolve 15 on the M4N68T boad with the GTX 1660 TI and possible nvidia 450/460 driver but I cant remeber what chipset on the other system but its intel i7 with the gtx 1660 super and it running nvidia 470 but - if I upgrade this to newer ubuntu 22.04 I will have the same problems with my gtx cards - it maybe old hardware but Davincy Resolve 18 need more memory than the old 15 needed.
Anyway the computer with M4N68T is mainly used for OBS SRT input streams and NDI and then outgoing streams. The only problem is when I try to record or stream every thing else is working fine.

Since it’s an i7, the chipset should be fairly usual, so no issues to expect there .

I have been running and enjoyed the h264_nvenc encoding from Ubuntu 18 to 21.10 using kdenlive rendering and or ffmpeg it have been working with this motherbord so it very strange this not work anymore so I think something have been changed - I don’t know if I change to windows and windows drivers if it would work but it can see its nvidia but the dl_fn->cuda_dl->cuInit(0) failed → CUDA_ERROR_SYSTEM_NOT_READY: system not yet initialized must be a hint on why the gtx 1660 is not working as it have been working before.

I can download ubuntu the 21.10 but its EOL so its not a good solution today.

Usually, CUDA_ERROR_SYSTEM_NOT_READY is only displayed on nvswitch systems where the fabric-manager is not running. So I suspect the driver falsely detects the nvidia chipset as nvswitch system.

1 Like

Also its little strange that the nvidia 470 on 21.10 is working but the same 470 driver does not work on 22.04 LTS but like you can see everything is working fine from the logs but not the encoding part - decoding must be working as NDI and SRT input works fine also using hardware. - I don’t know if other nvidia cards may work more perfect using the encoding part.

Maybe I should try to recompile the ffmpeg but if I do
sudo apt install nvidia-cuda-toolkit it will unistall my nvidia470 driver and force me to nvidia515
and also don’t remeber to have all the cuda stuff when I compiled ffmpeg on older linux versions.

I tried this
ffmpeg -y -hwaccel cuda -i 2022-08-09\ 17-12-07.mkv out.mp4

ffmpeg version 4.4.2-0ubuntu0.22.04.1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 11 (Ubuntu 11.2.0-19ubuntu1)
configuration: --prefix=/usr --extra-version=0ubuntu0.22.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Input #0, matroska,webm, from ‘2022-08-09 17-12-07.mkv’:
Metadata:
ENCODER : Lavf58.76.100
Duration: 00:00:05.56, start: 0.000000, bitrate: 9911 kb/s
Stream #0:0: Video: h264 (High), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1k tbn, 50 tbc (default)
Metadata:
DURATION : 00:00:05.560000000
Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp (default)
Metadata:
title : simple_aac
DURATION : 00:00:05.440000000
[AVHWDeviceContext @ 0x56409abbac40] cu->cuInit(0) failed → CUDA_ERROR_SYSTEM_NOT_READY: system not yet initialized
Device creation failed: -1313558101.
[h264 @ 0x56409aa857c0] No device available for decoder: device type cuda needed for codec h264.
Stream mapping:
Stream #0:0#0:0 (h264 (native) → h264 (libx264))
Stream #0:1#0:1 (aac (native) → aac (native))
Device setup failed for decoder on input stream #0:0 : Unknown error occurred

Make sure you have recent nv-codec-headers installed when you compile ffmpeg

1 Like

You need to compile ffmpeg with this option (–enable-nvenc) and with nv-codec-headers installed.

1 Like
$ ffmpeg -encoders |grep nvenc
ffmpeg version 5.1 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 12 (GCC)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --docdir=/usr/share/doc/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection' --extra-ldflags='-Wl,-z,relro -Wl,--as-needed -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 ' --extra-cflags=' -I/usr/include/rav1e' --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-amrwbenc --enable-version3 --enable-bzlib --disable-crystalhd --enable-fontconfig --enable-frei0r --enable-gcrypt --enable-gnutls --enable-ladspa --enable-libaom --enable-libdav1d --enable-libass --enable-libbluray --enable-libbs2b --enable-libcdio --enable-libdrm --enable-libjack --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libilbc --enable-libmp3lame --enable-libmysofa --enable-nvenc --enable-openal --enable-opencl --enable-opengl --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librav1e --enable-librtmp --enable-librubberband --enable-libsmbclient --enable-version3 --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtesseract --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libv4l2 --enable-libvidstab --enable-libvmaf --enable-version3 --enable-vapoursynth --enable-libvpx --enable-vulkan --enable-libglslang --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libxml2 --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-avfilter --enable-libmodplug --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-lto --enable-libmfx --enable-runtime-cpudetect
  libavutil      57. 28.100 / 57. 28.100
  libavcodec     59. 37.100 / 59. 37.100
  libavformat    59. 27.100 / 59. 27.100
  libavdevice    59.  7.100 / 59.  7.100
  libavfilter     8. 44.100 /  8. 44.100
  libswscale      6.  7.100 /  6.  7.100
  libswresample   4.  7.100 /  4.  7.100
  libpostproc    56.  6.100 / 56.  6.100
 V....D h264_nvenc           NVIDIA NVENC H.264 encoder (codec h264)
 V....D hevc_nvenc           NVIDIA NVENC hevc encoder (codec hevc)