Driver: Installed Toolkit: Installed in /usr/local/cuda-12.5/
Please make sure that - PATH includes /usr/local/cuda-12.5/bin - LD_LIBRARY_PATH includes /usr/local/cuda-12.5/lib64, or, add /usr/local/cuda-12.5/lib64 to /etc/ld.so.conf and run ldconfig as root
To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-12.5/bin To uninstall the NVIDIA Driver, run nvidia-uninstall Logfile is /var/log/cuda-installer.log
卸载方式
1 2 3
/usr/local/cuda-12.5/bin/cuda-uninstaller
nvidia-uninstall
可以将 /usr/local/cuda-12.5/bin 加入 PATH
1 2 3 4 5 6
root@imwl:~/snap# /usr/local/cuda-12.5/bin/nvcc -V nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2024 NVIDIA Corporation Built on Wed_Apr_17_19:19:55_PDT_2024 Cuda compilation tools, release 12.5, V12.5.40 Build cuda_12.5.r12.5/compiler.34177558_0
不安装 cuda, 只安装驱动
1 2
chmod +x NVIDIA-Linux-*.run ./NVIDIA-Linux-*.run
验证
1 2
lspci |grep -i nvidia nvidia-smi
卸载
1
nvidia-uninstall
遇到的问题
1 2 3 4
ERROR: You appear to be running an X server; please exit X before installing
× This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install.
If you wish to install a non-Debian-packaged Python package, create a virtual environment using python3 -m venv path/to/venv. Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application, it may be easiest to use pipx install xyz, which will manage a virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.11/README.venv for more information.
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification.
apt install python3-pycuda # 或者虚拟环境中安装
python3 test.py & # 多次执行
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
import pycuda.autoinit from pycuda.compiler import SourceModule import time mod = SourceModule(""" #include <stdio.h> __global__ void work() { printf("Manage GPU success!\\n"); } """) func = mod.get_function("work")
root@test:~# nvidia-smi Sun Jun 9 14:04:51 2024 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 525.147.05 Driver Version: 525.147.05 CUDA Version: 12.0 | |-------------------------------+----------------------+----------------------+ | 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 48C P0 N/A / N/A | 348MiB / 4096MiB | 0% Default | | | | N/A | +-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=============================================================================| | 0 N/A N/A 4559 G /usr/lib/xorg/Xorg 2MiB | | 0 N/A N/A 35606 C python3 30MiB | | 0 N/A N/A 35622 C python3 30MiB | | 0 N/A N/A 35634 C python3 30MiB | | 0 N/A N/A 35648 C python3 30MiB | | 0 N/A N/A 35686 C python3 30MiB | | 0 N/A N/A 35705 C python3 30MiB | | 0 N/A N/A 35718 C python3 30MiB | | 0 N/A N/A 35730 C python3 30MiB | | 0 N/A N/A 35742 C python3 30MiB | | 0 N/A N/A 35756 C python3 30MiB | | 0 N/A N/A 35769 C python3 30MiB | +-----------------------------------------------------------------------------+
Nouveau 开启导致失败
执行关闭操作还是不行,最后重启机器后完成
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Would you like nvidia-installer to attempt to create these modprobe configuration files for you? (Answer: Yes) -> One or more modprobe configuration files to disable Nouveau have been written. You will need to reboot your system and possibly rebuild the initramfs before these changes can take effect. Note if you later wish to reenable Nouveau, you will need to delete these files: /usr/lib/modprobe.d/nvidia-installer-disable-nouveau.conf, /etc/modprobe.d/nvidia-installer-disable-nouveau.conf -> nvidia-installer is not able to perform some of the sanity checks which detect potential installation problems while Nouveau is loaded. Would you like to continue installation without these sanity checks, or abort installation, confirm that Nouveau has been properly disabled, and attempt installation again later? (Answer: Abort installation) -> Nouveau detected in initramfs -> Initramfs scan complete. -> The initramfs will likely need to be rebuilt due to the following condition(s): * nvidia-installer attempted to disable Nouveau. * Nouveau is present in the initramfs.
Would you like to rebuild the initramfs? (Answer: Rebuild initramfs) -> /usr/sbin/update-initramfs requires a file path argument, but none was given. -> Processing the initramfs: -> Executing: /usr/sbin/update-initramfs -u -> done ERROR: Installation has failed. Please see the file '/var/log/nvidia-installer.log' for details. You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com.