Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Expose GPU pointers to Python #5904
The purpose of this is to expose the GPU blob pointers, permitting use of libraries like PyCUDA without needless and expensive blob roundtripping.
This commit has been modified from the original in the following ways:
I am making this PR now to have minimal mergeable access to blob GPU memory. On the Python side, it's easy to write code to convert
@shaibagon No test is included here; since this code just exposes an existing call, it's not clear what to test, especially without bringing in additional Python dependencies. The idea here is to have a small mergeable patch which just makes it possible to access GPU memory from Python. If you are a regular old user, the public interface is unchanged and there is no new functionality. If you are a hacker, you can dig into these functions and interface to PyCUDA &c. free of round-trips (this is what I am doing). If you are a developer, you can think about adding these interfaces to pycaffe.
Well, I don't think there is such a thing as a simple test here: in order to check that these functions return something valid, we would need to read GPU memory from Python. We would need a new Python library to do that, which we would not want to make a hard dependency of pycaffe. That means we would need a way to disable some tests, or to acknowledge that not all tests should run and pass all the time. Then we would need to make sure that the new test was sometimes run, even though it wouldn't be runnable on Travis.
That's all possible (after all, Caffe has a CPU-only mode and GPU tests on the C++ side), but I don't think I'm going to do any of that in this PR, and I don't really feel bad about it, because there is no change to the public interface, only a private exposure of calls that are already tested in Caffe.
Future code which adds a public interface wrapping these calls probably merits testing. If such code interfaced to PyCUDA, e.g., it would already have to deal with the issue of dependencies.