Skip to content

dlpack issue with PyTorch #1239

@wang-xianghao

Description

@wang-xianghao

Description

Hello, the newest release (25.10.0) says dlpack is supported. I was attempting to importing torch tensor on GPU to cupynumeric, but got an error. Also, the document misses the usage of dlpack support.

Environment

torch: 2.8.0
legate: 25.10.0
nvidia-cupynumeric: 25.10.0

Code and running command

'''Within one GPU'''

import cupylma
import cupynumeric as np
import torch
import argparse

from cupynumeric import from_dlpack
from cupylma import get_available_gpus

device = get_available_gpus()[0]

# Create tensor on torch
num_bytes = 5_000_000_000
bytes_per_element = 4
num_elements = (num_bytes + bytes_per_element - 1) // bytes_per_element
tensor_shape = (num_elements,)
tensor = torch.empty(tensor_shape, dtype=torch.float32, device=device)

# Send tensor to cupynumeric
cp_array = from_dlpack(tensor, copy=True)

legate --gpus 1 test.py

Error

Traceback (most recent call last):
  File "/home/659/xw6261/test-dlpack/send.py", line 21, in <module>
    cp_array = from_dlpack(tensor, copy=True)
TypeError: Tensor.__dlpack__() got an unexpected keyword argument 'dl_device'

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions