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

Function get_device_count

imperative/python/megengine/device.py:89–99  ·  view source on GitHub ↗

r"""Gets number of devices installed on this system. Args: device_type: device type, one of 'gpu' or 'cpu'

(device_type: str)

Source from the content-addressed store, hash-verified

87
88
89def get_device_count(device_type: str) -> int:
90 r"""Gets number of devices installed on this system.
91
92 Args:
93 device_type: device type, one of 'gpu' or 'cpu'
94 """
95 assert device_type in _device_type_set, "device must be one of {}".format(
96 _device_type_set
97 )
98 device_type = _str2device_type(device_type)
99 return CompNode._get_device_count(device_type, False)
100
101
102def is_cuda_available() -> bool:

Callers 15

run_modelFunction · 0.90
conftest.pyFile · 0.90
test_matmulFunction · 0.90
__init__Method · 0.85
__init__Method · 0.85
TESTFunction · 0.85
TESTFunction · 0.85
check_gpu_availableFunction · 0.85
get_device_countMethod · 0.85
LITE_get_device_countFunction · 0.85

Calls 2

_str2device_typeFunction · 0.85
formatMethod · 0.45

Tested by 11

test_matmulFunction · 0.72
TESTFunction · 0.68
TESTFunction · 0.68
check_gpu_availableFunction · 0.68
run_testFunction · 0.68
TESTFunction · 0.68
run<all_oprs>Function · 0.68
run<multi_device>Function · 0.68
run_all_gatherFunction · 0.68