Score:-2

Force graphics to run on specific GPU with nvidia-prime

pn flag

My computer has one integrated graphics card and 2 Nvidia RTX 3070 GPUS. I am using Ubuntu 20.04 and nvidia-driver-530.

lspci | grep VGA
00:02.0 VGA compatible controller: Intel Corporation AlderLake-S GT1 (rev 0c)
01:00.0 VGA compatible controller: NVIDIA Corporation GA104 [GeForce RTX 3070 Lite Hash Rate] (rev a1)
05:00.0 VGA compatible controller: NVIDIA Corporation GA104 [GeForce RTX 3070 Lite Hash Rate] (rev a1)

I am currently trying to test my 3070 graphics cards with the Phoronix Test Suite.

I am using nvidia-prime and prime-select: on-demand to run the terminal on the intel iGPU and phoronix tests on the Nvidia 3070: prime-run phoronix-test-suite run unigine-heaven.

There were some issues getting nvidia-prime to work, so I followed the suggestions from this article: Prime-run command not found.

cat /usr/bin/prime-run
#!/bin/bash
export __NV_PRIME_RENDER_OFFLOAD=1
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export __VK_LAYER_NV_optimus=NVIDIA_only
export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json
exec "$@"

By using prime-run I am successfully able to run the phoronix test suite on GPU 0 which has bus id 01:00.0 / PCI:1:0:0.

However, I seem unable to run any tests with GPU 1 which has bus id 05:00.0 / PCI:5:0:0.

Modifying /etc/X11/xorg.conf by changing the bus number and rebooting as suggested by the following links didn't seem to do anything and still ran on GPU 0.

cat /etc/X11/xorg.conf
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 530.41.03

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "Screen0"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

Section "Files"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol" "auto"
    Option         "Device" "/dev/psaux"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    # generated from default
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    VendorName     "Unknown"
    ModelName      "Unknown"
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
#    BusID          "PCI:1:0:0"
    BusID          "PCI:5:0:0"
EndSection

Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    Monitor        "Monitor0"
    DefaultDepth    24
    SubSection     "Display"
        Depth       24
    EndSubSection
EndSection

In fact, I deleted etc/X11/xorg.conf and was able to run the phoronix tests on GPU 0 without the conf file at all. I would guess that one of the drivers or programs I run automatically selects the nvidia card with the lowest bus id.

I would like to know where I should look to change the settings or any configuration files in order to select the second RTX 3070 gpu with the bus id 05:00.0. I would be more than happy to provide any further information.

Score:0
pn flag

In the prime-run script, I also need to set the variable

__NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G{CARD#}

using the card identifier found in xrandr --listproviders.

The official Nvidia guide listed below has the resolution to this problem, but I did not read the guide closely enough and missed it on my first read.

https://download.nvidia.com/XFree86/Linux-x86_64/495.44/README/primerenderoffload.html

/etc/X11/xorg.conf is unnecessary for this solution.

I missed the part about the OFFLOAD_PROVIDER because I was accessing the headless server remotely from a client without any Xsession or graphics display.

The machine must be running some type of GUI and not just a headless terminal environment. In my case, I installed lightdm onto my server and then everything worked.

I believe that the graphics needs to be using x11/ xorg and not wayland. For gdm3, xorg can be set to run by uncommenting

#WaylandEnable=false

in /etc/gdm3/custom.conf and rebooting.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.