MCPcopy Create free account
hub / github.com/PKU-Alignment/align-anything / torch_set_device

Function torch_set_device

align_anything/utils/device_utils.py:119–126  ·  view source on GitHub ↗

r""" Sets the device for PyTorch.

(device: Union[torch.device, str, int, None])

Source from the content-addressed store, hash-verified

117
118
119def torch_set_device(device: Union[torch.device, str, int, None]) -> None:
120 r"""
121 Sets the device for PyTorch.
122 """
123 if is_torch_npu_available():
124 torch.npu.set_device(device)
125 elif is_torch_cuda_available():
126 torch.cuda.set_device(device)
127
128
129def manual_seed_all(seed) -> None:

Callers 15

sft.pyFile · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected