vlfeat / matconvnet

MatConvNet: CNNs for MATLAB
Other
1.4k stars 753 forks source link

Compiling with CUDA 8.0 #575

Closed jlee614 closed 8 years ago

jlee614 commented 8 years ago

Hi,

I downloaded the last version of MatConvNet (ver1.0-beta20) and tried compiling with GPU support.

I have a GTX1080 card which requires CUDA 8.0 (otherwise there's an error: "nvcc fatal : Unsupported gpu architecture 'compute_61' ")

Anyways, when I try to compile with CUDA 8.0, it seems to work for the most part but then I get the following:

vl_compilenn: CUDA: MEX config file: 'C:\Program Files\MATLAB\R2016a\toolbox\distcomp\gpu\extern\src\mex\win64\mex_CUDA_win64.xml' data.cu datamex.cu nnconv.cu nnfullyconnected.cu nnsubsample.cu nnpooling.cu nnnormalize.cu nnbnorm.cu nnbias.cu nnbilinearsampler.cu Building with 'Microsoft Visual C++ 2013 Professional'. MEX completed successfully. Building with 'Microsoft Visual C++ 2013 Professional'. MEX completed successfully. Building with 'Microsoft Visual C++ 2013 Professional'. MEX completed successfully. Building with 'Microsoft Visual C++ 2013 Professional'. MEX completed successfully. Building with 'Microsoft Visual C++ 2013 Professional'. MEX completed successfully. Building with 'Microsoft Visual C++ 2013 Professional'. MEX completed successfully. Building with 'Microsoft Visual C++ 2013 Professional'. MEX completed successfully. Building with 'Microsoft Visual C++ 2013 Professional'. MEX completed successfully. Building with 'Microsoft Visual C++ 2013 Professional'. MEX completed successfully. im2row_gpu.cu subsample_gpu.cu copy_gpu.cu *> C:/Users/Justin/Documents/MATLAB/matconvnet-1.0-beta20/matlab/src/bits/impl/pooling_gpu.cu(163): error: function "atomicAdd(double , double)" has already been defined**

1 error detected in the compilation of "C:/Users/Justin/AppData/Local/Temp/tmpxft_00001afc_00000000-8_pooling_gpu.cpp1.ii". pooling_gpu.cu Error using vl_compilenn>nvcc_compile (line 521) Command "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\nvcc" -c "C:\Users\Justin\Documents\MATLAB\matconvnet-1.0-beta20\matlab\src\bits\impl\pooling_gpu.cu" -DNDEBUG -DENABLE_GPU -DENABLE_DOUBLE -DSSSE3 -gencode=arch=compute_61,code=\"sm_61,compute_61\" -I"C:\Program Files\MATLAB\R2016a\extern\include" -I"C:\Program Files\MATLAB\R2016a\toolbox\distcomp\gpu\extern\include" -gencode=arch=compute_61,code=\"sm_61,compute_61\" -Xcompiler /MD -o "C:\Users\Justin\Documents\MATLAB\matconvnet-1.0-beta20\matlab\mex.build\bits\impl\pooling_gpu.obj" failed.

Error in vl_compilenn (line 466) nvcc_compile(opts, srcs{i}, objfile, flags.nvcc) ;

I googled for the error bolded and came across this link which I think may have something to with what's going on: [http://stackoverflow.com/questions/37566987/cuda-atomicadd-for-doubles-definition-error]

I don't know if it's a proper fix or not, but I ended up doing the following:

pooling_gpu.cu, line 163 (commented out atomicadd)

bilinearsampler_gpu.cu, line 25 (commented out atomicadd)

This made the compiling work and I ran _vltestnn without any problems after compiling. Posting this here in case anyone else has the same problem and also if anyone has any further insights as to what caused the problem and what issues may arise from me commenting out the lines above.

Thanks! -Justin

BenjaminZoller commented 8 years ago

Hi,

I just encounter the same issue, except that I am using a gtx970, with compute capability 5.2. Apparently, it's related to the fact that with Pascal (compute capability 6.0) a native double version of atomicAdd has been added.

In my case, if I simply comment the overloaded definition of atomicAdd, I will still get an error. The right solution (http://stackoverflow.com/questions/37566987/cuda-atomicadd-for-doubles-definition-error/37569519) is to use the following macro:

#if !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 600
#else
<... place here your own pre-pascal atomicAdd definition ...>
#endif

I added the aforementioned macro at the two locations that Justin mentioned and the code compiles just fine with CUDA 8.0 on gpu architecture < 6.0.

Cheers, Ben

jlee614 commented 8 years ago

Ben,

Thanks for your help! I came across that same link (sorry, I had my syntax wrong and it didn't post properly the first time), and your suggestion is the correct one.

Thanks again! Justin

lenck commented 8 years ago

Thanks @jlee614 for the report and @missilzolair for suggesting the bugfix! It's now pushed to the master...

ahn19 commented 8 years ago

Thank you Ben.

lenck commented 8 years ago

Hi, do you still have this problem with the latest version? If so, then the fix got lost in the repo somewhere...

jlee614 commented 8 years ago

Hi Karel,

I haven't tried with the latest version yet. I'm currently out of state but will let you know when I get back in town if it works or not.

Thanks, Justin

On Wed, Sep 7, 2016 at 5:53 AM Karel Lenc notifications@github.com wrote:

Hi, do you still have this problem with the latest version? If so, then the fix got lost in the repo somewhere...

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/vlfeat/matconvnet/issues/575#issuecomment-245270859, or mute the thread https://github.com/notifications/unsubscribe-auth/AE0idRKoUPI4KuvL2r0k79XGvomsS5ZSks5qnrOzgaJpZM4IzfPR .

yingjieyao commented 7 years ago

Thank you all above!

lilhope commented 6 years ago

I‘ quite a newer for CUDA and MatConvnet,and I don‘t know edit which file helps to solve this problem, could you give me some suggestion? @missilzolair @lenck