Categories
Uncategorized

How to set up a CUDA GPU for computing only?

Most of logic board today comes with an integrated graphic card. Once a CUDA device is plugged in, X11 will recognize there is a new VGA device and configure it for X11 with memory allocations.

Blow is an example nvidia-smi output showing Xorg (X11) and gnome environment are using a large chunk of the GPU memory.

+—————————————————————————–+
| NVIDIA-SMI 470.182.03   Driver Version: 470.182.03   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:01:00.0  On |                  N/A |
|  0%   48C    P8    19W / 180W |   1201MiB /  8110MiB |     13%      Default |
|                               |                      |                  N/A |
+——————————-+———————-+———————-++—————————————————————————–+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1738      G   /usr/lib/xorg/Xorg                246MiB |
|    0   N/A  N/A      2033      G   /usr/bin/gnome-shell                7MiB |
|    0   N/A  N/A      2812      G   /usr/lib/xorg/Xorg                514MiB |
|    0   N/A  N/A      2942      G   /usr/bin/gnome-shell              169MiB |
|    0   N/A  N/A    321543      G   …NiYQ%3D%3D&browser=chrome       36MiB |
|    0   N/A  N/A    321587      G   …/debug.log –shared-files        5MiB |
|    0   N/A  N/A    458830      G   …390373760644109118,131072      115MiB |
|    0   N/A  N/A    458872      G   …veSuggestionsOnlyOnDemand       78MiB |
+—————————————————————————–+

If you want to use the CUDA device for computing, better free up the GPU memory. Here is a way to do it.

First, find the address of the device you want to use. You can change “Display” to “VGA” to list all the devices can be used to control the monitor.

$ lspci |grep Display
00:02.0 Display controller: Intel Corporation UHD Graphics 630 (Desktop)

Then edit or create /etc/X11/xorg.conf. Note: “sudo” privilege is required here.

Section "Device"
    Identifier      "intel"
    Driver          "intel"
    BusId           "PCI:0:2:0"
EndSection

Section "Screen"
    Identifier      "intel"
    Device          "intel"
EndSection

Restart the X11 environment or reboot, and you will see that GPU memory is now freed up and can all be used for CUDA computing.

~$ nvidia-smi
Mon May 1 11:03:18 2023
+—————————————————————————–+
| NVIDIA-SMI 470.182.03 Driver Version: 470.182.03 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:01:00.0 Off | N/A |
| 0% 55C P8 10W / 180W | 2MiB / 8119MiB | 0% Default |
| | | N/A |
+——————————-+———————-+———————-+

+—————————————————————————–+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+—————————————————————————–+

Leave a Reply

Your email address will not be published.