Can Caffe or Caffe2 be given input data directly from gpu?

后端 未结 2 731
粉色の甜心
粉色の甜心 2021-01-25 01:04

I\'ve read caffe2 tutorials and tried pre-trained models. I knew caffe2 will leverge GPU to run the model/net. But the input data seems always be given from CPU(ie. Host) memory

2条回答
  •  有刺的猬
    2021-01-25 01:52

    I don't think you can do it in caffe with python interface.
    But I think that it can be accomplished using the c++: In c++ you have access to the Blob's mutable_gpu_data(). You may write code that run on device and "fill" the input Blob's mutable_gpu_data() directly from gpu. Once you made this update, caffe should be able to continue its net->forward() from there.

    UPDATE
    On Sep 19th, 2017 PR #5904 was merged into master. This PR exposes GPU pointers of blobs via the python interface.
    You may access blob._gpu_data_ptr and blob._gpu_diff_ptr directly from python at your own risk.

提交回复
热议问题