python312Packages.nvidia-ml-py: fix and improve test (#348997)

This commit is contained in:
Someone 2024-10-16 14:32:37 +00:00 committed by GitHub
commit 051c4a28a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -40,10 +40,20 @@ buildPythonPackage rec {
passthru.tests.tester-nvmlInit =
cudaPackages.writeGpuTestPython { libraries = [ nvidia-ml-py ]; }
''
import pynvml
from pynvml.smi import nvidia_smi # noqa: F401
from pynvml import (
nvmlInit,
nvmlSystemGetDriverVersion,
nvmlDeviceGetCount,
nvmlDeviceGetHandleByIndex,
nvmlDeviceGetName,
)
print(f"{pynvml.nvmlInit()=}")
nvmlInit()
print(f"Driver Version: {nvmlSystemGetDriverVersion()}")
for i in range(nvmlDeviceGetCount()):
handle = nvmlDeviceGetHandleByIndex(i)
print(f"Device {i} : {nvmlDeviceGetName(handle)}")
'';
meta = {