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

OK recompile the ffmpeg is possible no problem but it still not working.
I used this GitHub - markus-perl/ffmpeg-build-script: The FFmpeg build script provides an easy way to build a static FFmpeg on OSX and Linux with non-free codecs included.

  • In OBS the log says
    4:52:14.942: [NVENC encoder: ‘recording_h264’] Failed to open NVENC codec: Unknown error occurred
    14:59:51.656: Settings changed (outputs)
    14:59:51.656: ------------------------------------------------
    14:59:54.938: ---------------------------------
    14:59:54.939: [NVENC encoder: ‘recording_h264’] settings:
    14:59:54.939: rate_control: CBR
    14:59:54.939: bitrate: 2500
    14:59:54.939: cqp: 0
    14:59:54.939: keyint: 50
    14:59:54.939: preset: hq
    14:59:54.939: profile: high
    14:59:54.939: width: 1920
    14:59:54.939: height: 1080
    14:59:54.939: 2-pass: false
    14:59:54.939: b-frames: 2
    14:59:54.939: psycho-aq: 0
    14:59:54.939: GPU: 0
    14:59:54.939:
    14:59:54.947: [NVENC encoder: ‘recording_h264’] Failed to open NVENC codec: Unknown error occurred

I dont know what is brooken with nvenc from the 21.10 to the 22.04LTS - its a clean install so it looks like have to use the 21.10 even if its EOL very strange the encoding is just gone away.

LOL, you shouldn’t need nvcc to be installed to compile nvenc support.

Does this command return a path? (which nvcc).

1 Like

No which nvcc does not return a path
And if i enter nvcc it says sudo apt install nvidia-cuda-toolkit but this will remove the nvidia-470 also

Try changing this section in ffmpeg-build-script

if [[ "$OSTYPE" == "linux-gnu" ]]; then
  if command_exists "nvcc"; then
    if build "nv-codec" "11.1.5.0"; then
      download "https://github.com/FFmpeg/nv-codec-headers/releases/download/n11.1.5.0/nv-codec-headers-11.1.5.0.tar.gz"
      execute make PREFIX="${WORKSPACE}"
      execute make install PREFIX="${WORKSPACE}"
      build_done "nv-codec" "11.1.5.0"
    fi
    CFLAGS+=" -I/usr/local/cuda/include"
    LDFLAGS+=" -L/usr/local/cuda/lib64"
    CONFIGURE_OPTIONS+=("--enable-cuda-nvcc" "--enable-cuvid" "--enable-nvenc" "--enable-cuda-llvm")

    if [ -z "$LDEXEFLAGS" ]; then
      CONFIGURE_OPTIONS+=("--enable-libnpp") # Only libnpp cannot be statically linked.
    fi

    # https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/
    CONFIGURE_OPTIONS+=("--nvccflags=-gencode arch=compute_52,code=sm_52")
  fi

to

if [[ "$OSTYPE" == "linux-gnu" ]]; then
    if build "nv-codec" "11.1.5.0"; then
      download "https://github.com/FFmpeg/nv-codec-headers/releases/download/n11.1.5.0/nv-codec-headers-11.1.5.0.tar.gz"
      execute make PREFIX="${WORKSPACE}"
      execute make install PREFIX="${WORKSPACE}"
      build_done "nv-codec" "11.1.5.0"
    fi
    CONFIGURE_OPTIONS+=("--enable-nvenc")
  fi
1 Like
  • Well it compiled OK but it did not solve the 1660 encoding problem - its like envec and or hvec is just invisible while all other parts is working fine and snappy - I will try to install 21.10 again because I need to see it work with linux maybe even windows just prove its not the hardware but a pure software problem. But still its a problem for me if my gtx 1660 is to old and EOL.

If this return no encoder it means the script is broken

ffmpeg -encoders |grep nvenc

ffmpeg outputs fine

V…D h264_nvenc (codec h264)
V…D hevc_nvenc (codec hevc)

So the script is working but access to the encoder is not working. But will try the old 21.10 again but with current obs and ffmpeg maybe also recompile but one thing changed compared to the other computer currently running 21.10 with 1660 super is the ffmpeg version but I have no clue what the real problem is and maybe the nvidia driver is working fine with 21.10 but may have problems on 22.04 - every nvidia tools shows a working fine card give informations so its only when trying to do encodig else it looks nice the newer 22.04.
Later today I will try to install the old 21.10 again and se how work - the script used to work fine and so did the encoding that i need.

I’d rather try to install a recent driver, then install the matching nvidia-fabric-manager, change all failure modes in /usr/share/nvidia/nvswitch/fabricmanager.cfg to ‘1’, set log level to max, then start fabric-manager and check if the cuda driver connects to it when trying to encode, checking the log for what it wants.

1 Like

Try running these commands

wget http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
ffmpeg -i BigBuckBunny.mp4 -c:v h264_nvenc  output.mp4
1 Like

You don’t need cuda-driver to encode, these nvidia driver supplied libs are enough to encode to h264_nvenc.

/usr/lib64/libcuda.so
/usr/lib64/libcuda.so.1
/usr/lib64/libcuda.so.515.65.01
/usr/lib64/libnvcuvid.so.1
/usr/lib64/libnvcuvid.so.515.65.01
/usr/lib64/libnvidia-encode.so.1
/usr/lib64/libnvidia-encode.so.515.65.01
1 Like
libcuda.so.515.65.01

is the “cuda driver”

Yes I remeber in the “old days” when h264_nvenc was working I dont needed the cuda stuff but then maybe now the ffmpeg and obs just demands it - the way to use the encoder without CUDA don’t work as the bug CUDA_ERROR_SYSTEM_NOT_READY: system not yet initialized is clear.

I dont know for sure if OBS depends on ffmpeg and ffmpeg now just need/demands cuda api to work it sounds possible it can also be the change from kernal used in 21.10 makes the nvidia driver 470 work while its in 22.04 is tries/demands to use cuda.

I have to ask but what driver do I need to install ?
I use the nvidia-driver-470 or the nvidia-driver-470-server ?

The stuff I would like to run is the OBS and https://datarhei.com/ restreamer with Nvidia support but its not working
to do

docker run -d --restart=always --name restreamer \
-p 8080:8080 -p 8181:8181 -p 1935:1935 -runtime=nvidia --privileged \
datarhei/restreamer:cuda-latest

But the restreamer cant even see nvidia runtime - but OK can maybe just use passthru to avoid encoding but sure it would be nice to make it work when the graphics card should be anble to work.

Before I give up i would thy your suggestion to install the nvidia-fabric-manager but how do i get the nvidia-fabric-manager installed ?

I also installed the

NVIDIA-SMI 515.48.07 Driver Version: 515.48.07 CUDA Version: 11.7

It does work just as god or bad here like the 470 driver same problem with h264_nvenc encoding

Can ffmpeg encode?, post any errors>

wget http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
ffmpeg -i BigBuckBunny.mp4 -c:v h264_nvenc  output.mp4

Stream mapping:
Stream #0:1#0:0 (h264 (native) → h264 (h264_nvenc))
Stream #0:0#0:1 (aac (native) → aac (native))
Press [q] to stop, [?] for help
[h264_nvenc @ 0x5646d5182640] dl_fn->cuda_dl->cuInit(0) failed → CUDA_ERROR_SYSTEM_NOT_READY: system not yet initialized
Error initializing output stream 0:0 – Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
[aac @ 0x5646d5184d80] Qavg: 11404.133
[aac @ 0x5646d5184d80] 2 frames left in the queue on closing
Conversion failed!

So its the samme error

sudo apt install nvidia-fabric-manager
or fetch the deb from
https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/

I did try to install the nvidia-fabric-manager but no luck and it just to complicated for me to get the 1660 encoding to work on my Ubuntu 22.04 so I will go back to 21.10 were it was working or maybe even give windows 11 a try on that computer - I have used many hours and I can only say everything works but not the encoding part and it must be driver related.

Just to make sure I installed windows 10 and the current driver and the hardware works and the gpu encodning works fine with windows so the bug is related to Linux drivers with this card.

I have exactly the same error dl_fn->cuda_dl->cuInit(0) failed → CUDA_ERROR_SYSTEM_NOT_READY: system not yet initialized on my old pc on nvidia 750ti card. Everything works fine on windows 11. On linux just wont work - ubuntu 22.10 and 525 nvidia driver. No fix yet ?