-
-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to use GPU inside NVIDIA docker container #578
Comments
Is this maybe duplicated with #454 ? |
The solution mentioned in that issue does not solve my problem. |
Here are all files inside |
I just looked into the source code, looks like it doesn’t even link the file extraPackages = mkIf cfg.useWindowsDriver [
(pkgs.runCommand "wsl-lib" { } ''
mkdir -p "$out/lib"
# # we cannot just symlink the lib directory because it breaks merging with other drivers that provide the same directory
ln -s /usr/lib/wsl/lib/libcudadebugger.so.1 "$out/lib"
ln -s /usr/lib/wsl/lib/libcuda.so "$out/lib"
ln -s /usr/lib/wsl/lib/libcuda.so.1 "$out/lib"
ln -s /usr/lib/wsl/lib/libcuda.so.1.1 "$out/lib"
ln -s /usr/lib/wsl/lib/libd3d12core.so "$out/lib"
ln -s /usr/lib/wsl/lib/libd3d12.so "$out/lib"
ln -s /usr/lib/wsl/lib/libdxcore.so "$out/lib"
ln -s /usr/lib/wsl/lib/libnvcuvid.so "$out/lib"
ln -s /usr/lib/wsl/lib/libnvcuvid.so.1 "$out/lib"
ln -s /usr/lib/wsl/lib/libnvdxdlkernels.so "$out/lib"
ln -s /usr/lib/wsl/lib/libnvidia-encode.so "$out/lib"
ln -s /usr/lib/wsl/lib/libnvidia-encode.so.1 "$out/lib"
ln -s /usr/lib/wsl/lib/libnvidia-ml.so.1 "$out/lib"
ln -s /usr/lib/wsl/lib/libnvidia-opticalflow.so "$out/lib"
ln -s /usr/lib/wsl/lib/libnvidia-opticalflow.so.1 "$out/lib"
ln -s /usr/lib/wsl/lib/libnvoptix.so.1 "$out/lib"
ln -s /usr/lib/wsl/lib/libnvwgf2umx.so "$out/lib"
ln -s /usr/lib/wsl/lib/nvidia-smi "$out/lib"
'')
];
}; |
To solve the nvidia-smi problem when nix-ld is also enabled, you need to add the "wsl-lib" to Or you didn't enabled the CDI feature in the docker daemon at it isn't enabled by default. |
@shikanime Thank you for the information! |
@fyang93 I was referring to the "wsl-lib" used by useWindowsDriver that you just mentioned. |
Ok, I just tested it, it seems that the CDI generated by virtualisation.docker = {
enable = true;
daemon.settings.features.cdi = true;
daemon.settings.cdi-spec-dirs = ["/etc/cdi"];
}; |
Normally it is the job of the hardware.nvidia-container-toolkit = {
enable = true;
mount-nvidia-executables = false;
}; ❯ docker run --rm --device nvidia.com/gpu=all ubuntu nvidia-smi -L
GPU 0: NVIDIA GeForce RTX 2070 with Max-Q Design (UUID: GPU-724d28f9-c8dc-91b2-6927-e1661f089935) |
@shikanime Would you be willing to create a PR to add this to the how-to section of the docs? I can't be of much help with this topic unfortunately, because the laptop I currently use primarily does not have an nvidia GPU |
@shikanime Sorry for the delayed response. Your solution was spot on and it worked like a charm, really appreciate the assist! 🙌 |
|
Bug description
I tried to use the NVIDIA Docker container on NixOS 24.05. According to the official docs, I set
hardware.nvidia-container-toolkit.enable = true;
and also enabledwsl.useWindowsDriver = true;
. After setting the environment variableNIX_LD_LIBRARY_PATH = "/usr/lib/wsl/lib"
, I was able to get GPU information usingnvidia-smi
, confirming that it matches the output on Windows. Next, I checked that the CDI file exists and is valid by runningcat /var/run/cdi/nvidia-container-toolkit.json
; however, I still cannot access to the nvidia driver inside the container properly, the error message is attached in Logs.It seems like the NVIDIA container toolkit did not correctly locate the driver files.
To Reproduce
Steps to reproduce the behavior:
wsl.useWindowsDriver = true;
andhardware.nvidia-container-toolkit.enable = true;
in flakeNIX_LD_LIBRARY_PATH = "/usr/lib/wsl/lib"
in shellLogs
WSL version
The text was updated successfully, but these errors were encountered: