Pytorch運行官方maskrcnn-benchmark,
問題
和官網上的位置不同,我的報錯在這個位置,SigmoidFocalLoss_cuda.cu,報錯內容如下,
....
e:/AMaskRCNN/maskrcnn-benchmark/maskrcnn_benchmark/csrc/cuda/SigmoidFocalLoss_cuda.cu(120): error: no instance of function template "THCCeilDiv" matches the argument list
argument types are: (long long, long)
e:/AMaskRCNN/maskrcnn-benchmark/maskrcnn_benchmark/csrc/cuda/SigmoidFocalLoss_cuda.cu(120): error: no instance of overloaded function "std::min" matches the argument list
argument types are: (<error-type>, long)
e:/AMaskRCNN/maskrcnn-benchmark/maskrcnn_benchmark/csrc/cuda/SigmoidFocalLoss_cuda.cu(164): error: no instance of function template "THCCeilDiv" matches the argument list
argument types are: (long long, long)
e:/AMaskRCNN/maskrcnn-benchmark/maskrcnn_benchmark/csrc/cuda/SigmoidFocalLoss_cuda.cu(164): 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/ADMINI~1/AppData/Local/Temp/tmpxft_00000788_00000000-10_SigmoidFocalLoss_cuda.cpp1.ii".
....
首先說一下官網的解決方案
https://github.com/facebookresearch/maskrcnn-benchmark/issues/254
該解決方案主要是針對ROIAlign_cuda.cu和ROIPool_cuda.cu,目前我剛編譯的版本這兩個文件沒有出現問題。
解決方案
修改了SigmoidFocalLoss_cuda.cu的3個地方:
/* added function in the front part of the file*/
int ceil_div(int a, int b){
return (a + b - 1) / b;
}
/* replace the line/row 120 in function : SigmoidFocalLoss_forward_cuda*/
dim3 grid(std::min(ceil_div((int)losses_size, 512), 4096));
//dim3 grid(std::min(THCCeilDiv(losses_size, 512L), 4096L));
/*replace the second line/row 164 in function: SigmoidFocalLoss_backward_cuda*/
dim3 grid(std::min(ceil_div((int)d_logits_size, 512), 4096));
//dim3 grid(std::min(THCCeilDiv(d_logits_size, 512L), 4096L));
然後把maskrcnn-benchmark下面那個build裏面的東西刪除乾淨(前面生成沒能成功的文件在這裏會造成干擾,刪除掉!!!)
就可以正常安裝了,
python setup.py install
如果想對其中的python源碼進行調試,則需要用指令,
python setup.py build develop
當然,在已經install的前提下,你不需要重新編譯,因爲文件其實都是已經準備好了的,你只需要build develop一下,完成拷貝鏈接即可。