summaryrefslogtreecommitdiff
path: root/tools/test_net.cpp
diff options
context:
space:
mode:
authorEvan Shelhamer <shelhamer@imaginarynumber.net>2014-04-26 15:22:42 -0700
committerEvan Shelhamer <shelhamer@imaginarynumber.net>2014-04-26 15:22:42 -0700
commit0b885b9ba4f784fa3aad6444eb08cf592e67017b (patch)
tree21463a11a81e060510c8411ff228579fefeb6d79 /tools/test_net.cpp
parenta154ebcab3b9ded8b2bfdf5708ead1fd645644f5 (diff)
downloadcaffeonacl-0b885b9ba4f784fa3aad6444eb08cf592e67017b.tar.gz
caffeonacl-0b885b9ba4f784fa3aad6444eb08cf592e67017b.tar.bz2
caffeonacl-0b885b9ba4f784fa3aad6444eb08cf592e67017b.zip
add device id arg to test_net (fix #232)
Diffstat (limited to 'tools/test_net.cpp')
-rw-r--r--tools/test_net.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/tools/test_net.cpp b/tools/test_net.cpp
index 559fa730..69c774a6 100644
--- a/tools/test_net.cpp
+++ b/tools/test_net.cpp
@@ -17,18 +17,21 @@
using namespace caffe; // NOLINT(build/namespaces)
int main(int argc, char** argv) {
- if (argc < 4 || argc > 5) {
+ if (argc < 4 || argc > 6) {
LOG(ERROR) << "test_net net_proto pretrained_net_proto iterations "
- << "[CPU/GPU]";
+ << "[CPU/GPU] [Device ID]";
return 1;
}
- cudaSetDevice(0);
Caffe::set_phase(Caffe::TEST);
- if (argc == 5 && strcmp(argv[4], "GPU") == 0) {
+ if (argc >= 5 && strcmp(argv[4], "GPU") == 0) {
LOG(ERROR) << "Using GPU";
Caffe::set_mode(Caffe::GPU);
+ if (argc == 6) {
+ int device_id = atoi(argv[5]);
+ Caffe::SetDevice(device_id);
+ }
} else {
LOG(ERROR) << "Using CPU";
Caffe::set_mode(Caffe::CPU);