使用带有Eigen的CUDA时找不到math_functions.hpp

Lin*_*Cai 3 c++ cuda eigen

我有一些严重依赖于Eigen的代码.我想用CUDA优化它,但是当我编译时,我得到:

[tcai4@golubh4 Try1]$ nvcc conv_parallel.cu -I /home/tcai4/project-cse/Try1 -lfftw3 -o conv.o
In file included from Eigen/Dense:1,
             from Eigen/Eigen:1,
             from functions.h:8,
             from conv_parallel.cu:10:
Eigen/Core:44:34: error: math_functions.hpp: No such file or directory
Run Code Online (Sandbox Code Playgroud)

我认为math_functions.hpp是来自CUDA的文件.有人能帮我搞清楚为什么nvcc找不到它?

编辑:我使用CUDA 5.5和Eigen 3.3,除了链接Eigen和fftw3库,我没有使用任何其他标志(你可以从我的代码中看到).

lyo*_*omi 22

我在使用Cuda 9.1构建TensorFlow 1.4.1时遇到了这个问题,并且奇怪地math_functions.hpp只存在于include/crt.

创建符号链接cuda/include/math_functions.hppcuda/include/crt/math_functions.hpp修复问题:

ln -s /usr/local/cuda/include/crt/math_functions.hpp /usr/local/cuda/include/math_functions.hpp
Run Code Online (Sandbox Code Playgroud)

  • 谢谢!这很有效.为方便起见,命令为:`ln -s /usr/local/cuda/include/crt/math_functions.hpp/usr/local/cuda/include/math_functions.hpp` (10认同)

tal*_*ies 4

nvcc 找不到有问题的文件的原因是因为该文件是 CUDA 数学库的一部分,该库是在 CUDA 6 中引入的。您的 CUDA 版本已近 4 年,早于数学库的发布。您的 CUDA 版本不包含该文件。

因此,您应该假设,如果不先更新到较新版本的 CUDA 工具包,您尝试执行的操作就无法工作。