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

matcaffe on windows 10: Undefined function 'caffe_' for input arguments of type 'char'. #4461

Closed
stoneyang opened this issue Jul 14, 2016 · 11 comments
Labels

Comments

@stoneyang
Copy link
Contributor

stoneyang commented Jul 14, 2016

caffe was pulled from github repo and was configured as the instructions under the windows branch, and the library was successfully compiled.

When running in-box matlab demo --- classification_demo.m, I got:

im = imread('../../examples/images/cat.jpg');
scores = classification_demo(im, 1);
Undefined function 'caffe_' for input arguments of type 'char'.

Error in caffe.set_mode_gpu (line 5)
caffe_('set_mode_gpu');

Error in classification_demo (line 66)
caffe.set_mode_gpu();

PC resources:

  • Windows 10 64bit ultimate edition
  • Visual Studio 2013 ultimate
  • CUDA 7.5
  • MATLAB r2014b 64bit
  • 8G RAM
  • nVidia GTX 960

PS: The generated matcaffe directory has already been set in path of MATLAB, and Release directory has already been included at the end of my system PATH.

I've spent several days googling around and found someone asking the same (or alike) question, such as: 1, and 2. It seems of no avail to solve this problem.

Anyone could shed me some light? Thanks in advance!

@Coderx7
Copy link
Contributor

Coderx7 commented Jul 28, 2016

the Undefined function 'caffe_' for input arguments of type 'char'
simply means caffe_ function is not found.
try the which command and see if matlab can find its path,
which caffe_
do this to other functions as well, like
which caffe.set_mode_gpu()

if it doesnt find caffe_, it means it is not in the path or pdw .
by the way when you run the demo, note that it first tries to see if the cafe+ folder which contains the caffe_ function , is in the path.
I am talking about this line of code

% Add caffe/matlab to you Matlab search PATH to use matcaffe
if exist('../+caffe', 'dir')
  addpath('..');
else

so basically if that folder is not your current folder, or caffe+ is not in your path you will get that error.
What I myself did was to write something like this :

% Add caffe/matlab to you Matlab search PATH to use matcaffe
if exist('N:/Caffe_Win/Build/x64/Release/matcaffe/+caffe', 'dir')
  addpath('..');
else

and I need to say that, I had already set matcaffe path to the MatlabPath. and having done that, I wrote the code I posted above .
and things got executed just fine .
by the way this stack overflow question helped me alot.

@stoneyang
Copy link
Contributor Author

stoneyang commented Aug 14, 2016

Hi, @Coderx7 , thanks a lot for timely reply and sorry for my delayed. :)

When I typed which caffe_ in the matlab console, it gives me: 'caffe_' not found.

While when I typed which caffe.set_mode_gpu(), it gives me something interesting: D:\src\caffe\matlab\+caffe\set_mode_cpu.m % static method or package function.

Then I tried to follow your advice on modifying the if exist() line, to make it implicitly pointing to the right directory, matlab still returns the same error as in the original post ....

What is your advice on this stage? Or, should I abandon playing caffe on windows? Thanks again.

Edit: Another earlier issue found #3967; and still, no effective solution yet....

@Coderx7
Copy link
Contributor

Coderx7 commented Aug 18, 2016

@stoneyang : have you looked at the stackoverflow link I gave earlier?
I am clueless whats wrong! make sure you check that link, it may help you get rid of the issue.

@stoneyang
Copy link
Contributor Author

@Coderx7 : Yeah, I've checked that link at the latest trial and I cannot add path to matlab because the directory contains a + symbol, which makes matlab resist accepting it ....
Thank you all the same for whatever you've helped. 👍
I will return to this thread when I find the solution.

@z-khan
Copy link

z-khan commented Aug 19, 2016

@stoneyang I am experiencing exactly similar issue as you. So far, I have not come across any solution.

@z-khan
Copy link

z-khan commented Aug 22, 2016

I resolved the issue using the following steps:

  1. Add <caffe_root>\Build\x64\Release to your system path, e.g
    PATH1;PATH2;D:\caffe-windows\Build\x64\Release
    Important: When appending a new item to a former list of paths, make sure there is no white space after the semicolon.
  2. Now open a Matlab session and add the generated matcaffe folder to the Matlab search path, e.g. addpath('D:\caffe-windows\Build\x64\Release\matcaffe')
  3. Edit classification_demo.m by changing
    addpath('..');
    to
    addpath('../../Build/x64/Release/matcaffe');
  4. Run classification_demo.m
    You should run it from <caffe_root>\matlab\demo folder as your current directory. This is because the demo uses other paths relative to this folder for loading models, example images, etc.

@stoneyang
Copy link
Contributor Author

@z-khan , your suggestions works before I have time to solve it :)

Thank you very much!!!

@avijoyChakma
Copy link

avijoyChakma commented Feb 15, 2017

I'm trying to follow this link. Caffe library built successfully with a bunch of warnings but I can not execute caffe.run_tests() statement. It terminates immediately resulting the following message -

Undefined function 'caffe_' for input arguments of type 'char'.
Error in caffe.set_mode_cpu (line 5)
caffe_('set_mode_cpu');
Error in caffe.run_tests (line 7)
caffe.set_mode_cpu();

I tried the above provided solutions but none worked. Did anyone face the same issue recently ? I'm using Windows-7, Cuda 7.0, CUDnn 4.0, Visual Studio 2013, Matlab 2016b(classroom licence). To build caffe I'm using the following configuration -

if NOT DEFINED MSVC_VERSION set MSVC_VERSION=12
if NOT DEFINED WITH_NINJA set WITH_NINJA=0
if NOT DEFINED CPU_ONLY set CPU_ONLY=1
if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Debug
if NOT DEFINED CMAKE_BUILD_SHARED_LIBS set CMAKE_BUILD_SHARED_LIBS=0
if NOT DEFINED PYTHON_VERSION set PYTHON_VERSION=2
if NOT DEFINED BUILD_PYTHON set BUILD_PYTHON=1
if NOT DEFINED BUILD_PYTHON_LAYER set BUILD_PYTHON_LAYER=1
if NOT DEFINED BUILD_MATLAB set BUILD_MATLAB=1
if NOT DEFINED PYTHON_EXE set PYTHON_EXE=python
if NOT DEFINED RUN_TESTS set RUN_TESTS=0
if NOT DEFINED RUN_LINT set RUN_LINT=0
if NOT DEFINED RUN_INSTALL set RUN_INSTALL=0

Every time I build, before it prints the configuration summery it prints The system cannot find the drive specified.
Any help or suggestion is greatly appreciated.

@YoungMagic
Copy link

YoungMagic commented Apr 21, 2017

@avijoyChakma I have the same problem with you? Did you fix it? And I have installed the newest caffe ,but I didn't find a project named matcaffe. Can anybody help?


I figured that my Matlab R2014B can't add a path with a '+'. So the caffe_.mex can't be found by matlab. I copy the file caffe_.mex to the /caffe/matlab path. Then it's all right!

@PENGUINLIONG
Copy link

@YoungMagic See if #5219 can help you.

@ckun5
Copy link

ckun5 commented Oct 23, 2017

I also met this. I solved it by compiling matcaffe: make all matcaffe

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

No branches or pull requests

8 participants