我正在关注指导方针在 Ubuntu 18.04 上安装 tensorflow 2 和 CUDA 10 时,添加 NVIDIA 软件包存储库时没有出现错误,但我无法安装 NVIDIA 驱动程序。当我运行:
sudo apt-get install --no-install-recommends nvidia-driver-430
我收到以下错误:
Building for 5.4.0-39-generic
Building for architecture x86_64
Building initial module for 5.4.0-39-generic
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/nvidia-dkms-440.0.crash'
Error! Bad return status for module build on kernel: 5.4.0-39-generic (x86_64)
Consult /var/lib/dkms/nvidia/440.95.01/build/make.log for more information.
...在里面/var/lib/dkms/nvidia/440.95.01/build/make.log
我发现:
DKMS make.log for nvidia-440.95.01 for kernel 5.4.0-39-generic (x86_64)
Tue Jun 30 08:53:44 UTC 2020
make[1]: Entering directory '/usr/src/linux-headers-5.4.0-39-generic'
arch/x86/Makefile:147: CONFIG_X86_X32 enabled but no binutils support
make[1]: cc: Command not found
test -e include/generated/autoconf.h -a -e include/config/auto.conf || ( \
echo >&2; \
echo >&2 " ERROR: Kernel configuration is invalid."; \
echo >&2 " include/generated/autoconf.h or include/config/auto.conf are missing.";\
echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \
echo >&2 ; \
/bin/false)
make -f ./scripts/Makefile.build obj=/var/lib/dkms/nvidia/440.95.01/build \
single-build= \
need-builtin=1 need-modorder=1
The C compiler 'cc' does not appear to be able to
create executables. Please make sure you have
your Linux distribution's gcc and libc development
packages installed.
*** Failed CC sanity check. Bailing out! ***
/var/lib/dkms/nvidia/440.95.01/build/Kbuild:191: recipe for target 'cc_sanity_check' failed
make[2]: *** [cc_sanity_check] Error 1
make[2]: *** Waiting for unfinished jobs....
Makefile:1719: recipe for target '/var/lib/dkms/nvidia/440.95.01/build' failed
make[1]: *** [/var/lib/dkms/nvidia/440.95.01/build] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.4.0-39-generic'
Makefile:81: recipe for target 'modules' failed
make: *** [modules] Error 2
我使用 gcc-7 和 g++-7,其中我使用sudo update-alternatives --config
g++/gcc 进行选择。
的输出uname -a
为:
Linux imt_deep 5.4.0-39-generic #43~18.04.1-Ubuntu SMP Mon Jun 22 19:05:32 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
我该如何解决这个错误?我真的不明白编译器出了什么问题。我也尝试安装驱动程序,将 gcc-5 和 g++-5 设置为默认值update-alternatives --config
,但仍然出现相同的错误。
答案1
首先检查这个错误:
ERROR: Kernel configuration is invalid.
看看这里来解决这个问题:https://stackoverflow.com/questions/8276245/how-to-compile-a-kernel-module-against-a-new-source
然后您需要检查您是否有 build-essentials,因为它告诉您找不到“dev”包。
The C compiler 'cc' does not appear to be able to create executables. Please make sure you have your Linux distribution's gcc and libc development packages installed.
最后,我假设您使用的是 Ubuntu,请按照以下说明操作:https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=deblocal