Skip to content

Commit b590f1d

Browse files
committed
Merge pull request BVLC#3624 from drnikolaev/bvlc-print-gpu-names
Nicely prints gpu names
2 parents 2ef5847 + dd20997 commit b590f1d

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/caffe/test/test_caffe_main.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ int main(int argc, char** argv) {
3434
cudaGetDevice(&device);
3535
cout << "Current device id: " << device << endl;
3636
cudaGetDeviceProperties(&CAFFE_TEST_CUDA_PROP, device);
37+
cout << "Current device name: " << CAFFE_TEST_CUDA_PROP.name << endl;
3738
#endif
3839
// invoke the test.
3940
return RUN_ALL_TESTS();

tools/caffe.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,13 @@ int train() {
183183
s << (i ? ", " : "") << gpus[i];
184184
}
185185
LOG(INFO) << "Using GPUs " << s.str();
186-
186+
#ifndef CPU_ONLY
187+
cudaDeviceProp device_prop;
188+
for (int i = 0; i < gpus.size(); ++i) {
189+
cudaGetDeviceProperties(&device_prop, gpus[i]);
190+
LOG(INFO) << "GPU " << gpus[i] << ": " << device_prop.name;
191+
}
192+
#endif
187193
solver_param.set_device_id(gpus[0]);
188194
Caffe::SetDevice(gpus[0]);
189195
Caffe::set_mode(Caffe::GPU);
@@ -229,6 +235,11 @@ int test() {
229235
get_gpus(&gpus);
230236
if (gpus.size() != 0) {
231237
LOG(INFO) << "Use GPU with device ID " << gpus[0];
238+
#ifndef CPU_ONLY
239+
cudaDeviceProp device_prop;
240+
cudaGetDeviceProperties(&device_prop, gpus[0]);
241+
LOG(INFO) << "GPU device name: " << device_prop.name;
242+
#endif
232243
Caffe::SetDevice(gpus[0]);
233244
Caffe::set_mode(Caffe::GPU);
234245
} else {

0 commit comments

Comments
 (0)