我不明白为什么这似乎失败了2的错误:
char debugText [256];
sprintf (debugText, "C:\\List.txt");
dfile = fopen( debugText, "w");
fprintf ( dfile, " err %d \n", errno);
Run Code Online (Sandbox Code Playgroud)
我说似乎是因为当dfile为NULL时,文件被创建并填充我的输出.
那么发生了什么 ?
使用 Cuda 5.0,VS2010
该项目在 VS2012 中编译和链接正常,但 VS2012 不支持 Nsight 调试,所以我也在 VS2010 中开发。所以我有一个 VS2010 项目文件,但我使用的是相同的源代码文件(.h、.cpp、.cu、.cuh。
VS2010 build 编译一切正常,但链接报告错误与未解析的外部:
Generating Code...
1>videoFuncUnThread.obj : error LNK2019: unresolved external symbol _runKernel referenced in function "void __cdecl videoFuncUnThread(int,bool,unsigned int * const)" (?videoFuncUnThread@@YAXH_NQAI@Z)
1>D:\StrApp\Viper1B_10\Viper1B_10\Debug\Viper1B_10.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
Run Code Online (Sandbox Code Playgroud)
缺少的符号 runKernel 是调用设备端模块(驻留在 PTX 文件中)的主机端模块。
当我搜索 runKernel 的所有出现时,我得到 3 行:
filter.cu(127): extern "C" CUresult runKernel (int numFrames, cudaStream_t stream, bool firstBatch, int* searchLimit) { ... } // module code
videofuncunthread.cpp(28): extern …
Run Code Online (Sandbox Code Playgroud) 我已经为其他应用程序做了这个,但由于某种原因它不能在我当前的应用程序中工作.
这是一个使用Cuda 4.2在VS2010中工作的代码片段.我已经在VS内部和VS外部编译了ptx文件而没有解决问题:
CUmodule Module = NULL;
int rc7 = cuModuleLoad(&Module, CubinName); // needs bin
if (rc7 == 0) {
rc = cuModuleGetFunction( &cuF_makeProcFrame, Module, "makeProcFrame" );
}
Run Code Online (Sandbox Code Playgroud)
我得到rc = 500 - 找不到功能.
当我在文本编辑器中打开ptx文件时,我看到:
.entry _Z13makeProcFrame14cudaPitchedPtriiii(
.param .align 4 .b8 _Z13makeProcFrame14cudaPitchedPtriiii_param_0[16],
.param .u32 _Z13makeProcFrame14cudaPitchedPtriiii_param_1,
.param .u32 _Z13makeProcFrame14cudaPitchedPtriiii_param_2,
.param .u32 _Z13makeProcFrame14cudaPitchedPtriiii_param_3,
.param .u32 _Z13makeProcFrame14cudaPitchedPtriiii_param_4
)
Run Code Online (Sandbox Code Playgroud)
最后在CUDA代码中,这里是被调用的行:
__global__ void makeProcFrame(
cudaPitchedPtr YProcBasePtr,
int numFrames,
int width,
int height,
int lineBytes
)
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我为什么我得到错误返回而不是找到功能?
编辑:这是用于编译的批处理文件:
"C:\ Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.2\bin \nvcc.exe"-gencode = arch …