首页 > 解决方案 > 用于 linux 的 Nvidia 驱动程序找不到 kernel.h 文件

问题描述

我知道我的 kernel.h 文件在 /usr/include/linux/ 中,但是这个 Nvidia 程序找不到它,然后它要求我使用 --kernel-source-path 参数运行它,我确实给了它那个路径和它不起作用它说找不到它,因为它不会采取正确的路径运行它只是通过

./nvidia.run

回报:

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.

然后运行它

./nvidia.run --kernel-source-path /usr/include/linux/

回报:

ERROR: The kernel header file '/usr/include/linux//include/linux/kernel.h'
does not exist. The most likely reason for this is that the kernel
source path '/usr/include/linux/' is incorrect. 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.

我的第一个想法是从地址中删除 /include/linux/ 但告诉它去路径 /usr/ 只是告诉我它是无效的。kernel.h 文件确实在 /usr/include/linux/kernel.h 中,但我无法读取它。

ERROR: The kernel source path '/usr/' is invalid. 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.

标签: linux-kernel

解决方案


根据https://ubuntuforums.org/showthread.php?t=843914可以试试

sudo apt update
sudo apt install linux-headers-`uname -r`

推荐阅读