Fedir Zadniprovskyi 2024-09-05
fix: cuda not working on nixos
@5c0549f6a79ee0bc7166a346f918408ae59c0561
flake.nix
--- flake.nix
+++ flake.nix
@@ -28,11 +28,25 @@
               rsync
               websocat
               uv
+              cudaPackages_12.cudnn_8_9
             ];
+
+            # https://github.com/NixOS/nixpkgs/issues/278976#issuecomment-1879685177
+            # NOTE: Without adding `/run/...` the following error occurs
+            # RuntimeError: CUDA failed with error CUDA driver version is insufficient for CUDA runtime version
+            #
+            # NOTE: sometimes it still doesn't work but rebooting the system fixes it
+            LD_LIBRARY_PATH = "/run/opengl-driver/lib:${
+              pkgs.lib.makeLibraryPath [
+                pkgs.cudaPackages_12.cudnn_8_9
+                pkgs.zlib
+                pkgs.stdenv.cc.cc
+                pkgs.openssl
+              ]
+            }";
+
             shellHook = ''
               source .venv/bin/activate
-              export LD_LIBRARY_PATH=${pkgs.stdenv.cc.cc.lib}/lib:$LD_LIBRARY_PATH
-              export LD_LIBRARY_PATH=${pkgs.zlib}/lib:$LD_LIBRARY_PATH
               source .env
             '';
           };
Add a comment
List