File tree 2 files changed +18
-1
lines changed
2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 18
18
#include " caffe/layers/memory_data_layer.hpp"
19
19
#include " caffe/layers/python_layer.hpp"
20
20
#include " caffe/sgd_solvers.hpp"
21
+ #include " caffe/util/gpu_memory.hpp"
21
22
22
23
// Temporary solution for numpy < 1.7 versions: old macro, no promises.
23
24
// You're strongly advised to upgrade to >= 1.7.
@@ -51,9 +52,25 @@ namespace caffe {
51
52
typedef float Dtype;
52
53
const int NPY_DTYPE = NPY_FLOAT32;
53
54
55
+ #ifndef CPU_ONLY
56
+ shared_ptr<GPUMemory::Scope> gpu_memory_scope;
57
+ #endif
58
+
54
59
// Selecting mode.
55
60
void set_mode_cpu () { Caffe::set_mode (Caffe::CPU); }
56
- void set_mode_gpu () { Caffe::set_mode (Caffe::GPU); }
61
+ void set_mode_gpu () {
62
+ Caffe::set_mode (Caffe::GPU);
63
+ #ifndef CPU_ONLY
64
+ vector<int > gpus;
65
+ int count = 0 ;
66
+ CUDA_CHECK (cudaGetDeviceCount (&count));
67
+ for (int i = 0 ; i < count; ++i) {
68
+ gpus.push_back (i);
69
+ }
70
+ CHECK_GT (gpus.size (), 0 );
71
+ gpu_memory_scope.reset (new GPUMemory::Scope (gpus));
72
+ #endif
73
+ }
57
74
58
75
// For convenience, check that input files can be opened, and raise an
59
76
// exception that boost will send to Python if not (caffe could still crash
File renamed without changes.
You can’t perform that action at this time.
0 commit comments