【发布时间】:2016-01-19 18:29:48
【问题描述】:
我正在尝试从 luaJIT (Torch) 调用一些 CUDA 代码,但我遇到了编译问题。 nvcc 似乎无法找到我的 Torch 头文件。我有 CUDA 6.5 和 gcc 4.4.7。
nvcc -o im2col -I/deep/u/ibello/torch/include im2col.cu
In file included from /deep/u/ibello/torch/include/THC/THC.h:4,
from utils.h:6,
from im2col.cu:1:
/deep/u/ibello/torch/include/THC/THCGeneral.h:4:23: error: THGeneral.h: No such file or directory
/deep/u/ibello/torch/include/THC/THCGeneral.h:5:25: error: THAllocator.h: No such file or directory
In file included from /deep/u/ibello/torch/include/THC/THC.h:7,
from utils.h:6,
from im2col.cu:1:
/deep/u/ibello/torch/include/THC/THCStorage.h:4:23: error: THStorage.h: No such file or directory
In file included from /deep/u/ibello/torch/include/THC/THC.h:9,
from utils.h:6,
from im2col.cu:1:
im2col.cu 包含以下内容
#include "utils.h"
#include "common.h"
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
“utils.h”在哪里
#ifndef CUNN_UTILS_H
#define CUNN_UTILS_H
extern "C" { #include <lua.h> }
#include <luaT.h>
#include <THC/THC.h>
THCState* getCutorchState(lua_State* L);
#endif
这比较奇怪,因为提到的文件确实在我给编译器的包含位置..
ls /deep/u/ibello/torch/include/THC
THCAllocator.h THCDeviceTensor.cuh THCDeviceTensorUtils-inl.cuh THC.h THCReduce.cuh THCTensorConv.h THCTensorMath.h
THCApply.cuh THCDeviceTensor-inl.cuh THCDeviceUtils.cuh THCReduceAll.cuh THCStorageCopy.h THCTensorCopy.h THCTensorRandom.h
THCBlas.h THCDeviceTensorUtils.cuh THCGeneral.h THCReduceApplyUtils.cuh THCStorage.h THCTensor.h THCTensorSort.h
关于我做错了什么有什么想法吗?
提前谢谢!
【问题讨论】:
-
它正在寻找
THGeneral.h并且您已经显示了THCGeneral.h的位置。这些不是同一个文件。也许您还需要包含THGeneral.h和其他类似文件的路径:-I/deep/u/ibello/torch/path/to/THGeneral.h -
这就是问题所在! THGeneral.h 在我提供的路径的子目录中,所以不知道为什么这不起作用..
-
编译器不会搜索您提供的路径的所有子目录。他们只搜索您提供的目录。
-
THC 文件位于 ..../torch/include/THC,而 TH 文件位于 ..../torch/include/TH。在这里,编译器能够找到 THC 文件,但不能找到 TH 文件(它们是从 THC 文件中#included 的)。所以编译器至少能够搜索到 THC 子目录
-
当您指定
-I/deep/u/ibello/torch/include时,编译器找到了进入.../include/THC的方式,因为这个构造:#include <THC/THC.h>一旦它“在那个目录中”,可能会发现来自THC.h的其他文件在 THC.h 所在的目录中。如果您仔细阅读您的帖子,您可以看到这一点。但是,这些机制都不允许它发现.../include/TH中的文件,除非您将其指向那里,或者包含文件指定了部分路径,例如#include "../TH/THGeneral.h"
标签: compilation cuda nvcc luajit torch