-
Notifications
You must be signed in to change notification settings - Fork 223
Closed
Labels
triageNeeds the team's attentionNeeds the team's attention
Description
I'm using numpy 2.0.2 and cuda-core 0.1.1. I cannot successfully convert a numpy array into a StridedMemoryView. My understanding is that this should be possible because numpy arrays implement the dlpack interface.
import nvmath # used to patch cupy imports of nvidia-wheels
import numpy as np
import cuda.core.experimental as ccx
import cupy as cp
import torch
host_array = np.ones(50)
device_array = cp.ones(50)
device = ccx.Device()
device.set_current()
torch_array = torch.ones(50)
stream = device.create_stream()
# StridedMemoryView cannot wrap NumPy arrays because of impossible constraints on the
# stream_ptr parameter.
# Try 1: Provide a valid stream pointer
print(host_array)
wrapped_host_array = ccx.utils.StridedMemoryView(host_array, stream_ptr=stream.handle)
# RuntimeError: NumPy only supports stream=None.
print(wrapped_host_array)
# Try 2: Provide no stream pointer
print(host_array)
wrapped_host_array = ccx.utils.StridedMemoryView(host_array, stream_ptr=None)
# BufferError: stream=None is ambiguous with view()
print(wrapped_host_array)
print(torch_array)
wrapped_torch_array = ccx.utils.StridedMemoryView(torch_array, stream_ptr=None)
# BufferError: stream=None is ambiguous with view()
print(wrapped_torch_array)
# The following work
print(torch_array)
wrapped_torch_array = ccx.utils.StridedMemoryView(torch_array, stream_ptr=stream.handle)
print(wrapped_torch_array)
torch_array = torch_array.to('cuda')
print(torch_array)
wrapped_torch_array = ccx.utils.StridedMemoryView(torch_array, stream_ptr=stream.handle)
print(wrapped_torch_array)
print(device_array)
wrapped_device_array = ccx.utils.StridedMemoryView(device_array, stream_ptr=stream.handle)
print(wrapped_device_array)Metadata
Metadata
Assignees
Labels
triageNeeds the team's attentionNeeds the team's attention