(storage, loc)
| 56 | |
| 57 | |
| 58 | def 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}") |