How to use PyTorch with CUDA using uv without nix?

I’d like to develop a PyTorch application using CUDA in a uv environment but I don’t want to use a nix shell.

At the moment I’ve installed torch and cudatoolkit from nixpkgs but when I run cuda.is_available() it comes back False. I’m not sure what might be the issue as I’m new to nix and don’t really know what I’m doing. I’ve set up LD_LIBRARY_PATH using nix-ld.

Appreciate any help.

1 Like

I managed to clone and modify this repo which uses uv2nix, to get a different python package built on top of torch working.

If you want specific help with your setup it might be worth sharing your source code!