summaryrefslogtreecommitdiff
path: root/pkgs/development/python-modules/pynvml/default.nix
blob: 312dd409b9cffe5cda41a82cc93da8619d136be2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{
  lib,
  buildPythonPackage,
  cudaPackages,
  fetchFromGitHub,
  setuptools,
  pytestCheckHook,
  nvidia-ml-py,
  pynvml,
}:

buildPythonPackage rec {
  pname = "pynvml";
  version = "13.0.1";
  pyproject = true;

  src = fetchFromGitHub {
    owner = "gpuopenanalytics";
    repo = "pynvml";
    tag = version;
    hash = "sha256-Jwj3cm0l7qR/q5jzwKbD52L7ePYCdzXrYFOceMA776M=";
  };

  build-system = [
    setuptools
  ];

  pythonRelaxDeps = [
    "nvidia-ml-py"
  ];

  dependencies = [ nvidia-ml-py ];

  pythonImportsCheck = [
    "pynvml_utils"
  ];

  nativeCheckInputs = [ pytestCheckHook ];

  doCheck = false;

  passthru.tests.tester-nvmlInit = cudaPackages.writeGpuTestPython { libraries = [ pynvml ]; } ''
    from pynvml_utils import nvidia_smi  # noqa: F401
    nvsmi = nvidia_smi.getInstance()
    print(nvsmi.DeviceQuery('memory.free, memory.total'))
  '';

  meta = {
    description = "Unofficial Python bindings for the NVIDIA Management Library";
    homepage = "https://github.com/gpuopenanalytics/pynvml";
    changelog = "https://github.com/gpuopenanalytics/pynvml?tab=readme-ov-file#release-notes";
    license = lib.licenses.bsd3;
    maintainers = [ lib.maintainers.bcdarwin ];
  };
}