Skip to content

Switch GPU for display and other purposes

Xin (Cindy) edited this page Feb 23, 2017 · 5 revisions

Two GPUs were installed on server Blacksword-Yoru in Socket 1 and 3 (the only two high-speed 16x sockets).

  1. Before you make changes, check the GPU status and usage by command line:

       nvidia-smi
    

And the output would look like this:

     +-----------------------------------------------------------------------------+
     | NVIDIA-SMI 367.57                 Driver Version: 367.57                    |
     |-------------------------------+----------------------+----------------------+
     | GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
     | Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
     |===============================+======================+======================|
     |   0  GeForce GTX TIT...  Off  | 0000:01:00.0      On |                  N/A |
     | 52%   83C    P2   124W / 250W |  11724MiB / 12206MiB |     73%      Default |
     +-------------------------------+----------------------+----------------------+
     |   1  GeForce GTX 980     Off  | 0000:02:00.0     Off |                  N/A |
     |  0%   36C    P8    11W / 185W |   3737MiB /  4037MiB |      0%      Default |
     +-------------------------------+----------------------+----------------------+
                                                                           
     +-----------------------------------------------------------------------------+
     | Processes:                                                       GPU Memory |
     |  GPU       PID  Type  Process name                               Usage      |
     |=============================================================================|
     |    0      1388    G   /usr/lib/xorg/Xorg                             530MiB |
     |    0      2325    G   compiz                                          61MiB |
     |    0     17131    G   /usr/lib/xorg/Xorg                              27MiB |
     |    0     18248    C   python                                       10997MiB |
     |    1     18248    C   python                                        3734MiB |
     +-----------------------------------------------------------------------------+

A brief info can also be found using

    lspci | grep VGA

And the output would look like this:

    01:00.0 VGA compatible controller: NVIDIA Corporation GM200 [GeForce GTX TITAN X] (rev a1)
    02:00.0 VGA compatible controller: NVIDIA Corporation GM204 [GeForce GTX 980] (rev a1)

Write down the BusID for both GPUs, e.g. 01:00.0 for TITAN and 02:00.0 for 980.

  1. Suppose we want to switch the X server to GPU 1 (GeForce GTX 980).

First try creating a new xorg config using the following command:

     sudo nvidia-xconfig

which will create a new xorg config at /etc/X11/xorg.conf. There might be some warning messages but xorg.conf will be created in /etc/X11/. Locate the file and change the mode using sudo chmod 757 xorg.conf in order to make the following changes to it. Remember to revert to mode 600 when done.

After you change the file mode to 757, let's modify the device section starting Line 39 of xorg.conf 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

The default configuration should be "Device0" and now we want to change it to "Device1". Note that here we put down the BusID for GeForce GTX 980 since we want to use it for monitor.

  1. Make sure your monitor is connected to GPU 1 and then reboot the computer.