Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding using_pinned_memory_allocator #4892

Open
jakirkham opened this issue Mar 15, 2021 · 3 comments
Open

Adding using_pinned_memory_allocator #4892

jakirkham opened this issue Mar 15, 2021 · 3 comments
Labels

Comments

@jakirkham
Copy link
Member

Just as we have using_allocator for device memory, it would be helpful to have a similar function for pinned memory. This way one could affect the pinned memory allocator used in a with-block of code

@kmaehashi kmaehashi added cat:feature New features/APIs prio:medium labels Mar 16, 2021
@kmaehashi
Copy link
Member

Just to make the scope of this issue clear: does the API intends to change the NumPy allocator (numpy/numpy#17582), or just change how numpy.ndarray is allocated internally in CuPy?

@jakirkham
Copy link
Member Author

Oh was just thinking this would be another way to change how alloc_pinned_memory behaves in CuPy

Yeah it will be interesting to see what that that NumPy API looks like when it is finalized. Right now it is just a C API AFAICT. Leo mentioned there would be some interest in using this from Python ( numpy/numpy#17467 (comment) )

@leofang
Copy link
Member

leofang commented May 3, 2021

The NEP for custom NumPy allocators (numpy/numpy#18805) is merged as a draft. I think it's good to be able to use this new capability, but it requires

  1. A newer NumPy release that contains this capability
  2. Accessing the NumPy C API which is never done in CuPy so far

I think one viable path is to dlopen NumPy's shared library and get the function pointers. This way if the NumPy version is old and dlopen fails, we can just raise an error. We do not have to make NumPy a build-time dependency either. WDYT @kmaehashi @jakirkham?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants