[Solved] error: ROIAlign_cuda.cu(275): error: no instance of function template “THCCeilDiv“ matches

Resolve roialign_ Cuda.cu and roipool_ Cuda.cu compilation error (two problems encountered)

Error 1:

D:/python/frankmocap-master/frankmocap-master/detectors/hand_object_detector/lib/model/csrc/cuda/ROIAlign_cuda.cu(275): error: no instance of function template "THCCeilDiv" matches the argument list
            argument types are: (long long, long)

D:/python/frankmocap-master/frankmocap-master/detectors/hand_object_detector/lib/model/csrc/cuda/ROIAlign_cuda.cu(275): error: no instance of overloaded function "std::min" matches the argument list
            argument types are: (<error-type>, long)

D:/python/frankmocap-master/frankmocap-master/detectors/hand_object_detector/lib/model/csrc/cuda/ROIAlign_cuda.cu(320): error: no instance of function template "THCCeilDiv" matches the argument list
            argument types are: (int64_t, long)

D:/python/frankmocap-master/frankmocap-master/detectors/hand_object_detector/lib/model/csrc/cuda/ROIAlign_cuda.cu(320): 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/18295/AppData/Local/Temp/tmpxft_00003514_00000000-10_ROIAlign_cuda.cpp1.ii"

Solution:

Modify maskscoring_ rcnn/maskrcnn_ benchmark/csrc/cuda/ROIAlign_ Cuda.culine 275:

//Original code: dim3 grid(std::min(THCCeilDiv(output_size, 512L), 4096L));
dim3 grid(std::min(((int)output_size + 512 -1)/512, 4096));

Mask scoring/maskrcnn benchmark/csrc/cuda/ROIAlign cuda.cu3203

//Original code: dim3 grid(std::min(THCCeilDiv(grad.numel(), 512L), 4096L));
dim3 grid(std::min(((int)(grad.numel()) + 512 -1)/512, 4096));

Modify maskscoring_rcnn/maskrcnn_benchmark/csrc/cuda/ROIPool_cuda.cu Line129:

// dim3 grid(std::min(THCCeilDiv(output_size, 512L), 4096L));
dim3 grid(std::min(((int)output_size + 512 -1)/512, 4096));

Modify maskscoring_rcnn/maskrcnn_benchmark/csrc/cuda/ROIPool_cuda.cu line 176:

//dim3 grid(std::min(THCCeilDiv(grad.numel(), 512L), 4096L));
dim3 grid(std::min(((int)(grad.numel()) + 512 -1)/512, 4096));

After modification, execute Python setup.py build development

Error 2:

error: ROIAlign_ Cuda.cu and roipool_ “In cuda.cu file”__ Floorf “and”__ Ceilf “error

error: calling a __host__ function("__floorf") from a __device__ 
function("get_coordinate_weight<float> ") is not allowed
error: identifier "__floorf" is undefined in device code

error: calling a __host__ function("__ceilf") from a __global__ 
function("detectron2::RoIAlignRotatedForward<float> ") is not allowed
error: identifier "__ceilf" is undefined in device code

Solution:

Find roialign_ Cuda.cu and roipool_ Cuda.cu file, add F after ceil and floor , that is, ceil is changed to ceilf , floor is changed to floor
the successful implementation is as follows:


Read More: