Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions cuda_core/cuda/core/checkpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,14 +239,21 @@ def _as_cuuuid(driver, value, buffers):
the ``"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"`` format returned by
:attr:`Device.uuid`.
"""
if isinstance(value, driver.CUuuid):
return value
if isinstance(value, str):
raw = bytes.fromhex(value.replace("-", ""))
try:
raw = bytes.fromhex(value.replace("-", ""))
except ValueError:
raise ValueError(
f"GPU UUID string must be 32 hex characters (with optional hyphens), got {value!r}"
) from None
if len(raw) != 16:
raise ValueError(f"GPU UUID string must be 32 hex characters (with optional hyphens), got {value!r}")
buf = _ctypes.create_string_buffer(raw, 16)
buffers.append(buf)
return driver.CUuuid(_ctypes.addressof(buf))
return value
raise TypeError("GPU UUID values must be CUDA UUID objects or UUID strings")


__all__ = [
Expand Down
Loading