Faster-rcnn.pytorch编译问题error: command'...\\CUDA\\v9.0\\bin\\nvcc.exe' failed with exit status 1

参考代码:https://github.com/potterhsu/easy-faster-rcnn.pytorch

最近在实现Faster RCNN过程中,遇到了不少问题,最令人头疼的问题就是很多GitHub上的源码都在linux系统下编译的,windows系统上会报错,尤其是需要编译C++模块时。

运行easy-faster-rcnn.pytorch-master/support/setup.py时,报错如下:

F:/study/easy-faster-rcnn.pytorch-master/support/src/cuda/ROIAlign_cuda.cu(280): error: no instance of function template "THCCeilDiv" matches the argument list
            argument types are: (long long, long)

F:/study/easy-faster-rcnn.pytorch-master/support/src/cuda/ROIAlign_cuda.cu(280): error: no instance of overloaded function "std::min" matches the argument list
            argument types are: (<error-type>, long)

F:/study/easy-faster-rcnn.pytorch-master/support/src/cuda/ROIAlign_cuda.cu(327): error: no instance of function template "THCCeilDiv" matches the argument list
            argument types are: (int64_t, long)

F:/stud/easy-faster-rcnn.pytorch-master/support/src/cuda/ROIAlign_cuda.cu(327): error: no instance of overloaded function "std::min" matches the argument list
            argument types are: (<error-type>, long)

4 errors detected in the compilation of "C:/Users/����֮/AppData/Local/Temp/tmpxft_000032d8_00000000-10_ROIAlign_cuda.cpp1.ii".
ROIAlign_cuda.cu
error: command 'C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v9.0\\bin\\nvcc.exe' failed with exit status 1

出现这个错误的原因是,数据类型不对,无法编译通过。

解决方案如下:
打开easy-faster-rcnn.pytorch-master/support/src/cuda/ROIAlign_cuda.cu

// line14
/* added function */
int ceil_div_2(int a, int b){
    return (a + b - 1) / b;
}
// line275
dim3 grid(std::min(ceil_div((int)output_size, 512), 4096));

// line 320
dim3 grid(std::min(ceil_div((int)grad.numel(), 512), 4096));

参考:https://github.com/facebookresearch/maskrcnn-benchmark/issues/254
具体代码改动在这里

还有另外一种简单的改动方法:

// line 275
dim3 grid(std::min(THCCeilDiv((long)output_size, 512L), 4096L));
// line 320
dim3 grid(std::min(THCCeilDiv((long)grad.numel(), 512L), 4096L));

参考:https://github.com/facebookresearch/maskrcnn-benchmark/pull/409
具体代码在这里

强制类型转换之后数据类型不会报错了。

又出现了新的错误

copying build\lib.win-amd64-3.6\support\_C.cp36-win_amd64.pyd -> support
error: could not create 'support\_C.cp36-win_amd64.pyd': No such file or directory

目前还没针对这个问题的方案,记录下,有了解决方案再来更新。

  • 6
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值