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

问题描述 投票:3回答:2

我有一些严重依赖于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

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

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

c++ cuda eigen
2个回答
3
投票

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

因此,您应该假设在没有首先更新到较新版本的CUDA工具包的情况下,您尝试执行的操作无法工作。


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
© www.soinside.com 2019 - 2024. All rights reserved.