显卡驱动是共享的,不需要安装,但是需要禁用内核更新
sudo apt-mark hold linux-image-generic linux-headers-generic
禁止内核更新。Thu Jan 19 16:23:40 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 517.00 Driver Version: 517.00 CUDA Version: 11.7 |
|-------------------------------+----------------------+----------------------+
| GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... WDDM | 00000000:01:00.0 Off | N/A |
| N/A 30C P0 23W / N/A | 0MiB / 6144MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
sudo apt update
sudo apt install gcc``sudo apt install make
sudo ./cuda_11.3.1_465.19.01_linux.run
需要等待好一会如果报错,查看错误原因 cat /var/log/cuda-installer.log
解决:
[ERROR]: unsupported compiler version: 11.3.0. Use --override to override this check.
sudo ./cuda_11.3.1_465.19.01_linux.run --override
再次等待一会。会一段时间无响应。┌──────────────────────────────────────────────────────────────────────────────┐
│ End User License Agreement │
│ -------------------------- │
│ │
│ The CUDA Toolkit End User License Agreement applies to the │
│ NVIDIA CUDA Toolkit, the NVIDIA CUDA Samples, the NVIDIA │
│ Display Driver, NVIDIA Nsight tools (Visual Studio Edition), │
│ and the associated documentation on CUDA APIs, programming │
│ model and development tools. If you do not agree with the │
│ terms and conditions of the license agreement, then do not │
│ download or use the software. │
│ │
│ Last updated: Mar 24, 2021. │
│ │
│ │
│ Preface │
│ ------- │
│ │
│ The Software License Agreement in Chapter 1 and the Supplement │
│ in Chapter 2 contain license terms and conditions that govern │
│ the use of NVIDIA software. By accepting this agreement, you │
│──────────────────────────────────────────────────────────────────────────────│
│ Do you accept the above EULA? (accept/decline/quit): │
│ │
└──────────────────────────────────────────────────────────────────────────────┘
CUDA Installer │
│ + [X] CUDA Toolkit 11.3 │
│ [X] CUDA Samples 11.3 │
│ [X] CUDA Demo Suite 11.3 │
│ [X] CUDA Documentation 11.3 │
│ Options │
│ Install
===========
= Summary =
===========
Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-11.3/
Samples: Installed in /home/swift/, but missing recommended libraries
Please make sure that
- PATH includes /usr/local/cuda-11.3/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-11.3/lib64, or, add /usr/local/cuda-11.3/lib64 to /etc/ld.so.conf and run ldconfig as root
To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-11.3/bin
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 465.00 is required for CUDA 11.3 functionality to work.
To install the driver using this installer, run the following command, replacing with the name of this run file:
sudo .run --silent --driver
Logfile is /var/log/cuda-installer.log
nvcc -V
报错swift@LAPTOP-3N6UNIUA:/mnt/d/download/idm$ nvcc -V
Command 'nvcc' not found, but can be installed with:
sudo apt install nvidia-cuda-toolkit
vim ~/.bashrc
添加到最后。export PATH=/usr/local/cuda-11.3/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.3/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
source ~/.bashrc
nvcc -V
之后就能显示swift@LAPTOP-3N6UNIUA:/mnt/d/download/idm$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2021 NVIDIA Corporation
Built on Mon_May__3_19:15:13_PDT_2021
Cuda compilation tools, release 11.3, V11.3.109
Build cuda_11.3.r11.3/compiler.29920130_0
cudnn-linux-x86_64-8.6.0.163_cuda11-archive.tar.xz
tar -xvf cudnn-linux-x86_64-8.6.0.163_cuda11-archive.tar.xz
cd cudnn-linux-x86_64-8.6.0.163_cuda11-archive
)解压有点慢。sudo cp ./lib/* /usr/local/cuda-11.3/lib64/
sudo cp ./include/* /usr/local/cuda-11.3/include/
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
vim ~/.bashrc
添加下面的内容export LD_LIBRARY_PATH=/usr/local/cuda-11.3/targets/x86_64-linux/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
source ~/.bashrc
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
vim ~/.bashrc
修改cuda-11.3的版本号export PATH=/usr/local/cuda-11.3/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.3/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.3/targets/x86_64-linux/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
source ~/.bashrc