From: Sergio Date: Thu, 19 Jun 2014 19:55:48 +0000 (-0700) Subject: Set device_id at the begining of Solver.Init() to avoid using memory in the default GPU X-Git-Tag: submit/tizen/20180823.020014~653^2~108^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3686f872f26e92e5c48e04e24bb89029b225984e;p=platform%2Fupstream%2Fcaffeonacl.git Set device_id at the begining of Solver.Init() to avoid using memory in the default GPU --- diff --git a/src/caffe/solver.cpp b/src/caffe/solver.cpp index 6a8f18f..7696181 100644 --- a/src/caffe/solver.cpp +++ b/src/caffe/solver.cpp @@ -36,6 +36,11 @@ void Solver::Init(const SolverParameter& param) { LOG(INFO) << "Initializing solver from parameters: " << std::endl << param.DebugString(); param_ = param; + if (param_.solver_mode() == SolverParameter_SolverMode_GPU && + param_.has_device_id()) { + Caffe::SetDevice(param_.device_id()); + } + Caffe::set_mode(Caffe::Brew(param_.solver_mode())); if (param_.random_seed() >= 0) { Caffe::set_random_seed(param_.random_seed()); } @@ -74,14 +79,8 @@ void Solver::Init(const SolverParameter& param) { LOG(INFO) << "Solver scaffolding done."; } - template void Solver::Solve(const char* resume_file) { - Caffe::set_mode(Caffe::Brew(param_.solver_mode())); - if (param_.solver_mode() == SolverParameter_SolverMode_GPU && - param_.has_device_id()) { - Caffe::SetDevice(param_.device_id()); - } Caffe::set_phase(Caffe::TRAIN); LOG(INFO) << "Solving " << net_->name(); PreSolve();