MCPcopy Create free account
hub / github.com/BVLC/caffe / get_gpus

Function get_gpus

tools/caffe.cpp:89–109  ·  view source on GitHub ↗

Parse GPU ids or use all available devices

Source from the content-addressed store, hash-verified

87
88// Parse GPU ids or use all available devices
89static void get_gpus(vector<int>* gpus) {
90 if (FLAGS_gpu == "all") {
91 int count = 0;
92#ifndef CPU_ONLY
93 CUDA_CHECK(cudaGetDeviceCount(&count));
94#else
95 NO_GPU;
96#endif
97 for (int i = 0; i < count; ++i) {
98 gpus->push_back(i);
99 }
100 } else if (FLAGS_gpu.size()) {
101 vector<string> strings;
102 boost::split(strings, FLAGS_gpu, boost::is_any_of(","));
103 for (int i = 0; i < strings.size(); ++i) {
104 gpus->push_back(boost::lexical_cast<int>(strings[i]));
105 }
106 } else {
107 CHECK_EQ(gpus->size(), 0);
108 }
109}
110
111// Parse phase from flags
112caffe::Phase get_phase_from_flags(caffe::Phase default_value) {

Callers 4

device_queryFunction · 0.85
trainFunction · 0.85
testFunction · 0.85
timeFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected