Skip to content

Cuda array interface #43

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

SimonRit
Copy link
Collaborator

Adding export code to #42

@SimonRit SimonRit force-pushed the cuda-array-interface branch from 9e356cf to e176586 Compare December 19, 2024 17:47
@LucasGandel LucasGandel mentioned this pull request Dec 20, 2024
6 tasks
@SimonRit
Copy link
Collaborator Author

This is a detail but fc4cfa8 and 792d00e could be squashed into a single commit. This PR will be merged for CudaCommon v2, after a first release of CudaCommon v1.2, based on ITK v5.4.1 and/or v5.4.2.

@SimonRit SimonRit added this to the CudaCommon 2.0 milestone Mar 24, 2025
LucasGandel and others added 10 commits March 25, 2025 15:37
Prior to this commit CudaDataManager::GetGPUBufferPointer() returned a
pointer to the GPU buffer pointer. Its return type should have been void**.
Every usage of this method across RTK and CudaCommon dereference the
returned pointer pointer, so just return the buffer pointer directly as it
required for future commits adding support for __cuda_array_interface__
Adapt ITK's PyBuffer approach to inject __cuda_array_interface__ in wrapped
code.
Closes RTKConsortium#10
This allows modules like RTK to easily reuse files from the CudaCommon
sources, e.g. CudaImage.i.init and CudaImage.i.in
@SimonRit SimonRit force-pushed the cuda-array-interface branch from fc4cfa8 to a6729f8 Compare March 25, 2025 14:40
@SimonRit SimonRit force-pushed the cuda-array-interface branch 5 times, most recently from f7a5762 to 214cfbe Compare April 5, 2025 11:27
Simon Rit and others added 3 commits April 25, 2025 14:16
Add function to create a CudaImage from an object providing
__cuda_array_interface__
Allows the CPU buffer to be allocated automatically when only the GPU
pointer is set on the image.
@LucasGandel LucasGandel force-pushed the cuda-array-interface branch from 214cfbe to dd33430 Compare April 25, 2025 12:21
@LucasGandel
Copy link
Collaborator

@SimonRit please review. The code has been updated to consume cuda_array_interface. Below is a quick code snippet to test:

import itk
import cupy as cp
x_gpu = cp.array([[0, 1, 2],[3, 4, 5]], dtype=cp.float32, order='C')

cuda_img = itk.cuda_image_from_cuda_array(x_gpu)
pixelIndex = itk.Index[2]()
pixelIndex[0] = 2
pixelIndex[1] = 1
print(f"5 = {cuda_img.GetPixel(pixelIndex)}")

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

Successfully merging this pull request may close these issues.

2 participants