From b060aa1ee591f4fea115ef6b5ffec69379e089cd Mon Sep 17 00:00:00 2001 From: mhouston Date: Mon, 13 Jul 2015 17:58:05 -0700 Subject: [PATCH] Workaround for running on default GPU if ID not specified --- tools/caffe.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tools/caffe.cpp b/tools/caffe.cpp index 1e646c31d93..c3b0f9270e0 100644 --- a/tools/caffe.cpp +++ b/tools/caffe.cpp @@ -134,9 +134,13 @@ int train() { // If the gpus flag is not provided, allow the mode and device to be set // in the solver prototxt. if (FLAGS_gpu.size() == 0 - && solver_param.solver_mode() == caffe::SolverParameter_SolverMode_GPU - && solver_param.has_device_id()) { - FLAGS_gpu = "" + boost::lexical_cast(solver_param.device_id()); + && solver_param.solver_mode() == caffe::SolverParameter_SolverMode_GPU) { + if (solver_param.has_device_id()) { + FLAGS_gpu = "" + + boost::lexical_cast(solver_param.device_id()); + } else { // Set default GPU if unspecified + FLAGS_gpu = "" + boost::lexical_cast(0); + } } vector gpus;