Update solver.cpp
authorSergio Guadarrama <sguada@gmail.com>
Mon, 3 Feb 2014 21:20:05 +0000 (13:20 -0800)
committerSergio Guadarrama <sguada@gmail.com>
Mon, 3 Feb 2014 21:20:05 +0000 (13:20 -0800)
Added these two conditions before trying SetDevice
param_.solver_mode() && param_.has_device_id()

src/caffe/solver.cpp

index 731ae38..f344cca 100644 (file)
@@ -40,7 +40,7 @@ Solver<Dtype>::Solver(const SolverParameter& param)
 template <typename Dtype>
 void Solver<Dtype>::Solve(const char* resume_file) {
   Caffe::set_mode(Caffe::Brew(param_.solver_mode()));
-  if (param_.solver_mode()) {
+  if (param_.solver_mode() && param_.has_device_id()) {
     Caffe::SetDevice(param_.device_id());
   }
   Caffe::set_phase(Caffe::TRAIN);