[HiCache]: Check return code of cudaHostRegister (#26301)

This commit is contained in:
Chao Shi
2026-05-26 17:44:15 +08:00
committed by GitHub
parent d25a220fdb
commit 48f3264807
@@ -187,9 +187,11 @@ def alloc_with_host_register(
""" """
buffer = allocator.allocate(dims, dtype=dtype, device=device) buffer = allocator.allocate(dims, dtype=dtype, device=device)
if pin_memory: if pin_memory:
torch.cuda.cudart().cudaHostRegister( ret = torch.cuda.cudart().cudaHostRegister(
buffer.data_ptr(), buffer.numel() * buffer.element_size(), 0 buffer.data_ptr(), buffer.numel() * buffer.element_size(), 0
) )
if ret != 0:
raise RuntimeError(f"cudaHostRegister failed with error code {ret}")
return buffer return buffer