Skip to first unread message

Andy Chen

unread,
Dec 20, 2016, 5:36:38 PM12/20/16
to Caffe Users
Hello everybody,

I have a problem of loading a pretrained model from Caffe Net. I'm using macOS Sierra 10.12.1 on Macbook Pro ME865 without an Nvidia GPU. Thus, in my code, there is a code like: 

caffe.set_mode_cpu()

I downloaded the following files and put them to the same folder of my source code:
  1. face_full_conv2.prototxt
  2. alexNet__iter_60000.caffemodel

I implemented the following Python code:

net_full_conv = caffe.Net('face_full_conv2.prototxt', caffe.TEST) 

And here is the error I got: 

WARNING: Logging before InitGoogleLogging() is written to STDERR
I1221 04:30:05.741330 3992683456 upgrade_proto.cpp:67] 
Traceback (most recent call last):
  File "/Users/macpro/Google Drive/MyProject/main.py", line 267, in <module>
    main()
  File "/Users/macpro/Google Drive/MyProject/main.py", line 262, in main
    face_detection('test.txt')
  File "/Users/macpro/Google Drive/MyProject/main.py", line 218, in face_detection
    net_full_conv = caffe.Net('face_full_conv2.prototxt', caffe.TEST)
RuntimeError: ios_base::clear: unspecified iostream_category error

 
I also tried loading the parameter and its weights simultaneously:

net_full_conv = caffe.Net('face_full_conv2.prototxt', 'alexNet__iter_60000.caffemodel', caffe.TEST)

And the error is the same as above. 


Here is a brief significant steps' description about how did I install Caffe. 
  1. I follow the instruction from:
    1. http://caffe.berkeleyvision.org/install_osx.html 
    2. http://caffe.berkeleyvision.org/installation.html#compilation
  2. I set the CPU_ONLY to ON in the CMakeLists.txt
  3. Then, I compile with CMake 
  4. When I "make" the "runtest":
    • I seem to be ok until I got this error message (it's just the last part of the whole log screen):
[100%] Linking CXX executable ../../../test/test.testbin
[100%] Built target test.testbin
Scanning dependencies of target runtest
test.testbin(97882,0x7fffedfb83c0) malloc: *** malloc_zone_unregister() failed for 0x7fffedfae000
Note: Google Test filter = -*GPU*
Note: Randomizing tests' orders with a seed of 30769 .
[==========] Running 1098 tests from 150 test cases.
[----------] Global test environment set-up.
[----------] 1 test from UniformFillerTest/1, where TypeParam = d
[ RUN      ] UniformFillerTest/1.TestFill
[       OK ] UniformFillerTest/1.TestFill (6 ms)
[----------] 1 test from UniformFillerTest/1 (6 ms total)
[----------] 12 tests from NesterovSolverTest/1, where TypeParam = N5caffe9CPUDeviceIdEE
[ RUN      ] NesterovSolverTest/1.TestNesterovLeastSquaresUpdateWithWeightDecay
*** Aborted at 1482216043 (unix time) try "date -d @1482216043" if you are using GNU date ***
PC: @     0x7fffe3e6ed28 std::__1::__shared_count::__add_shared()
*** SIGSEGV (@0x8) received by PID 97882 (TID 0x7fffedfb83c0) stack trace: ***
    @     0x7fffe54a5bba _sigtramp
    @        0x11096979a caffe::(anonymous namespace)::protobuf_AssignDescriptors_once_
    @     0x7fffe3e3c9fc std::__1::ios_base::getloc()
    @        0x110827d28 caffe::Solver<>::Init()
    @        0x110827afe caffe::Solver<>::Solver()
    @        0x1100cc378 caffe::SGDSolver<>::SGDSolver()
    @        0x1100d5b68 caffe::NesterovSolverTest<>::InitSolver()
    @        0x1100c7334 caffe::GradientBasedSolverTest<>::InitSolverFromProtoString()
    @        0x1100c7e61 caffe::GradientBasedSolverTest<>::RunLeastSquaresSolver()
    @        0x1100c7742 caffe::GradientBasedSolverTest<>::TestLeastSquaresUpdate()
    @        0x11028cb1a testing::internal::HandleExceptionsInMethodIfSupported<>()
    @        0x11028c97a testing::Test::Run()
    @        0x11028dbb2 testing::TestInfo::Run()
    @        0x11028e4a3 testing::TestCase::Run()
    @        0x1102947b9 testing::internal::UnitTestImpl::RunAllTests()
    @        0x110294293 testing::internal::HandleExceptionsInMethodIfSupported<>()
    @        0x1102941e9 testing::UnitTest::Run()
    @        0x110010705 main
    @     0x7fffe5298255 start
    @                0x3 (unknown)
/bin/sh: line 1: 97882 Segmentation fault: 11  "/Users/macpro/Caffe/build/test/test.testbin" --gtest_shuffle --gtest_filter="-*GPU*"
make[3]: *** [src/caffe/test/CMakeFiles/runtest] Error 139
make[2]: *** [src/caffe/test/CMakeFiles/runtest.dir/all] Error 2
make[1]: *** [src/caffe/test/CMakeFiles/runtest.dir/rule] Error 2
make: *** [runtest] Error 2

=> I avoid this issue because when I search Google for the answer, somebody said that this error does not affect the completion of the Caffe installation.   


I also tried installing without LevelDB (set USE_LEVELDB to OFF in CMakeLists.txt). The error is still the same, except that it avoid the problem of "malloc_zone_unregister()" as you can see at the above installation error. 

Furthermore, I tried with C++ implementation. The error is still the same. I use CLion as the IDE. The step of including Caffe has no problem, but the problem was raised with the following code:

Net<float> caffe_test_net("./face_full_conv.prototxt", caffe::TEST);

There is no error message, but when I debug, the error was shown as follows:



Can anyone help me to solve this problem? 

Andy Chen

unread,
Dec 21, 2016, 1:48:14 AM12/21/16
to Caffe Users
Dear all,
I have recompiled the Caffe source code (in C++) with some "cout" included. The reason for doing that is I would like to see when will the program get stuck.
Then, I see that it gets stuck at:

LOG_IF(INFO, Caffe::root_solver())
      << "Initializing net from parameters: " << std::endl
      << filtered_param.DebugString();

You can search for this lines of code in the file net.cpp attached with this reply. It is near the line 

std::cout << "Step 10" << std::endl;

 Anyone can help me, please?
net.cpp

surui2...@gmail.com

unread,
Nov 12, 2018, 3:44:42 AM11/12/18
to Caffe Users
I met the same error, I found it cause by source code function LOG(), so I use std::cout instead of all LOG(.*) , then make&make pycaffe. reference: sed -i '' 's/LOG(.*)/std::cout/g' `find ./ -type f -name "*.[ch]pp"`

在 2016年12月21日星期三 UTC+8上午6:36:38,Andy Chen写道:

Developer

unread,
Nov 29, 2018, 9:26:02 AM11/29/18
to Caffe Users
hi, 
i have a pretrained model which named xxxx.caffe , it is right to have a model with extension .caffe , because i know that the extension of caffe model is  '.caffemodel'
anyone can help me please 
Reply all
Reply to author
Forward
0 new messages