Wiki
Install required configuration
Existing English translations were reused. 5 current source blocks remain in Simplified Chinese, without triggering paid translation.
1.Changing package sources (using Debian-based distributions as an example)
Open the website below (note that this Ubuntu repository version is for X86, amd64 repositories; the ARM repository is not on this website (99.9% of people's computers are X86, many industrial control computers are ARM, but industrial control computers also include X86 models; please seeVinci Robotics Team Microcontroller Tutorialfor an introduction, or search on Baidu yourself).
Choose one of the mirror sources below.
https://mirrors.bfsu.edu.cn/help/ubuntu/
https://mirrors.cloud.tencent.com/help/ubuntu.html
https://developer.aliyun.com/mirror/ubuntu
https://mirrors.sustech.edu.cn/help/ubuntu.html#introduction
https://mirrors.ustc.edu.cn/help/ubuntu.html
https://help.mirrors.cernet.edu.cn/ubuntu/
You can test the speed and select the fastest source.
curl https://mirrors.cernet.edu.cn/oh-my-mirrorz.py | python3
Speed test results in the north (Shandong) are as follows:

Speed test results in the south (Guangdong) are as follows:

The faster one in both north and south is 北京外国语大学BFSU and 南方科技大学SUSTech. If you don't want to test speed, you can choose blindly, or you can test speed to choose the best source.
1.1.Ubuntu22.04 (and Debian 10) and earlier versions
Enter the following command
sudo apt update
sudo apt install vim
sudo vim /etc/apt/sources.list
On the following screen, press theggdG(note that it is case-sensitive)


After selecting the Ubuntu version,

Paste it in

Press ESC, then type an English colon, enter :wq!then press Enter

Enter the following command
sudo apt update
If the corresponding school source website appears below, it is successful.

At this point, the source replacement is complete.
1.2.Ubuntu24.04(and Debian 12) and above
sudo apt update
sudo apt install vim
sudo rm -rf /etc/apt/sources.list
sudo rm -rf /etc/apt/sources.list.d/**
sudo vim /etc/apt/sources.list.d/ubuntu.sources
After selecting the Ubuntu version, copy the content below.

Paste it in

Press ESC, then type an English colon, enter :wq!then press Enter

Enter the following command
sudo apt update
If this is replaced with the corresponding school, then it succeeds.

1.3.Fedora 41 (DNF5) and later
https://mirrors.bfsu.edu.cn/help/fedora/
https://help.mirrors.cernet.edu.cn/fedora/
sed -e 's|^metalink=|#metalink=|g' \
-e 's|^#baseurl=http://download.example/pub/fedora/linux|baseurl=https://mirrors.bfsu.edu.cn/fedora|g' \
-i.bak \
/etc/yum.repos.d/fedora.repo \
/etc/yum.repos.d/fedora-updates.repo
2.Uninstall the disgusting snap (Ubuntu derivative)
⚠️ Official default vanilla Ubuntu GNOME**** Do not uninstall snap, it will break. Vanilla Ubuntu can only continue to let snap disgust you, there's no way around it. (Now it seems that non-vanilla Ubuntu also doesn't allow uninstalling it anymore, utterly disgusting.)
So I have always recommended Ubuntu KDE (that is, Kubuntu).
2.1.Install a non-Firefox browser
Before uninstalling snap, please install a browser first (using Google Chrome as an example) (this is because Ubuntu installs the snap version of Firefox by default)
Below is the Chrome official website on Google Shanghai servers (no VPN required)
https://www.google.cn/chrome/index.html

Since we are using Ubuntu here, which is a Debian-based system, choose the package with the .deb extension. (That is, the one in the red box.)
For Red Hat-based systems, you need to install packages with the .rpm extension. (That is, the blue boxes.)

#某些发行版中,可能Downloads是中文下载,所以就需要 cd ~/下载
cd ~/Downloads
#下方chrome安装包名不一定是这个,根据名字来看
sudo apt install ./google-chrome-stable_current_amd64.deb

2.2.View the number of snap package applications
# 老版
sudo apt update
sudo apt install neofetch
neofetch
# 新版
sudo add-apt-repository ppa:zhangsongcui3371/fastfetch
sudo apt update
sudo apt install fastfetch
fastfetch
# windows 想看系统信息的话
winget install fastfetch
#重启 powershell
fastfetch
Here it shows that there are a total of 3162 Debian programs and 7 snap programs

2.3.Remove snap applications
When the system starts, it automatically starts Snap-related services. We will first disable these services.
sudo systemctl disable snapd.service
sudo systemctl disable snapd.socket
sudo systemctl disable snapd.seeded.service
Then view the snap application list
Depending on the installation option you chose (minimal installation or normal installation), there aredifferentSnap applications that will be preinstalled on the system. Before removing the Snap service, we need to remove these installed by Snap
# 查询当前系统上snap安装了哪些app
snap list

Uninstall all applications in the figure, in the order offirst delete application software, then delete non-application software.
#移除snap-store,如果是Kubuntu,则没有这个东西,测不需要卸载
sudo snap remove snap-store
#移除firefox浏览器 gnome-42-2204 gtk-common-themes(可以一次性移除多个)
sudo snap remove firefox gnome-42-2204 gtk-common-themes
#移除其它...
#移除core22,bare以及snapd(下面这些需要最后再移除,否则会报错)
sudo snap remove core22
sudo snap remove bare
sudo snap remove snapd

Enter the following command to check whether there are any snap packages left
snap list
# 老版
neofetch
# 新版
fastfetch

2.4.Remove snap
After deleting the software installed viaSnapthe next step is to also delete Snap itself; this needs to be done using Apt (uninstall with caution, as the graphical interface can easily crash)
#使用apt移除掉snap
sudo apt autoremove --purge snapd
#移除snapd的一些目录
sudo rm -rf /var/cache/snapd
sudo rm -rf ~/snap
At this point, snap has actually been deleted. However, this is not enough. If you use apt to install some software, sudo apt install firefox it will automatically download and reinstall the snap service. This is because some software in the Ubuntu repositories are already snap versions rather than deb versions, and when downloading the snap version, it will automatically check and, if necessary, reinstall the snap service. This is also some extra effort made by Canonical to promote its own Snap Store, I suppose. (This is the point that many people dislike the most.)
2.5.Disable automatic installation of snap by the system
We can leverage the feature that APT can be configured to disable the installation of certain dependencies, in order to prohibit the automatic reinstallation of the Snap service.
sudo vim /etc/apt/preferences.d/nosnap.pref
按insert进入编辑模式,然后复制以下内容,最后按ESC,切换为英文输入法模式,然后敲 :wq 回车
Package: snapd
Pin: release a=*
Pin-Priority: -10

2.6.Test whether it succeeded
sudo apt update
sudo apt install firefox
If it indicates here that snapd cannot be installed, that proves it was successful.

2.7.Reinstall the FireFox browser (not really necessary)
Personally, I actually prefer the Google Chrome browser. I installed the browser by downloading the deb package from the official Chrome website. So since I already have a browser, there’s no need to install Firefox.
But if you really like Firefox, after removing Snap, you actually can no longer install Firefox via Snap or Apt, and the download provided on the Firefox official website does not have a deb package or a desktop shortcut, so it is not very convenient.
So, you can consider using the source provided by Mozilla to install the Debian version of Firefox.
# 添加Mozilla提供的源
sudo add-apt-repository ppa:mozillateam/ppa
# 安装Firefox
sudo apt update
sudo apt install firefox
2.8.Cross-major-version Ubuntu upgrade
A cross-Ubuntu major version upgrade refers to a major version upgrade such as updating from Ubuntu22.04LTS to Ubuntu24.04LTS.
When performing a cross-major-version Ubuntu upgrade, it is recommended to restore snap, and delete snap after the upgrade is complete, to prevent Canonical from causing trouble in the process.
#删掉禁止安装snap的配置文件
sudo rm -rf /etc/apt/preferences.d/nosnap.pref
sudo apt update
sudo apt dist-update
3.Switch the system language to Chinese
(If you really don't like English, you can switch, using KDE6 as an example; others are similar.)


4.Chinese input method
4.1.Sogou (not recommended)(Ubuntu22.04 and below)
Download Sogou Input Method from the official website


Open the terminal and enter the following
cd ~/Downloads/
sudo apt install ./sogoupinyin_4.2.1.145_amd64.deb
Open Fcitx



Add Sogou Input Method


Set Sogou Input Method as the only input method

4.2.Fcitx5(Ubuntu22.04 及 以上、Debian12及以上、Fedora)
- Uninstall the old input method
# Ubuntu或者Debian
sudo apt purge fcitx* ibus*
# Fedora
# 应该不用干任何事,fedora41基本都移除了
- Install Fcitx5
# Ubuntu22.04及以上、Debian12及以上
sudo apt install fcitx5 fcitx5-chinese-addons
# Ubuntu20.04
sudo add-apt-repository ppa:zhsj/fcitx5
sudo apt update
sudo apt install fcitx5 fcitx5-chinese-addons
# Fedora
sudo dnf install fcitx5 fcitx5-chinese-addons fcitx5-autostart
-
Reboot System Restart System
-
Start Fcitx5

- Modify some settings

Add Pinyin and Keyboard - English US to the left. (If you cannot find them, do not check Show only current language on the right.)

Add a shortcut key for easier switching between Chinese and English.

-
Configure environment variables
- If you are KDE+Wayland, you also need the following step (Kubuntu26.04 and above, Debian 13 and above, Rocky 10 and above, Fedora, etc.)


- If you are KDE+X11, you also need the following step (for older versions of most distributions, you can use
fastfetchdepends on the specific one usedx11orwayland)
vim ~/.config/plasma-workspace/env/fcitx5.shexport GTK_IM_MODULE=fcitx export QT_IM_MODULE=fcitx export XMODIFIERS="@im=fcitx" export SDL_IM_MODULE=fcitx export INPUT_METHOD=fcitxthen restart
-
restart
sudo shutdown -r now
- 使用Fcitx5工具箱优化Fcitx5(进入Github自己看说明书安装)
https://github.com/debuggerx01/fcitx5_customizer
# Ubuntu
# 直接在线执行工具箱优化
curl -sSL https://fcitx5.debuggerx.com/fcitx5_customizer.sh | bash -s -- recommend
# Fedora
# 直接在线执行工具箱优化
curl -sSL https://fcitx5.debuggerx.com/fcitx5_customizer.sh | bash -s -- recommend
- Restart again
sudo shutdown -r now
5.pip3 source replacement
This needs to be done for non-Debian-based distributions.
Distributions that use the apt tool, such as Ubuntu and Debian, do not require this operation.
Systems that use dnf (such as Fedora, RHEL, RockyLinux) may also work without doing this.
https://mirrors.tuna.tsinghua.edu.cn/help/pypi/
Type in the order shown in the figure, but unless something unexpected happens, an error will occur, because most distributions do not come with pip, so please continue reading.

#安装pip3
sudo apt update
sudo apt-get install python3-pip
#更新pip3
python3 -m pip install -i https://mirrors.bfsu.edu.cn/pypi/web/simple --upgrade pip
#设置pip源为北京外国语大学镜像源
pip3 config set global.index-url https://mirrors.bfsu.edu.cn/pypi/web/simple
#测试
python3 -m pip install --upgrade pip
If successful, you will see the letters bfsu after Looking.

6.Install RPMFusion and change its source
(Red Hat-based only, i.e., no need to do this for Debian-based systems such as Ubuntu.)
https://mirrors.bfsu.edu.cn/help/rpmfusion/
- First, use the command below to check whether you have enabled RPM Fusion.
rpm -qa | grep rpmfusion

- If it is enabled, first uninstall rpmfusion.
sudo dnf remove rpmfusion-free-release rpmfusion-nonfree-release

-
Install RPM Fusion from Beijing Foreign Studies University
- Fedora
# 安装免费仓库非免费仓库 sudo dnf install --nogpgcheck https://mirrors.bfsu.edu.cn/rpmfusion/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.bfsu.edu.cn/rpmfusion/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm- RHEL、RockyLinux
# 安装免费仓库非免费仓库 sudo dnf install --nogpgcheck https://mirrors.bfsu.edu.cn/rpmfusion/free/fedora/rpmfusion-free-release-$(rpm -E %rhel).noarch.rpm https://mirrors.bfsu.edu.cn/rpmfusion/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %rhel).noarch.rpm -
Change the other RPM Fusion repositories to the BFSU source as well
sudo sed -e 's!^metalink=!#metalink=!g' \
-e 's!^mirrorlist=!#mirrorlist=!g' \
-e 's!^#baseurl=!baseurl=!g' \
-e 's!https\?://download1\.rpmfusion\.org/!https://mirrors.bfsu.edu.cn/rpmfusion/!g' \
-i /etc/yum.repos.d/rpmfusion*.repo
- Check the modified repository
grep "mirrors.bfsu" /etc/yum.repos.d/rpmfusion*.repo
It can be seen that not only have the free and nonfree sources been changed, but NVIDIA and Steam have also been changed.

- Refresh repository cache
sudo dnf clean all
sudo dnf makecache
7.Time not synchronized
Dual-booting causes Ubuntu's time to be 8 hours ahead of Windows, while Windows' time is 8 hours behind Ubuntu, so the issue of system time synchronization needs to be resolved. It is still the same video shared the first time; a later section discusses the issue of time synchronization.
( Tip: Turn on subtitles when watching, because some inexplicable problems will be answered in the bullet comments. )
https://www.bilibili.com/video/BV1554y1n7zv/?vd_source=ceb9c29ca8792358f229b53eef0c1448
8.Graphics card driver installation
8.1.Uninstall the graphics card driver (uninstall it cleanly)
# 如果使用了.run文件进行安装的,再使用下面命令卸载干净
sudo /usr/bin/nvidia-uninstall
# 如果是使用apt安装的驱动
sudo apt-get remove --purge nvidia*
# 如果是使用dnf安装的驱动
sudo dnf remove nvidia*
8.2.Frequently Asked Questions (If you run into problems, come back and check this section)
- Disable the open-source driver nouveau. nouveau often causes stuttering, black screens, and screen corruption, so it should be disabled.
sudo vim /etc/modprobe.d/blacklist-nouveau.conf
blacklist-nouveau.conf文件内容如下:
blacklist nouveau
blacklist lbm-nouveau
options nouveau modeset=0
alias nouveau off
alias lbm-nouveau off
Then run the command below.
# debian系选这个(Ubuntu等)
sudo update-initramfs -u
# 红帽系选这个(Fedora,Rocky等)
sudo dracut --force
# 重启
sudo reboot
After rebooting, check whether nouveau is still enabled. If nothing appears, the disabling was successful.
lsmod | grep nouveau
- Unable to adjust screen brightness, unable to use HDMI port (this is because the xorg file and grub are not configured)(X11 only , for example Ubuntu24.04 and below; those using Wayland such as Fedora cannot use the configuration below.)
First configure xorg
sudo vim /usr/share/X11/xorg.conf.d/10-nvidia.conf
Then change the content in 10-nvidia.conf to the content below and save it, then restart.
Section "OutputClass"
Identifier "nvidia"
MatchDriver "nvidia-drm"
Driver "nvidia"
Option "AllowEmptyInitialConfiguration"
Option "PrimaryGPU" "yes"
ModulePath "/usr/lib/x86_64-linux-gnu/nvidia/xorg"
EndSection
# 或者
Section "OutputClass"
Identifier "nvidia"
MatchDriver "nvidia-drm"
Driver "nvidia"
Option "RegistryDwords" "EnableBrightnessControl=1;PrimaryGPU=1"
Option "Backlight" "nvidia_0"
ModulePath "/usr/lib/x86_64-linux-gnu/nvidia/xorg"
EndSection
Reconfigure GRUB
sudo vim /etc/default/grub
Add the following parameters to the grub parameters. Note that this means adding them, not changing the parameters to these values; the original parameters must be retained.
GRUB_CMDLINE_LINUX_DEFAULT="nvidia.NVreg_EnableBacklightControl=1 acpi_backlight=native video.use_native_backlight=0"

# debian系选这个(Ubuntu等)
sudo update-initramfs -u
#或
sudo update-grub
# 红帽系选这个(Fedora,Rocky等)
sudo dracut --force
sudo reboot
Restart to take effect
- Error prompt when installing NVIDIA graphics card driver
Unable to find the kernel source tree for the currently running kernel. Please make sure you have installed the kernel source files for your kernel and that they are properly configured; on Red Hat Linux systems, for example, be sure you have the 'kernel-source' or 'kernel-devel' RPM installed.If you know the correct kernel source files are installed, you may specify the kernel source path with the '--kernel-source-path' command line option.
- Check the currently running kernel version:
Run the following command to view the kernel version you are currently using:
uname -r
- Install kernel development files:
Ensure that you have installed the kernel-devel package that matches the current kernel version. Run the following command to install it:
sudo dnf install kernel-devel-$(uname -r)
This will automatically install the kernel development package matching your current kernel version.
- Install kernel source code (optional):
If you need to access the complete kernel source code, you can run the following command to install it:
sudo dnf install kernel-headers kernel-source
- Check the installation:
After installation is complete, confirm whether the path is correct. Kernel source files are usually located in the /usr/src/kernels/ directory. You can use the following command to check whether this directory exists:
ls /usr/src/kernels/
If you still encounter problems, you can manually specify the kernel source file path via the --kernel-source-path option.
8.3.Recommended installation method
Below are three methods for installing drivers. The tutorial basically covers all of them, namely the general method, the APT method, and the DNF method.
Beginners are advised to use the APT method (Ubuntu or Debian) or the DNF method (Fedora or RockyLinux) to install NVIDIA drivers , then install CUDA using the general method, and install CUDNN still using the APT or DNF method.
(If you are a beginner, just follow the methods recommended in the table below and install it properly—don't try to be clever.)
| Recommended method for each distribution |
|---|
| NVIDIA Driver |
| CUDA |
| cuDNN |
8.4.APT installation (Method 1: suitable for Debian, Ubuntu, etc.)
8.4.1.Install graphics card driver
With drivers installed this way, there is no need to reinstall the graphics card driver after future kernel updates.
8.4.1.1.Ubuntu
# 安装英伟达驱动
sudo apt install nvidia-driver-版本号
# 重启 (必须重启)
sudo shutdown -r now
# 检查驱动是否安装成功
nvidia-smi
8.4.1.2.Debian
# 安装内核头文件和编译工具
sudo apt install -y linux-headers-amd64 build-essential
# 安装英伟达驱动
sudo apt install nvidia-driver
# 重启
sudo shutdown -r now
# 检查驱动是否安装成功
nvidia-smi
8.4.2.Install CUDA
(Please use Method 1, the general method)
8.4.3.Install cuDNN
Select the CuDNN v9 version (its installation is similar to that of CUDA; you can refer to the official website tutorial for installation)
https://developer.nvidia.com/cudnn-archive
8.5.DNF installation (Method 2: suitable for Fedora, Rocky, etc.)
8.5.1.Install graphics card driver
If we install the graphics card driver in a general way, we will find that every time Fedora updates the kernel, the graphics card driver stops working. How can this problem be solved? Please use DNF to install the graphics card driver.
With the graphics driver installed this way, there is no need to reinstall the graphics driver after future kernel updates. (After installing a new kernel, rebooting will automatically trigger the akmod build process. At this point, the system generates an NVIDIA driver module matching the new kernel.)
Note: before installing the driver, make sure you have not installed the driver using methods such as .run. You can use the nvidia-smi command to check. If it indicates that no driver is installed, that is fine. If it indicates that a driver is currently installed, please uninstall the driver first (there should be an uninstall tutorial above) or wait for the next kernel update (a kernel update will remove drivers installed via .run).
8.5.1.1.Fedora
# 启用 RPM Fusion 仓库(北京外国语源)
sudo dnf install --nogpgcheck https://mirrors.bfsu.edu.cn/rpmfusion/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.bfsu.edu.cn/rpmfusion/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
# 安装驱动和内核工具
sudo dnf install akmod-nvidia # 自动适配内核的驱动(重点)
sudo dnf install xorg-x11-drv-nvidia-cuda # 包含 CUDA 支持
# 重启并验证(这种方式必须重启)
sudo reboot
nvidia-smi # 检查驱动版本(如 570.86.16)
8.5.2.Install CUDA
After installing the graphics card driver via dnf, you can also use the general method to install CUDA, which is also very convenient (CUDA will not be lost after a kernel update).
CUDA installation can also be performed using the following dnf method.
(This tutorial uses Fedora 41 and RTX 3060 Laptop as an example) (Rocky and RHEL are similar)

- First check the maximum CUDA version supported by the graphics card driver.
nvidia-smi
On the left is the NVIDIA driver version, and on the right is the maximum supported CUDA version. Note that this is the maximum version; any CUDA version lower than this can be installed. (No need to pursue the highest, stability is enough, although they are all quite stable.)

- Download CUDA and install CUDA
https://developer.nvidia.com/cuda-toolkit-archive
Select a version; here, take CUDA12.4 as an example (everything framed in green is a version that can be installed on my computer, while those framed in red cannot).

My setup here uses an Intel CPU (X86_64 architecture, also called amd64 architecture), so I choose X86_64. (Both AMD and Intel are X86; if you can't tell them apart, seeVinci Robot Team Microcontroller Tutorial).
I am using Fedora 41, so I chose Fedora 41 (if you are using Rocky Linux, choose Rocky Linux) as shown in the following figure:
https://developer.nvidia.com/cuda-toolkit-archive


Type according to the corresponding part on the website, as shown in my image above:
wget https://developer.download.nvidia.com/compute/cuda/12.8.0/local_installers/cuda-repo-fedora41-12-8-local-12.8.0_570.86.10-1.x86_64.rpm
sudo dnf install ./cuda-repo-fedora41-12-8-local-12.8.0_570.86.10-1.x86_64.rpm
sudo dnf clean all
sudo dnf -y install cuda-toolkit-12-8
Perform environment configuration:
sudo vim ~/.bashrc
Copy the following string into the ~/.bashrc file and save it. Those who do not know how to use the vim editor, please search Baidu yourself.
export PATH=/usr/local/cuda-12.4/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:$LD_LIBRARY_PATH
Or (the one below is more recommended)
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

# 刷新当前终端的环境变量
source ~/.bashrc
# 验证CUDA是否安装成功
nvcc -V
If the following figure appears, the installation is successful.

8.5.3.Install cuDNN
Select the CuDNN v9 version (its installation is similar to that of CUDA; you can refer to the official website tutorial for installation)
https://developer.nvidia.com/cudnn-archive
8.6.General method (Method 3: script or archive method)
If you run into problems, see the Frequently Asked Questions section to check whether there is a corresponding solution. (For Ubuntu, Debian, Fedora, and Rocky, the frequently asked questions should be complete.)
8.6.1.Install graphics card driver
To install using this method, you need to disable nouveau first. Please scroll down and find the **Common Issues (in the one or two sections above)** section, locate the instructions for disabling nouveau, and disable nouveau.
First download the Nvidia driver, download the one with the .run extension
https://www.nvidia.cn/drivers/lookup/


用以下命令停止可视化桌面环境(用ctrl alt f*也可以)(也可以不禁用桌面环境,直接进行下一步。)
# 通用的命令(sudo telinit 5是打开图形界面)
sudo telinit 3
# ubuntu 使用下方命令
sudo service lightdm stop
# Fedora 使用下方命令
sudo systemctl isolate multi-user.target
Afterward, a new command-line session will be entered, and you should log in using the current username and password. (Do not use the root user.)
# 编译环境+准备工作
sudo apt install build-essential
# 进入到.run目录中
cd /home/tungchiahui/Downloads/
# 给驱动文件增加可执行权限:
sudo chmod a+x NVIDIA-Linux-x86_64-550.107.02.run
# 然后执行安装:
sudo ./NVIDIA-Linux-x86_64-550.107.02.run
# 如果有异常则:(一般不用下方这条,会导致OPENGL没法被安装,这样ROS有些功能无法使用)
sudo ./NVIDIA-Linux-x86_64-550.107.02.run --no-opengl-files
Restart after installation is complete.
# 重启
sudo reboot
# 检查驱动是否安装成功
nvidia-smi
8.6.2.Install CUDA
(This tutorial uses Debian 12 Bookworm and RTX 3060 Laptop as an example) (Ubuntu and Fedora are similar)

- First check the maximum CUDA version supported by the graphics card driver.
nvidia-smi
On the left is the NVIDIA driver version, and on the right is the maximum supported CUDA version. Note that this is the maximum version; any CUDA version lower than this can be installed. (No need to pursue the highest, stability is enough, although they are all quite stable.)

- Download CUDA and install CUDA
https://developer.nvidia.com/cuda-toolkit-archive
Select a version; here, take CUDA12.4 as an example (everything framed in green is a version that can be installed on my computer, while those framed in red cannot).

My setup here uses an Intel CPU (X86_64 architecture, also called amd64 architecture), so I choose X86_64. (Both AMD and Intel are X86; if you can't tell them apart, seeVinci Robot Team Microcontroller Tutorial).
I am using Debian 12, so I chose Debian 12 (if you are using Ubuntu, choose Ubuntu), as shown in the figure below. It is recommended to select the runfile file for installation.

Enter the command in the bottom box into the terminal.
# 在当前文件夹下创建一个ttt的子文件夹
mkdir -p ./ttt
# 进入ttt文件夹
cd ttt
# 输入复制的第一条命令(用来下载cuda的runfile文件)
wget https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_550.54.14_linux.run
# 给予权限
sudo chmod a+x ./cuda_12.4.0_550.54.14_linux.run
# 运行脚本
sudo ./cuda_12.4.0_550.54.14_linux.run

Loading:

Input accept to accept.

Since we have already installed the driver, delete this item and just Install. ( Do not check the install driver option , so beginners can avoid unnecessary trouble)

After waiting for a moment, generally if no red text appears, the installation was successful; you can read the English to confirm. (By the way, verify the location.)

- Configure the environment
According to the above, confirm the path, for example, the one I have outlined in a red box above is
Please make sure that - PATH includes /usr/local/cuda-12.4/bin - LD_LIBRARY_PATH includes /usr/local/cuda-12.4/lib64, or, add /usr/local/cuda-12.4/lib64 to /etc/ld.so.conf and run ldconfig as root
If you forgot to check just now, you can also use the command below to view the path:
which nvcc

So I perform the following operation:
sudo vim ~/.bashrc
Copy the following string into the ~/.bashrc file and save it. Those who do not know how to use the vim editor, please search Baidu yourself.
export PATH=/usr/local/cuda-12.4/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:$LD_LIBRARY_PATH
or
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

# 刷新当前终端的环境变量
source ~/.bashrc
# 验证CUDA是否安装成功
nvcc -V
If the following figure appears, the installation is successful.

8.6.3.Install cuDNN **(basically deprecated, see below for how to install CuDNN via apt and dnf)**
- Select and download the appropriate cuDNN version according to the installed CUDA version. Note that registration and login are required here:
https://developer.nvidia.cn/rdp/cudnn-archive#a-collapse805-111
Because I am CUDA12.4, all the versions circled in red below can be installed, and the newer the better. (The highest version on the website above is only v8.9.7; there are even newer versions, so you can skip ahead to the apt and dnf installation methods below.)

Red is common to all Linux systems on the X86 architecture, so I chose the red one.

The green one is Ubuntu for the X86 architecture; those who use Ubuntu with an X86 CPU can choose to download it.
The blue one is Ubuntu for the arm64 (aarch64) architecture; those whose system is Ubuntu and whose CPU is of the arm64 (aarch64) architecture can choose to download it.
I'll choose here the most universal method for all Linux X86_64:
Downloaded:

- Install cuDNN
Locate the directory containing the file, open a terminal, and cd to that directory.

Extract the files and copy them to the corresponding locations to complete the installation.
# 解压cuDNN文件
tar -xvf ./cudnn-linux-x86_64-8.9.7.29_cuda12-archive.tar.xz
# cd进文件夹
cd ./cudnn-linux-x86_64-8.9.7.29_cuda12-archive
# 复制cuDNN文件到CUDA目录
sudo cp include/cudnn* /usr/local/cuda/include
sudo cp lib/libcudnn* /usr/local/cuda/lib64
# 对比一下有没有缺文件
ls /usr/local/cuda/include/cudnn*
ls /usr/local/cuda/lib64/libcudnn*
# 给予权限
sudo chmod a+r /usr/local/cuda/include/cudnn*
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
- Check whether the installation was successful
# 检查cuDNN版本命令
cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
If the following image appears, the installation was successful.

- Soft link
# 运行 ldconfig 以更新库缓存:(如果运行 ldconfig 后没有出现任何错误,说明配置已经完成。)
sudo ldconfig
If the following prompt appears, a symbolic link is required **(if the following prompt does not appear, then nothing needs to be done)**
ldconfig: /usr/local/cuda-12.4/targets/x86_64-linux/lib/libcudnn_cnn_train.so.8 is not a symbolic link
ldconfig: /usr/local/cuda-12.4/targets/x86_64-linux/lib/libcudnn_ops_train.so.8 is not a symbolic link
ldconfig: /usr/local/cuda-12.4/targets/x86_64-linux/lib/libcudnn_ops_infer.so.8 is not a symbolic link
ldconfig: /usr/local/cuda-12.4/targets/x86_64-linux/lib/libcudnn_adv_infer.so.8 is not a symbolic link
ldconfig: /usr/local/cuda-12.4/targets/x86_64-linux/lib/libcudnn_cnn_infer.so.8 is not a symbolic link
ldconfig: /usr/local/cuda-12.4/targets/x86_64-linux/lib/libcudnn.so.8 is not a symbolic link
ldconfig: /usr/local/cuda-12.4/targets/x86_64-linux/lib/libcudnn_adv_train.so.8 is not a symbolic link
Run the command below
# cd进入CUDA路径
cd /usr/local/cuda/targets/x86_64-linux/lib
# 查看本路径下的需要软链接的文件名
ls

As shown above, I need to linklibcudnn_xxx_xxxxx.so.8.9.7andlibcudnn_xxx_xxxxx.so.8andlibcudnn_xxx_xxxxx.sosoft links
# 创建符号链接。对于每个 .so.8 文件,需要创建一个指向该文件的符号链接,通常链接的名称是不包含 .8 的文件名。
sudo ln -sf libcudnn_cnn_train.so.8.9.7 libcudnn_cnn_train.so.8
sudo ln -sf libcudnn_adv_infer.so.8.9.7 libcudnn_adv_infer.so.8
sudo ln -sf libcudnn_adv_train.so.8.9.7 libcudnn_adv_train.so.8
sudo ln -sf libcudnn_cnn_infer.so.8.9.7 libcudnn_cnn_infer.so.8
sudo ln -sf libcudnn.so.8.9.7 libcudnn.so.8
sudo ln -sf libcudnn_ops_infer.so.8.9.7 libcudnn_ops_infer.so.8
sudo ln -sf libcudnn_ops_train.so.8.9.7 libcudnn_ops_train.so.8
# 运行 ldconfig 以更新库缓存:(如果运行 ldconfig 后没有出现任何提示,说明配置已经完成。)
sudo ldconfig
# 使用 ls -l 来确认符号链接是否创建成功:(再次确认链接)
ls -l /usr/local/cuda/targets/x86_64-linux/lib/libcudnn_*.so*