无法使用nvcc

时间:2015-10-20 22:20:11

标签: compilation cuda nvcc luajit torch

我试图从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>

其中&#34; utils.h&#34;是

#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

关于我做错了什么的任何想法?

提前谢谢!

1 个答案:

答案 0 :(得分:1)

看来这个编译命令:

nvcc -o im2col -I/deep/u/ibello/torch/include im2col.cu 

没有为编译器提供必要的搜索路径,以查找位于THGeneral.h

中的/deep/u/ibello/torch/include/TH文件头文件

解决方案是指定一个这样的编译命令:

nvcc -o im2col -I/deep/u/ibello/torch/include -I/deep/u/ibello/torch/include/TH im2col.cu