biome: 1.9.2 -> 1.9.3 (#349335)
[NixPkgs.git] / pkgs / development / python-modules / nvidia-ml-py / default.nix
blob08beac0daf50b007689a078016740dc934c9654b
2   lib,
3   fetchPypi,
4   buildPythonPackage,
5   substituteAll,
6   addDriverRunpath,
7   setuptools,
8   cudaPackages,
9   nvidia-ml-py,
12 buildPythonPackage rec {
13   pname = "nvidia-ml-py";
14   version = "12.560.30";
16   pyproject = true;
18   src = fetchPypi {
19     inherit pname version;
20     extension = "tar.gz";
21     hash = "sha256-8CVNx0AGR2gKBy7gJQm/1GECtgvf7KMhV21NSBfn/pc=";
22   };
24   patches = [
25     (substituteAll {
26       src = ./0001-locate-libnvidia-ml.so.1-on-NixOS.patch;
27       inherit (addDriverRunpath) driverLink;
28     })
29   ];
31   build-system = [
32     setuptools
33   ];
35   # no tests
36   doCheck = false;
38   pythonImportsCheck = [ "pynvml" ];
40   passthru.tests.tester-nvmlInit =
41     cudaPackages.writeGpuTestPython { libraries = [ nvidia-ml-py ]; }
42       ''
43         from pynvml import (
44           nvmlInit,
45           nvmlSystemGetDriverVersion,
46           nvmlDeviceGetCount,
47           nvmlDeviceGetHandleByIndex,
48           nvmlDeviceGetName,
49         )
51         nvmlInit()
52         print(f"Driver Version: {nvmlSystemGetDriverVersion()}")
54         for i in range(nvmlDeviceGetCount()):
55             handle = nvmlDeviceGetHandleByIndex(i)
56             print(f"Device {i} : {nvmlDeviceGetName(handle)}")
57       '';
59   meta = {
60     description = "Python Bindings for the NVIDIA Management Library";
61     homepage = "https://pypi.org/project/nvidia-ml-py";
62     license = lib.licenses.bsd3;
63     maintainers = with lib.maintainers; [ GaetanLepage ];
64   };