Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem Compiling with GPU Support on MATLAB 2018a #1143

Closed
malrabeiah opened this issue May 10, 2018 · 10 comments
Closed

Problem Compiling with GPU Support on MATLAB 2018a #1143

malrabeiah opened this issue May 10, 2018 · 10 comments

Comments

@malrabeiah
Copy link

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: #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
Copy link
Author

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
Copy link

isahhin commented May 17, 2018

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
Copy link

wzm2256 commented Jun 24, 2018

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

@liheyi960622
Copy link

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
Copy link

himahuja commented Mar 18, 2019

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
Copy link

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
Copy link

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
Copy link

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
Copy link

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
Copy link

Thank you, it's really helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants