vlfeat / matconvnet

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

Problem Compiling with GPU Support on MATLAB 2018a #1143

Closed malrabeiah closed 6 years ago

malrabeiah commented 6 years ago

Hello,

I tried to compile MatConvNet with GPU support on MATLAB 2018a. Of course, I followed the instructions on the official website, but, for some reason, I got the following error:

Error using mex 'C:\Users\alrabm\Documents\MATLAB\MatConvNet\matconvnet-1.0-beta25\matlab\mex\vl_nnconv.mexw64' compiled with '-R2018a' and linked with '-R2017b'. For more information, see MEX file compiled with one API and linked with another.

Error in vl_compilenn>mex_link (line 627) mex(args{:}) ;

Error in vl_compilenn (line 500) mex_link(opts, objs, flags.mex_dir, flags) ;

Error in compileMatConvNet (line 4) vl_compilenn('enableGpu', true, ...

After a quick search here, I found a suggested solution, this one: https://github.com/vlfeat/matconvnet/issues/1129, but I am using cuda 9 not cuda 8 and cudnn 7 not cudnn 5. Any help is highly appreciated!

My settings are: Windows 10 CUDA 9.0 cuDNN 7.1.3 MATLAB 2018a

malrabeiah commented 6 years ago

Solved this problem by modifying lines 359 and 620 in vl_compilenn.m. As I understand, the error message points out a compatibility issue between the compiler and the linker. I referred to MATLAB help for the "mex" function, and I found that there were options for linking, which are '-R2017b' and 'R2018a.' Hence, I modified line 620 to:

args = horzcat({'-outdir', mex_dir}, ... flags.base, flags.mexlink, ... '-R2018a',... {['LDFLAGS=$LDFLAGS ' strjoin(flags.mexlink_ldflags)]}, ... {['LDOPTIMFLAGS=$LDOPTIMFLAGS ' strjoin(flags.mexlink_ldoptimflags)]}, ... {['LINKLIBS=' strjoin(flags.mexlink_linklibs) ' $LINKLIBS']}, ... objs) ;

Then, I modified line 359 to be:

flags.mexlink = {'-lmwblas'};

because, for some reason, -R2018a does not use -largeArrayDims.

isahhin commented 6 years ago

I solved by updating the mex_link function in vl_compilenn as given below. % -------------------------------------------------------------------- function mex_link(opts, objs, mex_dir, mex_flags) mex_flags=['-R2018a',mex_flags(1:end-1)]; % -------------------------------------------------------------------- mopts = {'-outdir', mex_dir, mex_flags{:}, objs{:}} ; opts.verbose && fprintf('%s: MEX LINK: %s\n', mfilename, strjoin(mopts)) ;

mex(mopts{:}) ;

wzm2256 commented 6 years ago

@isahhin 's answer works with older version than beta25. @malrabeiah 's answer works with beta25. Thank you both.

liheyi960622 commented 5 years ago

Solved this problem by modifying lines 359 and 620 in vl_compilenn.m. As I understand, the error message points out a compatibility issue between the compiler and the linker. I referred to MATLAB help for the "mex" function, and I found that there were options for linking, which are '-R2017b' and 'R2018a.' Hence, I modified line 620 to:

args = horzcat({'-outdir', mex_dir}, ... flags.base, flags.mexlink, ... '-R2018a',... {['LDFLAGS=$LDFLAGS ' strjoin(flags.mexlink_ldflags)]}, ... {['LDOPTIMFLAGS=$LDOPTIMFLAGS ' strjoin(flags.mexlink_ldoptimflags)]}, ... {['LINKLIBS=' strjoin(flags.mexlink_linklibs) ' $LINKLIBS']}, ... objs) ;

Then, I modified line 359 to be:

flags.mexlink = {'-lmwblas'};

because, for some reason, -R2018a does not use -largeArrayDims.

Thank you, it is helpful.

himahuja commented 5 years ago

I am on matconvnet beta-8.0 and I changed mexopts variable from {-largeArrayDims} to {-R2018a} to compile it successfully. If none of the above solutions work, this can help.

gpnuelvis commented 5 years ago

Hi, my matconvnet version is before beta-25 and my matlab version is 2018b. I changed variable from {-largeArrayDims} to {-lmwblas} to compile it successfully (Line: 426, 434, 440).
If none of the above solutions work, this can help.

The settings are: opts.enableGpu = true; opts.enableImreadJpeg = false; opts.enableCudnn = true; opts.enableDouble = true; opts.imageLibrary = [] ; opts.imageLibraryCompileFlags = {} ; opts.imageLibraryLinkFlags = [] ; opts.verbose = 0; opts.debug = false; opts.cudaMethod = ['nvcc'] ;

bearshng commented 5 years ago

Hi, my matconvnet version is before beta-25 and my matlab version is 2018b. I changed variable from {-largeArrayDims} to {-lmwblas} to compile it successfully (Line: 426, 434, 440). If none of the above solutions work, this can help.

The settings are: opts.enableGpu = true; opts.enableImreadJpeg = false; opts.enableCudnn = true; opts.enableDouble = true; opts.imageLibrary = [] ; opts.imageLibraryCompileFlags = {} ; opts.imageLibraryLinkFlags = [] ; opts.verbose = 0; opts.debug = false; opts.cudaMethod = ['nvcc'] ;

Thanks so much. It works!

astha0899 commented 5 years ago

Hi, my matconvnet version is before beta-25 and my matlab version is 2018b. I changed variable from {-largeArrayDims} to {-lmwblas} to compile it successfully (Line: 426, 434, 440). If none of the above solutions work, this can help.

The settings are: opts.enableGpu = true; opts.enableImreadJpeg = false; opts.enableCudnn = true; opts.enableDouble = true; opts.imageLibrary = [] ; opts.imageLibraryCompileFlags = {} ; opts.imageLibraryLinkFlags = [] ; opts.verbose = 0; opts.debug = false; opts.cudaMethod = ['nvcc'] ;

Thank you for the help, however, i got another error after this step. I'd be very thankful if you could help. image

yeduzhouzi commented 5 years ago

Hi, my matconvnet version is before beta-25 and my matlab version is 2018b. I changed variable from {-largeArrayDims} to {-lmwblas} to compile it successfully (Line: 426, 434, 440). If none of the above solutions work, this can help.

The settings are: opts.enableGpu = true; opts.enableImreadJpeg = false; opts.enableCudnn = true; opts.enableDouble = true; opts.imageLibrary = [] ; opts.imageLibraryCompileFlags = {} ; opts.imageLibraryLinkFlags = [] ; opts.verbose = 0; opts.debug = false; opts.cudaMethod = ['nvcc'] ;

you are life-saving ths

shyu4184 commented 5 years ago

Thank you, it's really helpful.