python3Packages.nvidia-ml-py: init 11.515.48#189028
python3Packages.nvidia-ml-py: init 11.515.48#189028SuperSandro2000 merged 2 commits intoNixOS:masterfrom
Conversation
9715e8b to
eb45546
Compare
|
Hello @FRidh and @jonringer ! I think this PR should be ready. Thank you very much in advance :) |
eb45546 to
2654342
Compare
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/need-pr-review-nvidia-ml-py/22020/1 |
|
Nevermind, this is provided by the NVIDIA driver. Still, probably best to hardcode a path to the stub in the cuda toolkit. cc @SomeoneSerge |
2654342 to
d69e072
Compare
|
RE: I think we want this line to resolve into |
|
I guess we can preserve ''
try:
nvmlLib = CDLL("libnvidia-ml.so.1")
except OSError:
nvmlLib = CDLL("${addOpenGLRunpath.driverLink}")
''Idk if it affects nixGL in any way |
|
@SomeoneSerge is your suggestion supposed to be a patch ? |
|
There's the line nvmlLib = CDLL("libnvidia-ml.so.1")If you run this on NixOS it's going to fail with |
jonringer
left a comment
There was a problem hiding this comment.
as others have mentioned, if this is exposing the functionality of nvidia drivers, you need to have the CDLL call resolve to nixos driver path /run/opengl-driver/lib/<lib>
|
Missing tests or doCheck = false and pythonImportsCheck. |
949f782 to
3cfac44
Compare
|
Could we not fix this in the stub and have all packages patch the path to the stub instead? |
|
Am I then supposed to use |
I'm not sure I follow, what exactly are you suggesting?
It's crude, but that's what i was thinking of |
3cfac44 to
4067f9a
Compare
done |
Ah okay, I thought that would be possible. Refer from here to the stub, and then in the stub refer to the driver library. |
|
✅ Tested the runtime with # shell.nix
let
nixpkgs = builtins.getFlake github:GaetanLepage/nixpkgs/nvidia-ml-py;
pkgs = import nixpkgs { config.cudaSupport = true; config.allowUnfree = true; };
py = pkgs.python3.withPackages (ps: with ps; [
nvidia-ml-py
]);
in
with pkgs;
mkShell {
packages = [ py ];
}and # test.py
import pynvml
if __name__ == "__main__":
pynvml.nvmlInit()
print(pynvml.nvmlSystemGetDriverVersion())
n_devices = pynvml.nvmlDeviceGetCount()
devices = [
pynvml.nvmlDeviceGetName(pynvml.nvmlDeviceGetHandleByIndex(i))
for i in range(n_devices)
]
print(f"{n_devices} devices:")
print("\n".join(devices)) |
|
Can the |
Yes, this Nix package with that patch will only be usable on NixOS. |
This why I suggested a try-except patch instead: with it non-nixos users can set |
|
I don't find any of this mandatory, but if it makes sense for you, I meant something like: diff --git a/pynvml.py b/pynvml.py
index 9e094c6..727716b 100644
--- a/pynvml.py
+++ b/pynvml.py
@@ -1676,7 +1676,11 @@ def _LoadNvmlLibrary():
nvmlLib = CDLL(os.path.join(os.getenv("ProgramFiles", "C:/Program Files"), "NVIDIA Corporation/NVSMI/nvml.dll"))
else:
# assume linux
- nvmlLib = CDLL("libnvidia-ml.so.1")
+ try:
+ nvmlLib = CDLL("libnvidia-ml.so.1")
+ except OSError:
+ # Assume NixOS
+ nvmlLib = CDLL("/run/opengl-driver/lib/libnvidia-ml.so.1")
except OSError as ose:
_nvmlCheckReturn(NVML_ERROR_LIBRARY_NOT_FOUND)
if (nvmlLib == None):I would, maybe, define this patch in Nix (via Maybe it would be even simpler to substitute |
Something like this ? try:
nvmlLib = CDLL("libnvidia-ml.so.1")
except OSError as ose:
nvmlLib = CDLL("/run/opengl-driver/lib/libnvidia-ml.so.1") |
I am not sure how to properly do this... |
buildPythonPackage {
# ...
patches = [
./0001-locate-libnvidia-ml.so.1-on-NixOS.patch
];
# ...
}or buildPythonPackage {
# ...
patches = [
(writeText "0001-locate-libnvidia-ml.so.1-on-NixOS.patch" ''
...
'')
];
# ...
} |
4067f9a to
e47b537
Compare
|
Ok, I have adopted the patch strategy. @SomeoneSerge could you please test on your system ? |
|
Please don't do that. It needlessly creates a derivation.
This is a WIP RFC. Please don't adopt to it yet. It might change or not come into place for a few more months. |
e47b537 to
65a15c2
Compare
|
@ofborg build python310Packages.nvidia-ml-py |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Description of changes
Adding the
nvidia-ml-pybindings for the NVIDIA Management Library.This is a requirement for nvitop which I would like to package next.
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notes