MCPcopy
hub / github.com/hpcaitech/ColossalAI / auto_set_accelerator

Function auto_set_accelerator

colossalai/accelerator/api.py:40–57  ·  view source on GitHub ↗

Automatically check if any accelerator is available. If an accelerator is available, set it as the global accelerator.

()

Source from the content-addressed store, hash-verified

38
39
40def auto_set_accelerator() -> None:
41 """
42 Automatically check if any accelerator is available.
43 If an accelerator is available, set it as the global accelerator.
44 """
45 global _ACCELERATOR
46
47 for accelerator_name, accelerator_cls in _ACCELERATOR_MAPPING.items():
48 try:
49 accelerator = accelerator_cls()
50 if accelerator_name == "cpu" or accelerator.is_available():
51 _ACCELERATOR = accelerator
52 break
53 except:
54 pass
55
56 if _ACCELERATOR is None:
57 raise RuntimeError("No accelerator is available.")
58
59
60def get_accelerator() -> BaseAccelerator:

Callers 1

get_acceleratorFunction · 0.85

Calls 1

is_availableMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…