【问题标题】:Trying to get CUDA working, sample can't find helper_cuda.h试图让 CUDA 工作,示例找不到 helper_cuda.h
【发布时间】:2013-10-21 14:06:47
【问题描述】:

我刚安装了CUDA,一直关注http://docs.nvidia.com/cuda/cuda-getting-started-guide-for-mac-os-x/index.html

在我尝试将 deviceQuery 等示例代码复制到 ~/Desktop 并编译之前,一切正常。

编译时出现以下错误:

/Developer/NVIDIA/CUDA-5.5/bin/nvcc -ccbin g++ -I../../common/inc  -m64 -Xcompiler -arch -Xcompiler x86_64   -gencode arch=compute_10,code=sm_10 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=\"sm_35,compute_35\" -o deviceQuery.o -c deviceQuery.cpp
deviceQuery.cpp:23:25: error: helper_cuda.h: No such file or directory
deviceQuery.cpp: In function ‘int main(int, char**)’:
deviceQuery.cpp:111: error: ‘SPRINTF’ was not declared in this scope
deviceQuery.cpp:116: error: ‘_ConvertSMVer2Cores’ was not declared in this scope
deviceQuery.cpp:206: error: ‘checkCudaErrors’ was not declared in this scope
deviceQuery.cpp:230: error: ‘checkCudaErrors’ was not declared in this scope
deviceQuery.cpp:241: error: ‘checkCudaErrors’ was not declared in this scope
make: *** [deviceQuery.o] Error 1

代码会在CUDA目录下编译运行,很明显编译器找不到helper_cuda.h,我也找不到,有没有人有解决办法?

【问题讨论】:

    标签: compiler-construction cuda compilation compiler-errors


    【解决方案1】:

    http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#environment-setup

    NVIDIA CUDA 工具包包含源代码形式的示例程序。您应该通过更改为 ~/NVIDIA_CUDA-8.0_Samples 并键入 make 来编译它们。生成的二进制文件将放在 ~/NVIDIA_CUDA-8.0_Samples/bin 下

    请确定:

    $ export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}

    $ export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64\ ${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

    $ nvcc -V

    应该显示版本。

    $ cd ~/some_path/NVIDIA_CUDA-8.0_Samples

    $ make

    【讨论】:

      【解决方案2】:

      如您的编译选项-I../../common/inc 所示,helper_cuda.h 位于$CUDA_HOME/samples/common/inc/

      如果要将示例复制到自定义位置,则必须复制整个samples 目录,或修改一些代码/编译选项以将人员包含在common/ 目录中。

      【讨论】:

        猜你喜欢
        • 2020-12-10
        • 2014-03-22
        • 2015-03-16
        • 1970-01-01
        • 1970-01-01
        • 2012-08-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多