vlfeat / matconvnet

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

Problem while Running setup.m in practical-cnn-2015a #289

Closed minhtannguyen closed 8 years ago

minhtannguyen commented 9 years ago

Hi all,

I encounter the following error while running the setup.m file in practical-cnn-2015a using CPU. Does anyone know how to fix this error? I am using MATLAB 2015b.

Thank you so much!!!

Error using mex In file included from /Users/dsp/Documents/MATLAB/practical-cnn-2015a/matconvnet/matlab/src/vl_nnconv.cpp:5: In file included from /Users/dsp/Documents/MATLAB/practical-cnn-2015a/matconvnet/matlab/src/vl_nnconv.cu:15: /Users/dsp/Documents/MATLAB/practical-cnn-2015a/matconvnet/matlab/src/bits/nnhelper.h:161:28: error: non-constant-expression cannot be narrowed from type 'ptrdiff_t' (aka 'long') to 'mwSize' (aka 'unsigned long') in initializer list [-Wc++11-narrowing] mwSize dimensions [4] = {geom.height, geom.width, geom.depth, geom.size} ; ^~~ /Users/dsp/Documents/MATLAB/practical-cnn-2015a/matconvnet/matlab/src/bits/nnhelper.h:161:28: note: override this message by inserting an explicit cast mwSize dimensions [4] = {geom.height, geom.width, geom.depth, geom.size} ; ^~~ static_cast( ) /Users/dsp/Documents/MATLAB/practical-cnn-2015a/matconvnet/matlab/src/bits/nnhelper.h:161:41: error: non-constant-expression cannot be narrowed from type 'ptrdiff_t' (aka 'long') to 'mwSize' (aka 'unsigned long') in initializer list [-Wc++11-narrowing] mwSize dimensions [4] = {geom.height, geom.width, geom.depth, geom.size} ; ^~~~~~ /Users/dsp/Documents/MATLAB/practical-cnn-2015a/matconvnet/matlab/src/bits/nnhelper.h:161:41: note: override this message by inserting an explicit cast mwSize dimensions [4] = {geom.height, geom.width, geom.depth, geom.size} ; ^~~~~~ static_cast( ) /Users/dsp/Documents/MATLAB/practical-cnn-2015a/matconvnet/matlab/src/bits/nnhelper.h:161:53: error: non-constant-expression cannot be narrowed from type 'ptrdiff_t' (aka 'long') to 'mwSize' (aka 'unsigned long') in initializer list [-Wc++11-narrowing] mwSize dimensions [4] = {geom.height, geom.width, geom.depth, geom.size} ; ^~~~~~ /Users/dsp/Documents/MATLAB/practical-cnn-2015a/matconvnet/matlab/src/bits/nnhelper.h:161:53: note: override this message by inserting an explicit cast mwSize dimensions [4] = {geom.height, geom.width, geom.depth, geom.size} ; ^~~~~~ static_cast( ) /Users/dsp/Documents/MATLAB/practical-cnn-2015a/matconvnet/matlab/src/bits/nnhelper.h:161:65: error: non-constant-expression cannot be narrowed from type 'ptrdiff_t' (aka 'long') to 'mwSize' (aka 'unsigned long') in initializer list [-Wc++11-narrowing] mwSize dimensions [4] = {geom.height, geom.width, geom.depth, geom.size} ; ^~~~~ /Users/dsp/Documents/MATLAB/practical-cnn-2015a/matconvnet/matlab/src/bits/nnhelper.h:161:65: note: override this message by inserting an explicit cast mwSize dimensions [4] = {geom.height, geom.width, geom.depth, geom.size} ; ^~~~~ static_cast( ) 4 errors generated.

Error in vl_compilenn>mex_link (line 323) mex(mopts{:}) ;

Error in vl_compilenn (line 274) mex_link(opts, mex_src, obj_files, mex_libs, mex_dir, mex_opts);

Error in setup (line 15) vl_compilenn('enableGpu', opts.useGpu, 'verbose', opts.verbose) ;

vedaldi commented 9 years ago

Hi, I cannot reproduce in MATLAB 2015b on Mac and Linux. Which version are you using?

At any rate, it seems a small quirk with c++11. See here for a solution: http://stackoverflow.com/questions/4434140/narrowing-conversions-in-c0x-is-it-just-me-or-does-this-sound-like-a-breakin

aurotripathy commented 9 years ago

I've run into the same issue (as minhtannguyen) with Mac OS X 10.11 (El Capitan) and Matlab R2015b

aurotripathy commented 9 years ago

OK, changing line 161 in nnhelper.h (to the line below) completed the build.

mwSize dimensions [4] = {static_cast(geom.height), static_cast(geom.width), static_cast(geom.depth), static_cast(geom.size)} ;

prasannavk commented 8 years ago

Thanks that works for me.

vedaldi commented 8 years ago

Hi, you could also try replacing matconvnet with one of the later versions. I vaguely remember that this bug was fixed at some point. Of course, we should be updating the practicals with the new versions. Hopefully we will get down to it soon.

On 10 Jan 2016, at 22:03, Prasanna Krishnasamy notifications@github.com wrote:

Thanks that works for me.

— Reply to this email directly or view it on GitHub https://github.com/vlfeat/matconvnet/issues/289#issuecomment-170398227.

Maswor commented 8 years ago

Thank Aurotripathy. That also works for me!

ghost commented 8 years ago

Thanks aurotripathy. changing line worked for me too on el capitan with matlab r2015a.

pencilzhang commented 8 years ago

Thank you Aurotripathy. Also works for me on Mac OS X 10.11 (El Capitan) and Matlab R2015a!

himahuja commented 5 years ago

Just adding on to the soultion by @aurotripathy. The cast is performed as below,

mwSize dimensions [4] = {static_cast<mwSize>(geom.height), static_cast<mwSize>(geom.width), static_cast<mwSize>(geom.depth), static_cast<mwSize>(geom.size)} ;