Conversation
The pointers could be used by CUDA wrapper libraries in Python such as PyCUDA, gnumpy, Theano etc.
|
Is there any automatic test for this feature? |
|
would be a very nice feature! ಠ_ಠ (yes, I lifted this from @longjon's comment ) |
|
@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. @vimalthilak I'm flattered but I'm not sure you've grokked the expression (https://www.google.com/search?q=ಠ_ಠ). |
|
@longjon You are right! Glad to stand corrected :). My usage is more along the lines of I'm keeping my eyes on this thread! |
|
@longjon This is indeed a very simple (yet important) feature, but I suppose a very simple test verifying that indeed the exposed GPU pointer can be used in python. |
|
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. |
|
I'm currently working on something to allow writing GPU layers for both CUDA and OpenCL from Python on the OpenCL branch (single source and runtime compile for both CUDA and OpenCL). PyCUDA won't even be necessary there. |
|
@longjon sounds reasonable. no need to over comicate things. What I like most in caffe is the automatic tests: I can be certain that everything does what it is expected to do. |
|
@naibaf7 GPU pyhon layer is a huge step forward for caffe. Thanks! |
|
@shaibagon @shelhamer Since this PR is usable for CUDA only: I'll release an initial version of the "device abstracted" Caffe soon, Python GPU will follow in 1-2 months approximately, which will allow to write device abstracted GPU code directly. |
This is a rebased and cleaned-up version of a commit from @tnarihi, 7b99436.
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:
reinterpret_castis used instead of C-style casting.uintptr_tis used instead ofsize_t.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
Blobs to (e.g.)GPUArrays. Such code could also be brought in as desired (see @tnarihi's PRs).