vasgaowei / pytorch_MELM

The pytorch implementation of the Min-Entropy Latent Model for Weakly Supervised Object Detection
104 stars 19 forks source link

cudaCheckError() failed : no kernel image is available for execution on the device #12

Closed kenanozturk closed 5 years ago

kenanozturk commented 5 years ago

Hi all,

I am trying to run the code and get this error. I searched online but couldnt solve the problem. Any recommendations?

I use a TitanV with conda installed cudatoolkit==9.0

vasgaowei commented 5 years ago
  1. I meet the same error when I run my code in Tesla V100. Titan V and Tesla V100 are all Vlota architecture. So I use Tesla P100 and GTX 1080TI to run my code. Of course you can run your code in Tesla V100 or Titan V.
  2. I think you can try to modify some codes in 'layer_utils/roi_pooling/src/roi_pooling_kernel.cu' if you want to run your code in Tesla V100 or Titan V. Before the __global__ void RoIPoolForward() function, add a line of code template <typename Dtype> . And the parameters like const float* bottom_rois become const Dtype* bottom_rois. Change all the float type data into 'Dtype'. See the following for an overview. That is the original code: __global__ void ROIPoolForward(const int nthreads, const float* bottom_data, const float spatial_scale, const int height, const int width, const int channels, const int pooled_height, const int pooled_width, const float* bottom_rois, float* top_data, int* argmax_data) After modifications, the code becomes like the following: template <typename Dtype> __global__ void ROIPoolForward(const int nthreads, const Dtype* bottom_data, const Dtype spatial_scale, const int height, const int width, const int channels, const int pooled_height, const int pooled_width, const Dtype* bottom_rois, Dtype* top_data, int* argmax_data) Do the same modifications to __global__ void ROIPoolBackward() function
  3. Make a summary. We can just do the same modifications to two functions: __global__ void ROIPoolForward(), __global__ void ROIPoolBackward() . Remenber only this '.py' file and only its two functions. Before the functions, add a line template <typename Dtype>, and change all the 'float' type data into 'Dtype' type data. It will work.
vasgaowei commented 5 years ago

It will work. If it doesn't, you can add a line in make.sh file. The original code is CUDA_ARCH="-gencode arch=compute_30,code=sm_30 \ -gencode arch=compute_35,code=sm_35 \ -gencode arch=compute_37,code=sm_37 \ -gencode arch=compute_50,code=sm_50 \ -gencode arch=compute_52,code=sm_52 \ -gencode arch=compute_60,code=sm_60 \ -gencode arch=compute_61,code=sm_61" After add a line it becomes CUDA_ARCH="-gencode arch=compute_30,code=sm_30 \ -gencode arch=compute_35,code=sm_35 \ -gencode arch=compute_37,code=sm_37 \ -gencode arch=compute_50,code=sm_50 \ -gencode arch=compute_52,code=sm_52 \ -gencode arch=compute_60,code=sm_60 \ -gencode arch=compute_61,code=sm_61 \ -gencode arch=compute_70,code=sm_70" ` Then recompile your cuda code

vasgaowei commented 5 years ago

Hi, I update the make.sh file in lib file. And the build.py in lib/layer_utils/roi_pooling/ is also updated. You can fetch the new make.sh file and the build.py file. And recompile the cuda code again. I'm sure it will work.

kenanozturk commented 5 years ago

Hello.

Thank you for your extensive efforts.

I realized the actual problem was that I had two different local cuda installations 8.0 and 9.0. Default path was directed to 8.0. So I did: LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64:$LD_LIBRARY_PATH PATH=/usr/local/cuda-9.0/bin:$PATH and the problem is solved without modifying "layer_utils/roi_pooling/src/roi_pooling_kernel.cu"

Cheers