安装 cuda 8.0 后无法运行 CUDA 示例

安装 cuda 8.0 后无法运行 CUDA 示例

我按照以下步骤在 ubuntu 16 上安装了 cuba8.0这里

然后执行确认测量。之后,我运行 make 并遇到如下错误:

$make

...

nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
/usr/bin/ld: cannot find -lnvcuvid

collect2: error: ld returned 1 exit status

Makefile:381: recipe for target 'cudaDecodeGL' failed

make[1]: *** [cudaDecodeGL] Error 1

make[1]: Leaving directory '/home/cocadas/Workspace/NVIDIA_CUDA-8.0_Samples/3_Imaging/cudaDecodeGL'

Makefile:52: recipe for target '3_Imaging/cudaDecodeGL/Makefile.ph_build' failed
make: *** [3_Imaging/cudaDecodeGL/Makefile.ph_build] Error 2

然后我查看了系统的信息

环境

$ printenv PATH
/usr/local/cuda-8.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/cocadas/Program/android-studio/bin

$ echo $LD_LIBRARY_PATH
/usr/local/cuda-8.0/lib64:/usr/local/cuda-8.0/lib64

操作系统

$ uname -m
x86_64

$ uname -r
4.4.0-64-generic

其他的

$ lspci |grep -i nvidia
01:00.0 VGA compatible controller: NVIDIA Corporation GK107GLM [Quadro K1100M] (rev a1)

$ gcc --version

gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ sudo apt-get install linux-headers-$(uname -r)
[sudo] password for cocadas: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
linux-headers-4.4.0-64-generic is already the newest version (4.4.0-64.85).
linux-headers-4.4.0-64-generic set to manually installed.
The following packages were automatically installed and are no longer required:
  linux-headers-4.4.0-53 linux-headers-4.4.0-53-generic linux-image-4.4.0-53-generic
  linux-image-extra-4.4.0-53-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 99 not upgraded.
$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module  375.26  Thu Dec  8 18:36:43 PST 2016
GCC version:  gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 

$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2016 NVIDIA Corporation
Built on Tue_Jan_10_13:22:03_CST_2017
Cuda compilation tools, release 8.0, V8.0.61

那么,我还能尝试什么?

答案1

示例的 makefile 中的 nvidia-xxx 版本号有误。请用:替换它们 sed -i "s/nvidia-367/nvidia-375/g" `grep "nvidia-367" -r ./ -l` ,然后尝试重新 make。

答案2

我使用了这篇文章中的方法:cuda-示例-构建错误。我认为你只需要替换正确的 gpu 驱动程序版本UBUNTU_PKG_NAME = "nvidia-375",你可以在

.../NVIDIA_CUDA-8.0_Samples/3_Imaging/cudaDecodeGL/findgllib.mk 文件

答案3

根本原因是链接器找不到 libnvcuvid,并且 make 文件的驱动程序版本应为 375(如帖子中所示)。因此,在文件夹中使用以下命令:

~/NVIDIA_CUDA-8.0_Samples/$find . -type f -execdir sed -i 's/UBUNTU_PKG_NAME = "nvidia-367"/UBUNTU_PKG_NAME = "nvidia-375"/g' '{}' \;

答案4

这可能只限于 9.0 版本,但最新的脚本似乎会查询您通过 dpkg 安装了哪个驱动程序。如果您安装了多个驱动程序,它似乎会 grep 第一个找到的驱动程序,这往往是较旧的版本。

我只需要通过以下方式卸载一些较旧的驱动程序(不再使用):

# NOTE: your driver versions may vary

sudo apt-get remove nvidia-367
sudo apt-get remove nvidia-375

相关内容