Skip to content

Commit 6f8c069

Browse files
committed
Add tests
1 parent 2d20100 commit 6f8c069

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

cuda_core/cuda/core/system/_mig.pxi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ cdef class MigInfo:
2727

2828
For Ampere™ or newer fully supported devices.
2929
"""
30-
return nvml.device_is_mig_device_handle(self._device._handle)
30+
return bool(nvml.device_is_mig_device_handle(self._device._handle))
3131

3232
@property
3333
def mode(self) -> bool:

cuda_core/tests/system/test_system_device.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,3 +729,30 @@ def test_pstates():
729729
assert isinstance(utilization.percentage, int)
730730
assert isinstance(utilization.inc_threshold, int)
731731
assert isinstance(utilization.dec_threshold, int)
732+
733+
734+
@pytest.mark.skipif(helpers.IS_WSL or helpers.IS_WINDOWS, reason="MIG not supported on WSL or Windows")
735+
def test_mig():
736+
for device in system.Device.get_all_devices():
737+
with unsupported_before(device, DeviceArch.AMPERE):
738+
mig = device.mig
739+
740+
assert isinstance(mig.is_mig_device, bool)
741+
if mig.is_mig_device:
742+
assert isinstance(mig.mode, bool)
743+
assert isinstance(mig.pending_mode, bool)
744+
745+
device_count = mig.get_device_count()
746+
assert isinstance(device_count, int)
747+
assert device_count >= 0
748+
749+
for mig_device in mig.get_all_devices():
750+
assert isinstance(mig_device, system.Device)
751+
752+
753+
def test_uuid_with_prefix():
754+
for device in system.Device.get_all_devices():
755+
uuid_with_prefix = device.uuid_with_prefix
756+
assert isinstance(uuid_with_prefix, str)
757+
assert uuid_with_prefix.startswith(("GPU-", "MIG-"))
758+
assert uuid_with_prefix[4:] == device.uuid

0 commit comments

Comments
 (0)