Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MultiGPU Testing #2931

Merged
merged 1 commit into from
Aug 15, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/caffe/test/test_gradient_based_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,19 @@ class GradientBasedSolverTest : public MultiDeviceTest<TypeParam> {
const int iter_size = 1, const int devices = 1,
const bool snapshot = false, const char* from_snapshot = NULL) {
ostringstream proto;
int device_id = 0;
#ifndef CPU_ONLY
if (Caffe::mode() == Caffe::GPU) {
CUDA_CHECK(cudaGetDevice(&device_id));
}
#endif
proto <<
"snapshot_after_train: " << snapshot << " "
"max_iter: " << num_iters << " "
"base_lr: " << learning_rate << " "
"lr_policy: 'fixed' "
"iter_size: " << iter_size << " "
"device_id: " << device_id << " "
"net_param { "
" name: 'TestNetwork' "
" layer { "
Expand Down Expand Up @@ -189,8 +196,12 @@ class GradientBasedSolverTest : public MultiDeviceTest<TypeParam> {
} else {
LOG(INFO) << "Multi-GPU test on " << devices << " devices";
vector<int> gpus;
for (int i = 0; i < devices; ++i) {
gpus.push_back(i);
// put current device at the beginning
int device_id = solver_->param().device_id();
gpus.push_back(device_id);
for (int i = 0; gpus.size() < devices; ++i) {
if (i != device_id)
gpus.push_back(i);
}
Caffe::set_solver_count(gpus.size());
this->sync_.reset(new P2PSync<Dtype>(
Expand Down