I am using caffe for windows through matlab. However, when I run
Undefined function or variable 'caffe_'.
Error in caffe.set_mode_cpu (line 5)
caffe_('set_mode_cpu');
Error in classification_demo (line 70)
caffe.set_mode_cpu();
Then I tried >>mex matlab/+caffe/private/caffe_.cpp
It shows:
Error using mex
caffe_.cpp
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\intrin.h(26) : fatal error C1083: Cannot open include
file: 'ammintrin.h': No such file or directory
In fact I don't have an ammintrin.h in that directory.
Another problem is that I try to read a prototxt and a caffemodel files using the following codes:
addpath(genpath(pwd));
def = fullfile('..', 'models', 'ResNet-50-deploy.prototxt');
net = fullfile('..', 'models', 'ResNet-50-model.caffemodel');
ConvNet = caffe.Net(def, net, 'test');
save model/ConvNet ConvNet
But it shows:
Invalid MEX-file
'
Error in caffe.get_net (line 27)
hNet = caffe_('get_net', model_file, phase_name);
Error in caffe.Net (line 31)
self = caffe.get_net(varargin{:});
Error in read_models (line 12)
ConvNet = caffe.Net(def, net, 'test');
I wonder if anybody met these problems and know solutions.
I may be forced to give up my research in this way if I could not solve the problems about reading pre-trained models by tomorrow, which I really don' want to be. Greatest thanks to anyone helps!
Does the debug version of caffe_.mexw64 exist? Perhaps you only built the release version.
Try adding only the paths that you need (following the instructions). Adding a whole subtree using genpath may cause MATLAB to look for caffe_.mexw64 in a wrong location.
I have met the same problem. Do you have any solution later? @ljyyoruhi
When you get matlab cant find the specified module, it means three things:
1.you didnt specifiy the module path correctly
2.one of the dependencies of the specified module is not accessible.
For the second part, you need to make sure you added the actual Caffe's bin directory (Build directory in windows) where the built dlls are located to the PATH environment variable.
so that all of those dlls that are needed in caffe's compilation are available
I finally have found the solution!!
it is mex-file dependency problem.
Just copy the dll files on release (including opencv, lmdb etc.) and paste to the Release\matcaffe+caffe\private caffe_.mexw64 is located.
Hopefully, it works
Sorry for no reaction to this issue for so long. I will try all your suggestions later. Thank you all!
Hello,
I have the same error message :
Undefined function or variable 'caffe'.
Error in mycaffe_tiled_forward5 (line 70)
caffe('init', model_def_file, opts.model_file)
Error in segmentAndTrack2 (line 64)
scores = mycaffe_tiled_forward5(data,opts);
I tried to copy the dlls files on release in the Release\matcaffe+caffe\private folder but error remains.
When I am on Matlab I cannot add the private file to the path because it is a 'private' folder. Is that the reason of the error ?
Has anyone found a solution ?
Thank you for your help
I have tried all the methods you mentioned,but I still can't solve this problem,
you should copy caffe_.exp, caffe_.lib and caffe_.mexw64 from "D:\caffe-windows\Build\x64\Release\matcaffe+caffe\private" , and paste to "D:\caffe-windows\matlab+caffe\private". I have solve it, good luck!
Closing since this was an issue with the previous VS build.
@GuanRainy
I just build the caffe+vs2015+py2.7
under caffe\build\x64\Release, I didn't find any files but 2 folders ALL_BUILD and ZERO_CHECK.
so I went to the \caffe\build\Matlab\Release, and foung 2 files: caffe_.exp, caffe_.lib.
ang then got the caffe_.mexw64 from caffe\matlab+caffe\private\Release.
and then. I run the test:
im = imread('../../examples/images/cat.jpg');
scores = classification_demo(im, 1);
no warning and error message but my matlab 2017a has stopped.
Is anything wrong?
If you do not find matcaffe folder in caffe\build\x64\Release, maybe you have some problems when you build caffe. please check the matcaffe project.@tyskink
See if #5219 can help.
Same problem. I am totally at loss, and stuck for a very long while at this. :'-(
Can someone please provide me ready to use (already built) caffe for Matlab (Windows)? I shall be very thankful
I have almost done the same as you @tyskink and my matlab 2016b is finishing the test just fine.
Build Caffe on Win10, VS2015, Py3.5
C:\caffe\scripts\build\Matlab\Release contains: caffe_.exp, caffe_.lib
C:\caffe\matlab+caffe\private\Release contains: caffe_.mexw64
copied only .mexw64 file to C:\caffe\matlab+caffe\private
then the test worked without the need to copy the .exp and .lib file
Most helpful comment
you should copy caffe_.exp, caffe_.lib and caffe_.mexw64 from "D:\caffe-windows\Build\x64\Release\matcaffe+caffe\private" , and paste to "D:\caffe-windows\matlab+caffe\private". I have solve it, good luck!