MCPcopy
hub / github.com/huggingface/alignment-handbook / get_current_device

Function get_current_device

src/alignment/model_utils.py:33–35  ·  view source on GitHub ↗

Get the current device. For GPU we return the local process index to enable multiple GPU training.

()

Source from the content-addressed store, hash-verified

31
32
33def get_current_device() -> int:
34 """Get the current device. For GPU we return the local process index to enable multiple GPU training."""
35 return Accelerator().local_process_index if torch.cuda.is_available() else "cpu"
36
37
38def get_kbit_device_map() -> Dict[str, int] | None:

Callers 1

get_kbit_device_mapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected