Sign inSign up

simeononsecurity/nvidia-patch

By simeononsecurity

•Updated over 3 years ago

This patch removes restriction on maximum number of simultaneous NVENC video encoding sessions.

Image
1

442

simeononsecurity/nvidia-patch repository overview

⁠Github⁠
⁠Website⁠

⁠NVENC and NvFBC patches for Nvidia drivers

GitHub last commit Latest version

NVENC patch⁠ removes restriction on maximum number of simultaneous NVENC video encoding sessions imposed by Nvidia to consumer-grade GPUs.

NvFBC patch⁠ allows to use NvFBC on consumer-grade GPUs. It should be applied same way as NVENC patch.sh, except you have to use patch-fbc.sh instead.

Main target operating system is GNU/Linux, but for Windows support see win (clickable)⁠.


If you like this project, best way to contribute is by sending PRs and fixing documentation.

If you want to donate, please send it to your favorite open source organizations, for example FFmpeg⁠, VideoLAN⁠


⁠Requirements

⁠Version Table

VersionNVENC patchNVFBC patchDriver link
375.39YESNODriver link⁠
390.77YESNODriver link⁠
390.87YESNODriver link⁠
390.147YESNODriver link⁠
396.24YESNODriver link⁠
396.26YESNODriver link⁠
396.37YESNODriver link⁠
396.54YESNODriver link⁠
410.48YESNO
410.57YESNODriver link⁠
410.73YESNODriver link⁠
410.78YESNODriver link⁠
410.79YESNODriver link⁠
410.93YESNODriver link⁠
410.104YESNODriver link⁠
415.18YESNODriver link⁠
415.25YESNODriver link⁠
415.27YESNODriver link⁠
418.30YESNODriver link⁠
418.43YESNODriver link⁠
418.56YESNODriver link⁠
418.67YESNODriver link⁠
418.74YESNODriver link⁠
418.87.00YESNODriver link⁠
418.87.01YESNODriver link⁠
418.88YESNODriver link⁠
418.113YESNODriver link⁠
430.09YESNODriver link⁠
430.14YESNODriver link⁠
430.26YESNODriver link⁠
430.34YESNODriver link⁠
430.40YESNODriver link⁠
430.50YESNODriver link⁠
430.64YESNODriver link⁠
435.17YESNODriver link⁠
435.21YESNODriver link⁠
435.27.08YESYES
440.26YESYESDriver link⁠
440.31YESYESDriver link⁠
440.33.01YESYESDriver link⁠
440.36YESYESDriver link⁠
440.43.01YESYES
440.44YESYESDriver link⁠
440.48.02YESYES
440.58.01YESYES
440.58.02YESYES
440.59YESYESDriver link⁠
440.64YESYESDriver link⁠
440.64.00YESYESDriver link⁠
440.66.02YESYES
440.66.03YESYES
440.66.04YESYES
440.66.08YESYES
440.66.09YESYES
440.66.11YESYES
440.66.12YESYES
440.66.14YESYES
440.66.15YESYES
440.66.17YESYES
440.82YESYESDriver link⁠
440.95.01YESYESDriver link⁠
440.100YESYESDriver link⁠
440.118.02YESYESDriver link⁠
450.36.06YESYESDriver link⁠
450.51YESYESDriver link⁠
450.51.05YESYESDriver link⁠
450.51.06YESYESDriver link⁠
450.56.01YESYES
450.56.02YESYES
450.56.06YESYES
450.56.11YESYES
450.57YESYESDriver link⁠
450.66YESYESDriver link⁠
450.80.02YESYESDriver link⁠
450.102.04YESNODriver link⁠
455.22.04YESNO
455.23.04YESYESDriver link⁠
455.23.05YESYES
455.26.01YESYES
455.26.02YESYES
455.28YESYESDriver link⁠
455.32.00YESYES
455.38YESYESDriver link⁠
455.45.01YESYESDriver link⁠
455.46.01YESYES
455.46.02YESYES
455.46.04YESYES
455.50.02YESYES
455.50.03NOYES
455.50.04YESYES
455.50.05YESYES
455.50.07YESYES
455.50.10YESYES
460.27.04YESYESDriver link⁠
460.32.03YESYESDriver link⁠
460.39YESYESDriver link⁠
460.56YESYESDriver link⁠
460.67YESYESDriver link⁠
460.73.01YESYESDriver link⁠
460.80YESYESDriver link⁠
460.84YESYESDriver link⁠
460.91.03YESYESDriver link⁠
465.19.01YESYESDriver link⁠
465.24.02YESYESDriver link⁠
465.27YESYESDriver link⁠
465.31YESYESDriver link⁠
470.42.01YESYESDriver link⁠
470.57.02YESYESDriver link⁠
470.62.02YESYES
470.62.05YESYES
470.63.01YESYESDriver link⁠
470.74YESYESDriver link⁠
470.82.00YESYESDriver link⁠
470.82.01YESYESDriver link⁠
470.86YESYESDriver link⁠
470.94YESYESDriver link⁠
470.103.01YESYESDriver link⁠
470.129.06YESYESDriver link⁠
470.141.03YESYESDriver link⁠
470.161.03YESYESDriver link⁠
495.29.05YESYESDriver link⁠
495.44YESYESDriver link⁠
495.46YESYESDriver link⁠
510.39.01YESYESDriver link⁠
510.47.03YESYESDriver link⁠
510.54YESYESDriver link⁠
510.60.02YESYESDriver link⁠
510.68.02YESYESDriver link⁠
510.73.05YESYESDriver link⁠
510.73.08YESYESDriver link⁠
510.85.02YESYESDriver link⁠
510.108.03YESYESDriver link⁠
515.43.04YESYESDriver link⁠
515.48.07YESYESDriver link⁠
515.57YESYESDriver link⁠
515.65.01YESYESDriver link⁠
515.76YESYESDriver link⁠
515.86.01YESYESDriver link⁠
520.56.06YESYESDriver link⁠
520.61.05YESYESDriver link⁠
525.60.11YESYESDriver link⁠
525.60.13YESYES
525.78.01YESYESDriver link⁠
525.85.05YESYESDriver link⁠
525.85.12YESYES

⁠Synopsis

# bash ./patch.sh -h

SYNOPSIS
       patch.sh [-s] [-r|-h|-c VERSION|-l|-f]

DESCRIPTION
       The patch for Nvidia drivers to remove NVENC session limit

       -s             Silent mode (No output)
       -r             Rollback to original (Restore lib from backup)
       -h             Print this help message
       -c VERSION     Check if version VERSION supported by this patch.
                      Returns true exit code (0) if version is supported.
       -l             List supported driver versions
       -d VERSION     Use VERSION driver version when looking for libraries
                      instead of using nvidia-smi to detect it.
       -f             Enable support for Flatpak NVIDIA drivers.

# bash ./patch-fbc.sh -h

SYNOPSIS
       patch-fbc.sh [-s] [-r|-h|-c VERSION|-l|-f]

DESCRIPTION
       The patch for Nvidia drivers to allow FBC on consumer devices

       -s             Silent mode (No output)
       -r             Rollback to original (Restore lib from backup)
       -h             Print this help message
       -c VERSION     Check if version VERSION supported by this patch.
                      Returns true exit code (0) if version is supported.
       -l             List supported driver versions
       -d VERSION     Use VERSION driver version when looking for libraries
                      instead of using nvidia-smi to detect it.
       -f             Enable support for Flatpak NVIDIA drivers.

⁠Step-by-Step guide

Examples are provided for driver version 430.50. All commands are executed as root.

⁠Download and install driver

Skip this step if you already have installed driver with version supported by this patch.

Make sure you have kernel headers and compiler installed before running Nvidia driver installer. Kernel headers and compiler are required to build nvidia kernel module. Recommended way to do this is to install dkms package, if it is available in your distro. This way dkms package will pull all required dependencies to allow building kernel modules and kernel module builds will be automated in a reliable fashion.

mkdir /opt/nvidia && cd /opt/nvidia
wget https://international.download.nvidia.com/XFree86/Linux-x86_64/430.50/NVIDIA-Linux-x86_64-430.50.run
chmod +x ./NVIDIA-Linux-x86_64-430.50.run
./NVIDIA-Linux-x86_64-430.50.run
⁠Check driver
nvidia-smi

Output should show no errors and details about your driver and GPU. You can also check if ffmpeg can encode without limit⁠, and check NVFBC via OBS.

⁠Patch driver

This patch performs backup of original file prior to making changes.

bash ./patch.sh

You're all set!

Note: Sometimes distribution installed drivers are not found by the patch script. In that case, please uninstall the nvidia driver using your distribution package manager, and install it using the steps above⁠.

⁠Rollback

If something got broken you may restore patched driver from backup:

bash ./patch.sh -r

⁠Docker support

It is possible to use this patch with nvidia-docker containers, even if host machine hasn't patched drivers. See Dockerfile for example.

Essentially all you need to do during build is:

  • COPY the patch.sh and docker-entrypoint.sh files into your container.
  • Make sure docker-entrypoint.sh is invoked on container start.

docker-entrypoint.sh script does on-the-fly patching by means of manipulating dynamic linker to workaround read-only mount of Nvidia runtime. Finally it passes original docker command to shell, like if entrypoint was not restricted by ENTRYPOINT directive. So docker run --runtime=nvidia -it mycontainer echo 123 will print 123. Also it can be just invoked from your entrypoint script, if you have any.

⁠Flatpak support

If you use a Flatpak app that uses NVENC/NvFBC (e.g. OBS Studio, Kdenlive), it's recommended that you patch the NVIDIA drivers for Flatpak as well. To do so, just pass the -f parameter to either patch.sh or patch-fbc.sh, like so:

bash ./patch.sh -f
bash ./patch-fbc.sh -f

In case something goes wrong, you can restore the original Flatpak drivers by adding the -r paramater:

bash ./patch.sh -f -r
bash ./patch-fbc.sh -f -r

⁠Benchmarks

⁠See also

If you experience CreateBitstreamBuffer failed: out of memory (10), then you have to lower buffers number used for every encoding session. If you are using ffmpeg, see option -surfaces ("Number of concurrent surfaces") and try value near -surfaces 8.

Tag summary

Content type

Image

Digest

sha256:fafbe34e3…

Size

57.3 MB

Last updated

over 3 years ago

docker pull simeononsecurity/nvidia-patch