diff --git a/examples/devicequery.cpp b/examples/devicequery.cpp new file mode 100644 index 000000000..337ab05a3 --- /dev/null +++ b/examples/devicequery.cpp @@ -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; +} diff --git a/src/caffe/common.cpp b/src/caffe/common.cpp index c5dcd1013..749857944 100644 --- a/src/caffe/common.cpp +++ b/src/caffe/common.cpp @@ -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);