# 首先测试下运行环境是否正常,主要是GCC是否正常 tzloop@tzloop-GE62-6QC:~$ cat /proc/driver/nvidia/version NVRM version: NVIDIA UNIX x86_64 Kernel Module 440.48.02 Tue Jan 14 06:22:51 UTC 2020 GCC version: gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
# 进入sample所在的目录 tzloop@tzloop-GE62-6QC:~$ cp -r /usr/local/cuda-10.2/samples/ ~ tzloop@tzloop-GE62-6QC:~$ cd ~/samples
# 编译自带的例子 tzloop@tzloop-GE62-6QC:~/samples$ make … … arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75 -o cudaNvSci.o -c cudaNvSci.cpp In file included from cudaNvSci.cpp:12:0: cudaNvSci.h:14:10: fatal error: nvscibuf.h: No such file or directory #include <nvscibuf.h> ^~~~~~~~~~~~ compilation terminated.
注意:这里我们直接使用 make 的话会无法通过对例子的编译,参见 这里 的解释,这是一个已知的错误,我们可以通过 make -k 来忽略过程中的错误。
# 使用 -k 参数来跳过错误 tzloop@tzloop-GE62-6QC:~/samples$ make -k … … mkdir -p ../../bin/x86_64/linux/release cp cuSolverRf ../../bin/x86_64/linux/release make[1]: Leaving directory '/home/tzloop/samples/7_CUDALibraries/cuSolverRf' make: Target 'all' not remade because of errors.
# 最终的测试,如果是PASS则Cuda运行正常 tzloop@tzloop-GE62-6QC:~/samples/bin/x86_64/linux/release$ ./deviceQuery ./deviceQuery Starting... CUDA Device Query (Runtime API) version (CUDART static linking) Detected 1 CUDA Capable device(s) Device 0: "GeForce GTX 960M" CUDA Driver Version / Runtime Version 10.2 / 10.2 … … Compute Mode: < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) > deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 10.2, CUDA Runtime Version = 10.2, NumDevs = 1 Result = PASS