MCPcopy Create free account
hub / github.com/NVIDIA/FasterTransformer / gpu_map_location

Function gpu_map_location

examples/pytorch/utils.py:58–66  ·  view source on GitHub ↗
(storage, loc)

Source from the content-addressed store, hash-verified

56
57
58def gpu_map_location(storage, loc):
59 if loc.startswith("cuda"):
60 training_gpu_idx = int(loc.split(":")[1])
61 inference_gpu_idx = training_gpu_idx % torch.cuda.device_count()
62 return storage.cuda(inference_gpu_idx)
63 elif loc.startswith("cpu"):
64 return storage.cpu()
65 else:
66 raise NotImplementedError(f"Not handled {loc}")

Callers

nothing calls this directly

Calls 1

cudaMethod · 0.45

Tested by

no test coverage detected