Are data copied from cpu to gpu during Forward?

16 views
Skip to first unread message

filipe mutz

unread,
Dec 15, 2016, 8:54:31 AM12/15/16
to Caffe Users
Hey guys, 

I'm trying to develop a regression application using the C++ interface. The code runs on the GPU. The application receive as input an image and it should compute some real values as output. Both, the input image and target values are represented as memory data layers. Looking at the caffe's C++ classification example, it seems that I can fill the data into the target blob using the mutable_cpu_method, as shown in the code below. My question is: when I call the forward method (or the solver's step method), the blob  data is automatically copied to the GPU or I have to explicitly call other method to do it? Is this the right caffenian way of setting the data of a memory data layer?

float* tdata = net_->blob_by_name("target")->mutable_cpu_data();

for (int i = 0; i < OUTPUT_SIZE; i++)
tdata[i] = expected_output[i];

(...)

// expected to run on GPU
solver->Step(1);


Happy holidays, fellows!


Reply all
Reply to author
Forward
0 new messages