Nvidia Cuda Detection problem

This image is from OBS :

This is from RVC AI :

nvidia-smi :

How can I enable Cuda detection system wide (configuration.nix) ?

If nvidia-smi isn’t working it looks more like you just don’t have the nvidia drivers. Did you see the manual heading for nvidia?

Alternatively see the nvidia wiki entry for offload (“laptop”/iGPU+dGPU) mode, and nixos-hardware for pre-made modules enabling it.

I have the nvidia drivers installed, I just tried using gnome x11/wayland and both work with nvidia-smi, but in hyprland it doesn’t work.

Did you read the hyprland wiki entry on nvidia, and enable the nvidia-related options for the hyprland module as well (note that the NixOS module enables most things you need, don’t try to enable dkms or anything, just check if you’re missing e.g. the variables)?

Does CUDA work on X11?

1 Like

Well, I have never read this one, but currently due to work I have returned to gnome, when I reuse my hyprland config again, I will try your suggestion.

Hi! There several things going on here:

  1. There’s enabling the nvidia kernel module and userspace drivers in NixOS, which you do via services.xserver.videoDrivers = [ "nvidia" ] and hardware.opengl.enable = true respectively. Depending on the graphics card you got, you might need to also manually choose the kernel module: hardware.nvidia.package = config.kernelPackages.nvidia_x11_legacy470 (this is an example; pick yours). Note that because of how Nvidia is, it is necessary to reboot after you’ve enabled (or updated) the driver: the userspace driver in /run/opengl-driver/lib/libcuda.so must be of the same version, as the kernel module loaded at boot time. I am not sure whether you’ve already done all of these, since nvidia-smi is giving you errors
  2. Then, there’s using packages built with CUDA support. For example, instead of (import <nixpkgs> { }).obs-studio you probably have to use (import <nixpkgs> { config.cudaSupport = true; }).obs-studio (I don’t know if obs-studio actually has any dependencies that may rely on CUDA). You could make this the default for your entire configuration.nix by setting the nixpkgs.config.cudaSupport = true option. Note that this triggers many rebuilds
  3. Finally, I see you are using packages from pypi. These packages are built with the FHS assumption, and they expect either for the libcuda.so driver to be in /usr/lib, or for /etc/ld.so.cache to list the other location. The pypi packages do not know you’re running NixOS, and they do not know where to find the drivers, so you have to tell them. E.g. you could try LD_LIBRARY_PATH=/run/opengl-driver/lib ./run.sh

I haven’t read the thread in much detail, so I may have missed something

A few checks:

  • Please post the outputs of ls /dev/nvidia*
  • Please post the outputs of ls -l /run/opengl-driver/lib/libcuda*
  • If LD_LIBRARY_PATH=... ./run.sh does not work, please post the outputs of LD_LIBRARY_PATH=... LD_DEBUG=libs ./run.sh |& grep libcuda (replace ... with /run/opengl-driver/lib/)
1 Like