keylase / nvidia-patch

This patch removes restriction on maximum number of simultaneous NVENC video encoding sessions imposed by Nvidia to consumer-grade GPUs.
3.51k stars 276 forks source link

NvFBC patch not working on driver 470.63.01 #428

Open huzhifeng opened 3 years ago

huzhifeng commented 3 years ago

Hello,

I tried to enable NvFBC for GTX 1050 with driver 470.63.01, but no success.

GPU model and driver:

[root@localhost ~]# lspci -d 10de:
00:08.0 VGA compatible controller: NVIDIA Corporation GP107 [GeForce GTX 1050] (rev a1)
[root@localhost ~]# nvidia-smi 
Mon Aug 30 15:42:52 2021       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.63.01    Driver Version: 470.63.01    CUDA Version: 11.4     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:00:08.0  On |                  N/A |
| 29%   31C    P8    N/A /  65W |     73MiB /  2000MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      2827      G   /usr/libexec/Xorg                  70MiB |
+-----------------------------------------------------------------------------+
[root@localhost ~]#

Apply NvFBC patch:

[root@localhost ~]# cd nvidia-patch/
[root@localhost nvidia-patch]# ./patch-fbc.sh 
Detected nvidia driver version: 470.63.01
Attention! Backup not found. Copying current libnvidia-fbc.so to backup.
b098578a8656207667f665c81780310c3985811c  /opt/nvidia/libnvidia-fbc-backup/libnvidia-fbc.so.470.63.01
9734e6bf0f73616c97a203b06cbe7d2a36a5fadc  /usr/lib64/libnvidia-fbc.so.470.63.01
Patched!

Run test (NvFBCHwEnc):

[root@localhost ~]# cd ~/Capture_Linux_v7.1.9/NvFBC/samples/NvFBCHwEnc
[root@KSVDI-VDI-0004 NvFBCHwEnc]# make
gcc -m64 -Wall -I../../inc -I../inc -c NvFBCHwEnc.c -o NvFBCHwEnc.o
gcc -m64 -Wall -I../../inc -I../inc -c ../common/NvFBCUtils.c -o NvFBCUtils.o
gcc -m64 NvFBCHwEnc.o NvFBCUtils.o -ldl -o NvFBCHwEnc
[root@localhost NvFBCHwEnc]# ./NvFBCHwEnc 
Application version: 4
NvFBC API version: 1.6

This hardware does not support NvFBC
[root@localhost NvFBCHwEnc]#

Run test (NvFBCCUDAAsync):

[root@localhost ~]# cd ~/Capture_Linux_v8.0.4/NvFBC/samples/NvFBCCUDAAsync
[root@localhost NvFBCCUDAAsync]# make
gcc -m64 -Wall -I../../inc -I../inc  -c NvFBCCUDAAsync.c -o NvFBCCUDAAsync.o
gcc -m64 -Wall -I../../inc -I../inc  -c ../common/NvFBCUtils.c -o NvFBCUtils.o
gcc -m64 NvFBCCUDAAsync.o NvFBCUtils.o -ldl -o NvFBCCUDAAsync
[root@localhost NvFBCCUDAAsync]# ./NvFBCCUDAAsync 
Application version: 4
NvFBC API version: 1.7

This hardware does not support NvFBC
[root@localhost NvFBCCUDAAsync]#
huzhifeng commented 3 years ago

Actually it works well with 455.45.01

Downgrade the driver to version 455.45.01

[root@localhost ~]# nvidia-uninstall
[root@localhost ~]# ./NVIDIA-Linux-x86_64-455.45.01.run
[root@localhost ~]# nvidia-smi 
Mon Aug 30 19:36:29 2021       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 455.45.01    Driver Version: 455.45.01    CUDA Version: 11.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GTX 1050    Off  | 00000000:00:08.0  On |                  N/A |
| 29%   32C    P8    N/A /  65W |     91MiB /  1997MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1682      G   /usr/libexec/Xorg                  88MiB |
+-----------------------------------------------------------------------------+
[root@localhost ~]# 

Apply NvFBC patch again:

[root@localhost ~]# cd nvidia-patch/
[root@localhost nvidia-patch]# ./patch-fbc.sh 
Detected nvidia driver version: 455.45.01
Attention! Backup not found. Copying current libnvidia-fbc.so to backup.
2deaeb50209924d0a71a8cbb11873c266e68a798  /opt/nvidia/libnvidia-fbc-backup/libnvidia-fbc.so.455.45.01
3dfcc57c56bc28a00da211ca97cb1d04e0b0436e  /usr/lib64/libnvidia-fbc.so.455.45.01
Patched!
[root@localhost nvidia-patch]#

Run test:

[root@localhost ~]# cd Capture_Linux_v7.1.9/NvFBC/samples/NvFBCHwEnc
[root@localhost NvFBCHwEnc]# ./NvFBCHwEnc 
Application version: 4
NvFBC API version: 1.6

Creating a capture session of 1000 HW compressed frames.
Capture of HW compressed frames is no longer supported. See: https://developer.nvidia.com/nvidia-video-codec-sdk
[root@localhost NvFBCHwEnc]#
[root@localhost NvFBCHwEnc]# cd ../NvFBCCUDAAsync/
[root@localhost NvFBCCUDAAsync]# ./NvFBCCUDAAsync 
Application version: 4
NvFBC API version: 1.6

Creating an asynchronous capture session of 10 frames with 1 second internal between captures.
WARNING: Could not find the Vulkan loader 'libvulkan.so.1' on this system.
         Attempting to load the NVIDIA Vulkan ICD...
         (This warning is non-fatal and can be suppressed with
         the NVFBC_NO_WARNING=1 environment variable.)
Reallocated 6075 KB of system memory
New frame id 1 grabbed in 1 ms, downloaded in 3 ms, saved in 15 ms, now sleeping for 981 ms
Frame id 2 grabbed in 0 ms, downloaded in 1 ms, saved in 15 ms, now sleeping for 984 ms
Frame id 3 grabbed in 0 ms, downloaded in 1 ms, saved in 17 ms, now sleeping for 982 ms
Frame id 4 grabbed in 0 ms, downloaded in 1 ms, saved in 15 ms, now sleeping for 984 ms
Frame id 5 grabbed in 0 ms, downloaded in 1 ms, saved in 14 ms, now sleeping for 985 ms
Frame id 6 grabbed in 0 ms, downloaded in 0 ms, saved in 15 ms, now sleeping for 985 ms
Frame id 7 grabbed in 0 ms, downloaded in 1 ms, saved in 15 ms, now sleeping for 984 ms
Frame id 8 grabbed in 0 ms, downloaded in 1 ms, saved in 14 ms, now sleeping for 985 ms
Frame id 9 grabbed in 0 ms, downloaded in 1 ms, saved in 15 ms, now sleeping for 984 ms
Frame id 10 grabbed in 0 ms, downloaded in 1 ms, saved in 14 ms, now sleeping for 985 ms
Unable to cleanup NvFBC
[root@localhost NvFBCCUDAAsync]#

[root@localhost ~]# cd Capture_Linux_v8.0.4/NvFBC/samples/NvFBCCUDAAsync/
[root@localhost NvFBCCUDAAsync]# DISPLAY=:0 ./NvFBCCUDAAsync 
Application version: 4
NvFBC API version: 1.7

Creating an asynchronous capture session of 10 frames with 1 second internal between captures.
WARNING: Could not find the Vulkan loader 'libvulkan.so.1' on this system.
         Attempting to load the NVIDIA Vulkan ICD...
         (This warning is non-fatal and can be suppressed with
         the NVFBC_NO_WARNING=1 environment variable.)
Reallocated 6075 KB of system memory
New frame id 1 grabbed in 1 ms, downloaded in 3 ms, saved in 16 ms, now sleeping for 980 ms
Frame id 2 grabbed in 0 ms, downloaded in 1 ms, saved in 16 ms, now sleeping for 983 ms
Frame id 3 grabbed in 0 ms, downloaded in 1 ms, saved in 23 ms, now sleeping for 976 ms
Frame id 4 grabbed in 0 ms, downloaded in 1 ms, saved in 15 ms, now sleeping for 984 ms
Frame id 5 grabbed in 0 ms, downloaded in 1 ms, saved in 15 ms, now sleeping for 984 ms
Frame id 6 grabbed in 0 ms, downloaded in 1 ms, saved in 14 ms, now sleeping for 985 ms
Frame id 7 grabbed in 0 ms, downloaded in 1 ms, saved in 15 ms, now sleeping for 984 ms
Frame id 8 grabbed in 0 ms, downloaded in 0 ms, saved in 15 ms, now sleeping for 984 ms
Frame id 9 grabbed in 0 ms, downloaded in 1 ms, saved in 15 ms, now sleeping for 984 ms
Frame id 10 grabbed in 0 ms, downloaded in 1 ms, saved in 15 ms, now sleeping for 984 ms
Unable to cleanup NvFBC
[root@localhost NvFBCCUDAAsync]#