setting the default gpu

31,837

Solution 1

OK, I figured it out.

First try creating an xorg config using the following command:

sudo nvidia-xconfig

this will create a new xorg config at /etc/X11/xorg.conf.

then change the device section to look something like below:

Section "Device"
    Identifier     "Device1"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "PCI:2:0:0"
EndSection

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

IMPORTANT: make sure your monitor is connected to the second GPU. reboot and voila!

Solution 2

I have two GPUs. Here is what I did to set the GPU2 for display:

To get PCI in hex format, use:

lspci | grep VGA

For me, it returns:

05:00.0 VGA compatible controller: NVIDIA Corporation Device 1b02 (rev a1)
09:00.0 VGA compatible controller: NVIDIA Corporation GM200 [GeForce GTX TITAN X] (rev a1)

So, in my case it is 09:00.0 for the GPU I wish to use for display (GPU2). I then generated the /etc/X11/xorg.conf using sudo nvidia-xconfig.

this will create a new xorg config at /etc/X11/xorg.conf.

Then I only added the BusID line in the following part of the file /etc/X11/xorg.conf:

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "PCI:9:0:0"
EndSection

I then restarted the computer and connected the monitors to the GPU2. After this few of the USB ports stopped working but others were fine to be used for keyboard and mouse.

Solution 3

The above answer is quite working except the exact number of "Bus ID."

In my case (Xubuntu 18.04, Kubuntu 20.04), the result of "lspci" was different from the Bus ID shown in "nvidia-settings," and the correct Bus ID was the one on the nvidia-settings.

If you set the wrong pci number as Bus ID, then you will see the black screen only.

Solution 4

In addition, I wanted the default boot to be a specific card also.

Rather than messing with xorg files, I simply opened the case and switched the graphic card I wanted as default into the slot currently occupied by GPU-0

After boot, the card came up as GPU-0 and as the default with no further config required.

Share:
31,837

Related videos on Youtube

MBZ
Author by

MBZ

PhD Student in Computer Science at UIUC

Updated on September 18, 2022

Comments

  • MBZ
    MBZ over 1 year

    I have two gpus on my machine:

    $ lspci | grep VGA
    01:00.0 VGA compatible controller: NVIDIA Corporation GM200 [GeForce GTX 980 Ti] (rev a1)
    03:00.0 VGA compatible controller: NVIDIA Corporation GF108 [GeForce GT 730] (rev a1)
    

    I wanna use the first gpu for computation, so I need it free. However the X server is running on the first one by default which costs %2 to %10 of the gpu capacity.

    How can I move the X server to the second gpu?

  • Dmitry Andreev
    Dmitry Andreev almost 4 years
    Thanks for the warning! I used the BusID from nvidia-settings and it worked. I must have avoided quite some trouble.
  • RedEyed
    RedEyed over 3 years
    lspci gives hexadecimal but xorg requires decimal.
  • RedEyed
    RedEyed over 3 years
    You can use nvidia-xconfig --query-gpu-info to get directly decimal bus id