BVLC / caffe

Caffe: a fast open framework for deep learning.
http://caffe.berkeleyvision.org/
Other
34.14k stars 18.68k forks source link

Unknown solver type: SGD #6793

Open starkdm opened 5 years ago

starkdm commented 5 years ago

I'm trying to build Caffe under Windows 10 and use it in my Visual Studio C++ project (VS 2017, v141 toolset). The build was successful as the libraries linking (although I had to have difficulties). I conducted tests after the build, and also ran "runtest" project. All tests were successfully.

Caffe build options:

INFO: ============================================================ 
INFO: Summary: 
INFO: ============================================================ 
INFO: MSVC_VERSION = 14 
INFO: WITH_NINJA = 0 
INFO: CMAKE_GENERATOR = "Visual Studio 14 2015 Win64" 
INFO: CPU_ONLY = 1 
INFO: CUDA_ARCH_NAME = Auto 
INFO: CMAKE_CONFIG = Debug
INFO: USE_NCCL = 0 
INFO: CMAKE_BUILD_SHARED_LIBS = 0 
INFO: PYTHON_VERSION = 2 
INFO: BUILD_PYTHON = 0
INFO: BUILD_PYTHON_LAYER = 1 
INFO: BUILD_MATLAB = 0 
INFO: PYTHON_EXE = "python" 
INFO: RUN_TESTS = 1
INFO: RUN_LINT = 0 
INFO: RUN_INSTALL = 0 
INFO: ============================================================ 

Program has triggered a breakpoint when CreateSolver method called. Full output:

WARNING: Logging before InitGoogleLogging() is written to STDERR
F0615 23:44:43.842417 14808 solver_factory.cpp:29] Check failed: registry.count(type) == 1 (0 vs. 1) Unknown solver type: SGD (known types: )
*** Check failure stack trace: ***

main.cpp: https://pastebin.com/w43ZgaXZ solver.prototxt: https://pastebin.com/Dt2hym79

JustLikeComet commented 5 years ago

The class SolverRegistry is a singleton, it is define in a header file. In dll it has an instance. but the caffe.cpp has another one. Ttey init different.

fix: in solver_factory.hpp, add two functions declare: Solver CreateFloatFloatSolver(const SolverParameter& param); Solver CreateFloatDoubleSolver(const SolverParameter& param);

create new file names with solver_factory.cpp add content:

namespace caffe {

Solver<float>* CreateFloatFloatSolver(const SolverParameter& param)
{
    return SolverRegistry<float>::CreateSolver(param);
}
Solver<double>* CreateFloatDoubleSolver(const SolverParameter& param)
{
    return SolverRegistry<double>::CreateSolver(param);
}

}

in caffe.cpp change

shared_ptr<caffe::Solver > solver(caffe::SolverRegistry::CreateSolver(solver_param));

to

shared_ptr<caffe::Solver > solver(caffe::CreateFloatFloatSolver(solver_param));

it will be ok.

starkdm commented 5 years ago

Do you offer to edit caffe.cpp and recompile the library? I solved the problem differently (specify solver): boost::shared_ptr<AdamSolver<double>> solver(new AdamSolver<double>(solverParam));

JustLikeComet commented 5 years ago

your solution better, then use yours.

i did not offer my change .

------------------ 原始邮件 ------------------ 发件人: "starkdm"notifications@github.com; 发送时间: 2019年10月9日(星期三) 凌晨5:09 收件人: "BVLC/caffe"caffe@noreply.github.com; 抄送: "无咎"474341520@qq.com;"Comment"comment@noreply.github.com; 主题: Re: [BVLC/caffe] Unknown solver type: SGD (#6793)

Do you offer to edit caffe.cpp and recompile the library? I solved the problem differently (specify solver): boost::shared_ptr<AdamSolver> solver(new AdamSolver(solverParam));

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.