MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / set_default_device

Function set_default_device

imperative/python/megengine/device.py:126–144  ·  view source on GitHub ↗

r"""Sets default computing node. Args: device: default device type. Note: * The type can be 'cpu0', 'cpu1', etc., or 'gpu0', 'gpu1', etc., to specify the particular CPU or GPU to use. * 'cpux' and 'gpux' can also be used to specify any number of CPU or GP

(device: str = "xpux")

Source from the content-addressed store, hash-verified

124
125
126def set_default_device(device: str = "xpux"):
127 r"""Sets default computing node.
128
129 Args:
130 device: default device type.
131
132 Note:
133 * The type can be 'cpu0', 'cpu1', etc., or 'gpu0', 'gpu1', etc.,
134 to specify the particular CPU or GPU to use.
135 * 'cpux' and 'gpux' can also be used to specify any number of CPU or GPU devices.
136 * The default value is 'xpux' to specify any device available.
137 * The priority of using GPU is higher when both GPU and CPU are available.
138 * 'multithread' device type is avaliable when inference,
139 which implements multi-threading parallelism at the operator level.
140 For example, 'multithread4' will compute with 4 threads.
141 * It can also be set by environment variable ``MGE_DEFAULT_DEVICE``.
142 """
143 assert _valid_device(device), "Invalid device name {}".format(device)
144 CompNode._set_default_device(device)
145
146
147def get_default_device() -> str:

Callers 3

mainFunction · 0.90
device.pyFile · 0.70
init_process_groupFunction · 0.50

Calls 2

_valid_deviceFunction · 0.85
formatMethod · 0.45

Tested by

no test coverage detected