-
Notifications
You must be signed in to change notification settings - Fork 245
Description
ManagedMemoryResource() (no options) attempts to retrieve the current memory pool via cuMemGetMemPool with CU_MEM_ALLOCATION_TYPE_MANAGED. On platforms where the default pool does not support managed allocations, this fails with a cryptic error:
CUDAError: CUDA_ERROR_NOT_SUPPORTED: This error indicates that the attempted operation is not supported
on the current system or device.
Meanwhile, ManagedMemoryResource(options=ManagedMemoryResourceOptions(preferred_location=0)) works on the same platform because it creates a new managed pool via cuMemPoolCreate.
Improve the error message so users understand what went wrong, and investigate whether the API should handle this case more gracefully (e.g., by falling back to pool creation).
Reproducer:
from cuda.core import Device, ManagedMemoryResource, ManagedMemoryResourceOptions
device = Device(0)
device.set_current()
# Fails with CUDA_ERROR_NOT_SUPPORTED
mr = ManagedMemoryResource()
# Workaround: succeeds
mr = ManagedMemoryResource(options=ManagedMemoryResourceOptions(preferred_location=0))Test results:
On WSL2 x86_64 (concurrent_managed_access=False, memory_pools_supported=True):
ManagedMemoryResource() ...
failed: CUDA_ERROR_NOT_SUPPORTED: This error indicates that the attempted
operation is not supported on the current system or device.
ManagedMemoryResource(options=ManagedMemoryResourceOptions(preferred_location=0)) ...
succeeded (device_id=0)
On Linux x86_64 (concurrent_managed_access=True, memory_pools_supported=True):
ManagedMemoryResource() ...
succeeded (device_id=-1)
ManagedMemoryResource(options=ManagedMemoryResourceOptions(preferred_location=0)) ...
succeeded (device_id=0)