Skip to content

Commit b060aa1

Browse files
mhoustoncypof
authored andcommitted
Workaround for running on default GPU if ID not specified
1 parent 48a7adf commit b060aa1

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tools/caffe.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,13 @@ int train() {
134134
// If the gpus flag is not provided, allow the mode and device to be set
135135
// in the solver prototxt.
136136
if (FLAGS_gpu.size() == 0
137-
&& solver_param.solver_mode() == caffe::SolverParameter_SolverMode_GPU
138-
&& solver_param.has_device_id()) {
139-
FLAGS_gpu = "" + boost::lexical_cast<string>(solver_param.device_id());
137+
&& solver_param.solver_mode() == caffe::SolverParameter_SolverMode_GPU) {
138+
if (solver_param.has_device_id()) {
139+
FLAGS_gpu = "" +
140+
boost::lexical_cast<string>(solver_param.device_id());
141+
} else { // Set default GPU if unspecified
142+
FLAGS_gpu = "" + boost::lexical_cast<string>(0);
143+
}
140144
}
141145

142146
vector<int> gpus;

0 commit comments

Comments
 (0)