anuranbaka / OpenDTAM

An open source implementation of DTAM
Other
286 stars 150 forks source link

OpenCV Error: Gpu API call (invalid device function) #31

Closed stevenleecinetec closed 8 years ago

stevenleecinetec commented 8 years ago

Hi Paul,

Thanks for the software! I have been attempting to try your code out, but unfortunately I can't get it to start properly, and am seeking your help. I am using Ubuntu 12.04.05, CUDA 5.5, GTX960, OpenCV 2.4.9, NVidia driver 352.21. The program stalls after reading scene 49 and dies with the following message with the backport version:

text_file_name = /home/stevenlee/OpenDTAM/Trajectory_30_seconds/scene_048.txt Reading: scene_048.png text_file_name = /home/stevenlee/OpenDTAM/Trajectory_30_seconds/scene_049.txt Reading: scene_049.png using: 1 OpenCV Error: Gpu API call (invalid device function ) in globalWeightedBoundsCostCaller, file /home/stevenlee/OpenDTAM/Cpp/CostVolume/CostVolume.cu, line 25 terminate called after throwing an instance of 'cv::Exception' what(): /home/stevenlee/OpenDTAM/Cpp/CostVolume/CostVolume.cu:25: error: (-217) invalid device function in function globalWeightedBoundsCostCaller

the line is: cudaSafeCall( cudaGetLastError() ); and in the experimental version I get the same error at line 209, which is the same command as above.

For the backport, I changed CMakeLists.txt at line 52 to include opencv_gpu instead of opencv_cudastereo and opencv_cudaimgproc because I had issues. I tried with arch and code in the line 50 as 30 and as 35, but still get the same errors.

Please let me know if there is any further information I can provide. Thank you!

Steven

anuranbaka commented 8 years ago

Hmm. Try setting the architechture to the one for your card, which should be a maxwell card. I think it is 50 rather than 35, but I'm not sure

stevenleecinetec commented 8 years ago

Hi Paul,

Thanks for the reply. With 50, I get: libOpenDTAM.so: undefined reference to `cv::gpu::StreamAccessor::getStream(cv::gpu::Stream const&)' collect2: error: ld returned 1 exit status

Is there anything else I can try?

Thanks,

Steven

anuranbaka commented 8 years ago

Ah good! That just happens when you don't have OpenCV built for CUDA properly. Rebuild it with the CUDA stuff enabled

stevenleecinetec commented 8 years ago

Oh boy, more problems...

OK, so here is the situation:

Does OpenDTAM really need exactly cuda 5.5? Is there a workaround? Thank you again for spending time with me to solve this.

Steven

anuranbaka commented 8 years ago

No problem. There're two workarounds, but I have not tried either. In theory if you compile to ptx, the 3.5 code should work on newer versions. I think you can do this by replacing all "sm_35" with "compute_35". The other possibility is to dig around in cmake and see if you can find the check for 5.5 and try just replacing it with 6.5.

stevenleecinetec commented 8 years ago

I noticed that I built OpenCV with 5.5. Rebuilt with 6.5 and made with compute_50, and it works now. Thanks Paul!