Skip to content

Instantly share code, notes, and snippets.

@Nitesh8998
Created October 15, 2021 08:48
Show Gist options
  • Save Nitesh8998/a337c29a41e23e4c5d0e421852e62db3 to your computer and use it in GitHub Desktop.
Save Nitesh8998/a337c29a41e23e4c5d0e421852e62db3 to your computer and use it in GitHub Desktop.
Instructions To Succesfully Install Linux with Cuda in AMD machine
  1. Check the AMD Radeon Software for Linux latest version that is available. This is because until these graphics drivers support a linux kernel version there is no use trying to install linux in your machine.

  2. Check the kernel version supported and create a bootable drive of the linux distro with exactly that kernel.

  3. While installation DONOT agree 'download updates while installation'. Random updates are installed which can be a problem.

  4. After installing there is a high chance that the neither(internal gpu nor dedicated GPU) drivers are installed. If the linux doesnt boot under GUI, try TTY (ctrl+alt+F[1-6]) and change the following parameter in /etc/default/grub

    GRUB_CMDLINE_LINUX_DEFAULT = "nomodeset"

This is a temporary change.

  1. To install the AMD graphics drivers use the radeon software package as seen in step 1. (something similar to this)

  2. Extract the downloaded drive pack install the drivers.DONOT use 'pro' install version of install.

  3. You should see this after a reboot:

lspci -nnk | grep -i vga -A3 | grep 'in use'

Kernel driver in use: amdgpu 8. Now get the ' .deb' localfile of the correct cuda version. DONOT use the 'run file' method. (from here may be)

  1. After installing check nvidia-smi. you should see this: No running processes found.
Fri May 21 21:45:27 2021      
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 465.19.01    Driver Version: 465.19.01    CUDA Version: 11.3     |
|-------------------------------+----------------------+----------------------+
| 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 ...  On   | 00000000:01:00.0 Off |                  N/A |
| N/A   50C    P0    19W /  N/A |      1MiB /  5946MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
  1. Its now time to force amd integrated graphics card to be the display gpu. This is essential if you want CUDA to have maximum memory of the nvidia gpu.

  2. Check the id of the GPU using lspci | grep -i vga

01:00.0 VGA compatible controller: NVIDIA Corporation GA106M [GeForce RTX 3060 Mobile / Max-Q] (rev a1)
05:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Cezanne (rev c5)

id here is 5.0.0 for AMD integrated GPU.

  1. Check the identifiers for your amd gpu from ls /usr/share/X11/xorg.conf.d/10-amdgpu.conf

  2. create xorg.conf in /etc/X11/xorg.conf as following

Section "Device"
    Identifier      "AMDgpu"
    Driver          "amdgpu"
    BusId           "PCI:5:0:0"
EndSection
 
Section "Screen"
    Identifier      "AMDgpu"
    Device          "amdgpu"
EndSection

Pay attention to the indentation. Keep in mind that the BusID is the same as in step 11.

  1. Change this

GRUB_CMDLINE_LINUX_DEFAULT = "quiet splash"

Reboot. and Check this:

$ lspci -nnk | grep -i vga -A3 | grep 'in use'

Kernel driver in use: amdgpu
Kernel driver in use: nvidia
 
$nvidia-smi
Fri May 21 21:45:27 2021      
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 465.19.01    Driver Version: 465.19.01    CUDA Version: 11.3     |
|-------------------------------+----------------------+----------------------+
| 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 ...  On   | 00000000:01:00.0 Off |                  N/A |
| N/A   50C    P0    19W /  N/A |      1MiB /  5946MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
  1. Congrats after a painful process you are good to enjoy your AMD powered system that has Crazy NVIDIA GPU connected to it!! 🤘 😆
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment