在具有多个 GPU 的系统上使用特定 GPU 运行应用程序

在具有多个 GPU 的系统上使用特定 GPU 运行应用程序

我有一台运行 Ubuntu Mate 20.04 的戴尔 precision 7510 笔记本电脑,配备混合 Nvidia GeForce 940MX 卡和带有 Radeon RX 570 的 eGPU。

我有 5 个显示器连接到我的 Radeon RX 570,我正在尝试强制 Handbrake 使用我的 nvidia GPU,以便我可以使用 NVenc。我尝试过使用 DRI_PRIME,但它总是使用 Radeon RX 570。

philroche@bomek:~$ DRI_PRIME=1 glxinfo | grep "OpenGL renderer"
libGL error: failed to create dri screen
libGL error: failed to load driver: nouveau
OpenGL renderer string: Radeon RX 570 Series (POLARIS10, DRM 3.35.0, 5.4.0-42-generic, LLVM 10.0.0)
philroche@bomek:~$ DRI_PRIME=0 glxinfo | grep "OpenGL renderer"
OpenGL renderer string: Radeon RX 570 Series (POLARIS10, DRM 3.35.0, 5.4.0-42-generic, LLVM 10.0.0)

我可以看到 nvidia 模块已加载

philroche@bomek:~$ lsmod | grep -i nvidia
nvidia_uvm            913408  0
nvidia_drm             40960  0
nvidia_modeset       1122304  1 nvidia_drm
nvidia              19517440  2 nvidia_uvm,nvidia_modeset
drm_kms_helper        184320  3 amdgpu,nvidia_drm,i915
drm                   491520  26 gpu_sched,drm_kms_helper,amdgpu,nvidia_drm,i915,ttm
ipmi_msghandler       106496  2 ipmi_devintf,nvidia

以及 amd 模块

philroche@bomek:~$ lsmod | grep -i amd
amdgpu               4579328  64
amd_iommu_v2           20480  1 amdgpu
gpu_sched              32768  1 amdgpu
ttm                   106496  1 amdgpu
i2c_algo_bit           16384  2 amdgpu,i915
drm_kms_helper        184320  3 amdgpu,nvidia_drm,i915
drm                   491520  26 gpu_sched,drm_kms_helper,amdgpu,nvidia_drm,i915,ttm

我可以看到所有 GPU

philroche@bomek:~$ lspci 
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 530 (rev 06)
01:00.0 VGA compatible controller: NVIDIA Corporation GM107GLM [Quadro M2000M] (rev a2)
09:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] (rev ef)
09:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590]

nvidia-smi如预期般回报

philroche@bomek:~$ nvidia-smi
Thu Sep  3 18:54:39 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 435.21       Driver Version: 435.21       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Quadro M2000M       Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   53C    P0    N/A /  N/A |      0MiB /  4043MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

但 xrandr 只列出了一个提供商

philroche@bomek:~$ xrandr --listproviders
Providers: number : 1
Provider 0: id: 0x5a cap: 0x9, Source Output, Sink Offload crtcs: 6 outputs: 5 associated providers: 0 name:Radeon RX 570 Series @ pci:0000:09:00.0

我也安装了 nvidia-driver-435。

有人知道如何强制应用程序使用 Nvidia GPU 运行吗?

谢谢

答案1

如果您摆脱 nouveau 而使用 nvidia 驱动程序:

https://www.if-not-true-then-false.com/2015/fedora-nvidia-guide/

您需要使用 __GLX_VENDOR_LIBRARY_NAME=nvidia 来强制驱动程序:

$ inxi -G
Graphics:  Device-1: Intel UHD Graphics 620 driver: i915 v: kernel 
           Device-2: NVIDIA GP106 [GeForce GTX 1060 3GB] driver: nvidia v: 470.74 
           Device-3: Acer SunplusIT Integrated Camera type: USB driver: uvcvideo 
           Display: wayland server: X.Org 1.21.1.2 driver: loaded: nvidia resolution: 1920x1080~60Hz 
           OpenGL: renderer: Mesa Intel UHD Graphics 620 (KBL GT2) v: 4.6 Mesa 21.1.8 
$ DRI_PRIME=0 glxinfo | grep 'OpenGL renderer string'
OpenGL renderer string: Mesa Intel(R) UHD Graphics 620 (KBL GT2)
$ DRI_PRIME=1 glxinfo | grep 'OpenGL renderer string'
libGL error: failed to create dri screen
libGL error: failed to load driver: nouveau
OpenGL renderer string: llvmpipe (LLVM 12.0.1, 256 bits)
$ __GLX_VENDOR_LIBRARY_NAME=nvidia DRI_PRIME=1 glxinfo | grep 'OpenGL renderer string'
OpenGL renderer string: NVIDIA GeForce GTX 1060 3GB/PCIe/SSE2

相关内容