CUDA headers not included in cudatoolkit?

Hi everyone,

Possible major newbie question here: I’d like to compile an program that includes the cuda_runtime_api.h header. I would think that this would be included in the systemPackage cudatoolkit, but unfortunately it doesn’t seem to be.

Several people on the web have suggested that, to do CUDA development under NixOS, you need to include the following in your configuration.nix:

systemd.services.nvidia-control-devices = {
  wantedBy = [ "multi-user.target" ];
  serviceConfig.ExecStart = "${pkgs.linuxPackages.nvidia_x11}/bin/nvidia-smi";
};

but when I add this and run # nixos-rebuild switch, the service fails with the error

... systemd[22581]: nvidia-control-devices.service: Failed to execute command: No such file or directory

Someone else had a similar issue in this question, and seemed to be able to resolve it by working in a nix-shell–but I’m pretty sure this is not what I want (as I do want a global installation), and I’m such a beginner that I’m not sure how to adapt it!

Any help would be much appreciated, both with this issue directly, and the more general hairy question of discoverability (I know how to search NixOS packages, but this doesn’t always make it obvious how or where or in what package some program or library is provided!).

Thanks very much.

3 Likes

I’m finding a similar error for a missing cuda_runtime.h - not sure of the fix yet:

cuda_runtime.h: No such file or directory

But found that the example nvidia-controle-devices.service includes an extra .bin in the package path which might fix the systemd switch error:

-   serviceConfig.ExecStart = "${pkgs.linuxPackages.nvidia_x11}/bin/nvidia-smi";
+   serviceConfig.ExecStart = "${pkgs.linuxPackages.nvidia_x11.bin}/bin/nvidia-smi";

This is a four years old thread, I’m pretty sure whatever you’re experiencing is most likely unrelated to the OP’s issue… that said, nvidia-smi and nvidia_x11 definitely do not have anything to do with the headers

NOTE: In NixOS configs, don’t refer to pkgs.linuxPackages, refer to config.boot.kernelPackages instead
NOTE: cuda_runtime.h is located at ${lib.getDev cudaPackages.cuda_cudart}/include/cuda_runtime.h
NOTE: nvidia-smi is located at "${lib.getExe' nvidia_x11 "nvidia-smi"}"