安装Nvidia CUDA时,提示:ERROR: Unable to find the kernel source tree for the currently running kernel.的解决方法

2023-03-27 400 0

按照官网的提示,执行

sudo sh cuda_12.1.0_530.30.02_linux.run

提示:

Installation failed. See log at /var/log/cuda-installer.log for details.

查看提示的log文件

cat /var/log/cuda-installer.log

发现日志中记录如下

[ERROR]: Install of driver component failed. Consult the driver log at /var/log/nvidia-installer.log for more details.
[ERROR]: Install of 530.30.02 failed, quitting

再次查看提示的log文件(怎么感觉开始套娃了~)

cat /var/log/nvidia-installer.log 

发现提示错误(还好还好~)

ERROR: 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.
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.

安装Linux headers

sudo apt install linux-headers-$(uname -r)

再次执行

sudo sh cuda_12.1.0_530.30.02_linux.run

搞定

===========
= Summary =
===========

Driver:   Installed
Toolkit:  Installed in /usr/local/cuda-12.1/

Please make sure that
 -   PATH includes /usr/local/cuda-12.1/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-12.1/lib64, or, add /usr/local/cuda-12.1/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-12.1/bin
To uninstall the NVIDIA Driver, run nvidia-uninstall
Logfile is /var/log/cuda-installer.log

来个图纪念一下

相关文章

Nvidia显卡安装container tool kit
ubuntu安装Nvidia显卡驱动
如何在ubuntu下用非root权限运行docker
linux中切换当前任务到后台

发布评论