Pytorch with cuda support

I found a solution for this issue. Here’s how I addressed it:

  1. Cachix Setup:
  • I used Cachix not to compile/build CUDA.
  • Also, I used package pytorch-bin in my nix-shell file.
  1. Nix-Shell Configuration:
  • I did not use cudaSupport = true; in the nix-shell file. Including this option would compile CUDA, which is unnecessary in this case.
  • The same issue occurred with the torchWithCuda package (or similar).
  1. Cachix Installation:
  • When installing, Cachix will generate a new caching.nix file and a caching directory in /etc/nixos. Make sure to move these to your dotfiles.
  • After installing Cachix, you’ll need to import it into your configuration.nix file and do nixos-rebuild.

After all this steps I successfully was able to run nix-shell shell.nix and had cuda available in pytorch

Hope this helps someone, I might also post here my shell.nix later on.

Useful links:
https://nixos.wiki/wiki/CUDA

https://app.cachix.org/cache/cuda-maintainers

1 Like