nvalchemi.data.resolve_device#
- nvalchemi.data.resolve_device(device)[source]#
Return device with a bare
cudaindexed by the current CUDA device.A storage records the device it is asked for, but
.to("cuda")puts its tensors on whichever GPU is current at that moment. Recording the request verbatim makes the record disagree with the tensors as soon as the current device changes, so every latertorch.cator lazily built pointer raises a device mismatch. Resolving once at record time pins the storage to the GPU its tensors actually reached. The same resolution turns a caller’s index-less"cuda", which means the device a launcher pinned this process to, into a concrete device that other placements can be compared against.- Parameters:
device (DeviceType or None) – Requested device.
Nonemeans"cpu".- Returns:
The requested device, with a CUDA index filled in when absent.
- Return type: