From 4a72528620e479033d0efaa29f48b5d4664e051b Mon Sep 17 00:00:00 2001 From: sguada Date: Mon, 3 Feb 2014 12:41:55 -0800 Subject: [PATCH] Added device_query.cpp to examples/ to get basic information about the current GPU device or other device_id --- examples/devicequery.cpp | 23 +++++++++++++++++++++++ src/caffe/common.cpp | 1 + 2 files changed, 24 insertions(+) create mode 100644 examples/devicequery.cpp diff --git a/examples/devicequery.cpp b/examples/devicequery.cpp new file mode 100644 index 0000000..337ab05 --- /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 c5dcd10..7498579 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); -- 2.7.4