This patch removes restriction on maximum number of simultaneous NVENC video encoding sessions imposed by Nvidia to consumer-grade GPUs.
Bypass (remove) Nvidia GPU maximum number of simultaneous NVENC video encoding sessions
Main target operating system is GNU/Linux but for Windows support its added to.
Requirements:
- x86_64 system architecture
- GNU/Linux operating system
- nvenc-compatible gpu (https://developer.nvidia.com/video-encode-decode-gpu-support-matrix#Encoder)
- Nvidia driver. Patch available for: https://github.com/keylase/nvidia-patch
Synopsis
# bash ./patch.sh -h
SYNOPSIS
patch.sh [OPTION]…
DESCRIPTION
The patch for Nvidia drivers to increase encoder sessions
-s Silent mode (No output)
-r Rollback to original (Restore lib from backup)
-h Print this help message
Step-by-Step guide
Examples are provided for driver version 430.40. All commands are runned as root.
Download driver
https://international.download.nvidia.com/XFree86/Linux-x86_64/430.40/NVIDIA-Linux-x86_64-430.40.run
Install driver
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.40/NVIDIA-Linux-x86_64-430.40.run
chmod +x ./NVIDIA-Linux-x86_64-430.40.run
./NVIDIA-Linux-x86_64-430.40.run
Check driver
nvidia-smi
Output should show no errors and details about your driver and GPU.
Patch driver
This patch performs backup of original file prior to making changes.
bash ./patch.sh
You’re all set!
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.
See also
- Plex Media Server: enable HW decoding:
- Unraid / Docker:
- GH Issue
- Unraid Nvidia plugin:
- Original research behind this patch
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.
Nvidia drivers patch for Windows
This patch removes restriction on maximum number of simultaneous NVENC video encoding sessions imposed by Nvidia to consumer-grade GPUs.
Website: https://github.com/keylase/nvidia-patch/tree/master/win
Requirements:
- Any of following 64bit operating systems:
- Windows 7
- Windows 8
- Windows 8.1
- Windows 10
- Windows Server 2008 R2
- Windows Server 2012
- Windows Server 2012 R2
- Windows Server 2016
- Windows Server 2019
- NVENC-compatible GPU (https://developer.nvidia.com/video-encode-decode-gpu-support-matrix#Encoder)
- Nvidia driver. Patch available for versions in table below.
Step-by-Step Guide
- Download and install latest Nvidia driver supported by this patch.
- Download latest Win_1337_Apply_Patch tool.
- Save appropriate patch from Version Table using direct link to the patch (Right Click -> Save as…). Alternatively you may checkout repo using git or download it as ZIP archive and then locate corresponding .1337 patch file in win directory.
- Apply patch to corresponding file in %WINDIR%\system32\ with the Win_1337_Apply_Patch tool. File name of patched object is specified in first line of .1337 patch.
E.g, for 64bit Windows 10 running driver version 417.35 use win10_x64/417.35/nvcuvid.1337 against C:\WINDOWS\system32\nvcuvid.dll.
Version Table
Windows 10 drivers
Product series | Version | Patch | Driver link |
---|---|---|---|
GeForce | 417.35 | Direct link | Direct link |
GeForce | 417.58 | Direct link | Direct link |
GeForce | 417.71 | Direct link | Direct link |
GeForce | 418.81 | Direct link | Direct link |
GeForce | 418.91 | Direct link | Direct link |
GeForce | 419.17 | Direct link | Direct link |
GeForce | 419.35 | Direct link | Direct link |
GeForce | 419.67 | Direct link | Direct link |
GeForce | 419.67 CRD | Direct link | Direct link |
GeForce | 425.31 | Direct link | Direct link |
GeForce | 430.39 | Direct link | Direct link |
GeForce | 430.64 | Direct link | Direct link |
GeForce | 430.86 | Direct link | Direct link |
GeForce | 430.86 Studio Driver | Direct link | Direct link |
GeForce | 431.36 | Direct link | Direct link |
GeForce | 431.60 | Direct link | Direct link |
GeForce | 431.70 Studio Driver | Direct link | Direct link |
GeForce | 431.86 Studio Driver | Direct link | Direct link |
GeForce | 435.27 | Direct link | Direct link (non-official) |
GeForce | 436.02 | Direct link | Direct link |
GeForce | 436.15 | Direct link | Direct link |
Product series | Version | Patch | Driver link |
---|---|---|---|
Quadro | 412.16 | Direct link | Direct link |
Quadro | 412.29 | Direct link | Direct link |
Quadro | 416.78 | Direct link | Direct link |
Quadro | 418.81 | Direct link | Direct link |
Quadro | 419.17 | Direct link | Direct link |
Quadro | 419.67 | Direct link | Direct link |
Quadro | 425.31 | Direct link | Direct link |
Quadro | 430.39 | Direct link | Direct link |
Quadro | 430.64 | Direct link | Direct link |
Quadro | 430.86 | Direct link | Direct link |
Quadro | 431.02 | Direct link | Direct link |
Quadro | 431.70 | Direct link | Direct link |
Quadro | 431.86 | Direct link | Direct link |
Quadro | 436.02 | Direct link | Direct link |
Windows 7, Windows 8, Windows 8.1 drivers
Product series | Version | Patch | Driver link |
---|---|---|---|
GeForce | 431.60 | Direct link | Direct link |
GeForce | 436.02 | Direct link | Direct link |
GeForce | 436.15 | Direct link | Direct link |
Product series | Version | Patch | Driver link |
---|---|---|---|
Quadro | 431.02 | Direct link | Direct link |
Quadro | 431.70 | Direct link | Direct link |
Quadro | 431.86 | Direct link | Direct link |
Quadro | 436.02 | Direct link | Direct link |
Windows Server 2008R2, 2012, 2012R2 drivers
Product series | Version | Patch | Driver link |
---|---|---|---|
Quadro | 430.64 | Direct link | Direct link |
Quadro | 430.86 | Direct link | Direct link |
Quadro | 431.02 | Direct link | Direct link |
Quadro | 431.70 | Direct link | Direct link |
Quadro | 431.86 | Direct link | Direct link |
Windows Server 2016, 2019 drivers
Product series | Version | Patch | Driver link |
---|---|---|---|
Quadro | 430.86 | Direct link | Direct link |
Quadro | 431.02 | Direct link | Direct link |
Quadro | 431.70 | Direct link | Direct link |
Quadro | 431.86 | Direct link | Direct link |
See also
- Genesis in related issue
Plex Media Server, D3D11 and 32-bit apps encoding sessions
Related issue. Summary: this patch permanently removes limit only for CUDA NVENC sessions in 64bit apps. But once usage limit was exceeded, it persists for all kinds of apps until system reboot. So, for example, you may once open 10 sessions with 64bit version of ffmpeg and limit will get raised to 10 for all rest types of apps until reboot. You may follow these steps to achieve this automatically and have all limits raised (assuming patch above already applied):
Method 1 (recommended)
- Download and run latest release of NvencSessionLimitBump.
- (Optional) Add it to autostart programs.
By default this application raises limit to 32 encoding sessions. Credits to @jantenhove.
Method 2 (alternative)
- Download 64bit FFmpeg for Windows: https://ffmpeg.zeranoe.com/builds/
- Unpack it somewhere.
- Get ffmpeg_null_10streams.cmd from this repo.
- Edit ffmpeg_null_10streams.cmd and set executable path to real location of your unpacked ffmpeg.
- (Optional) Add ffmpeg_null_10streams.cmd to autostart programs.
Bonus: you may use this AutoIt script from @wazerstar for silent startup of console applications bumping sessions.
Also you may use these methods to check if patch applied correctly and limit was raised. Use them when nothing works and you are in doubt.