Skip to content

Commit

Permalink
Added device_query.cpp to examples/ to get basic information about th…
Browse files Browse the repository at this point in the history
…e current GPU device or other device_id
  • Loading branch information
sguada committed Feb 3, 2014
1 parent ab8b5f3 commit 4a72528
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/devicequery.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2013 Yangqing Jia


#include "caffe/common.hpp"
#include "caffe/net.hpp"


using namespace caffe;

int main(int argc, char** argv) {
if (argc > 2) {
LOG(ERROR) << "device_query [device_id=0]";
return 0;
}
if (argc == 2) {
LOG(INFO) << "Querying device_id=" << argv[1];
Caffe::SetDevice(atoi(argv[1]));
Caffe::DeviceQuery();
} else {
Caffe::DeviceQuery();
}
return 0;
}
1 change: 1 addition & 0 deletions src/caffe/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ void Caffe::DeviceQuery() {
return;
}
CUDA_CHECK(cudaGetDeviceProperties(&prop, device));
printf("Device id: %d\n", device);
printf("Major revision number: %d\n", prop.major);
printf("Minor revision number: %d\n", prop.minor);
printf("Name: %s\n", prop.name);
Expand Down

0 comments on commit 4a72528

Please sign in to comment.