NVIDIA: Difference between revisions

imported>User
No edit summary
imported>Mschonfinkel
Added some info about running a CUDA env on NixOS
Line 89: Line 89:
* The [https://github.com/guibou/nixGL nixGL project] provides wrapper to use GL drivers outside of NixOS. You need to have nvidia drivers installed on your distro (for kernel modules). Then supply nvidia driver version you use on host system to nixGL.
* The [https://github.com/guibou/nixGL nixGL project] provides wrapper to use GL drivers outside of NixOS. You need to have nvidia drivers installed on your distro (for kernel modules). Then supply nvidia driver version you use on host system to nixGL.
* [https://github.com/dukzcry/crap/tree/master/primerun Optimus only]. Primerun will build nvidia kernel modules against your currently running kernel.
* [https://github.com/dukzcry/crap/tree/master/primerun Optimus only]. Primerun will build nvidia kernel modules against your currently running kernel.
== CUDA ==
There some possible ways to setup a development environment using CUDA on NixOS. This can accomplished in the following ways:
* By making a FHS user env
{{file|cuda-fsh.nix|nix|<nowiki>
{ pkgs ? import <nixpkgs> {} }:
let fhs = pkgs.buildFHSUserEnv {
        name = "cuda-env";
        targetPkgs = pkgs: with pkgs;
              [ git
                gitRepo
                gnupg
                autoconf
                curl
                procps
                gnumake
                utillinux
                m4
                gperf
                unzip
                cudatoolkit
                linuxPackages.nvidia_x11
                libGLU_combined
xorg.libXi xorg.libXmu freeglut
                xorg.libXext xorg.libX11 xorg.libXv xorg.libXrandr zlib
ncurses5
stdenv.cc
binutils
                ];
          multiPkgs = pkgs: with pkgs; [ zlib ];
          runScript = "bash";
          profile = ''
                  export CUDA_PATH=${pkgs.cudatoolkit}
                  # export LD_LIBRARY_PATH=${pkgs.linuxPackages.nvidia_x11}/lib
  export EXTRA_LDFLAGS="-L/lib -L${pkgs.linuxPackages.nvidia_x11}/lib"
  export EXTRA_CCFLAGS="-I/usr/include"
            '';
          };
in pkgs.stdenv.mkDerivation {
  name = "cuda-env-shell";
  nativeBuildInputs = [ fhs ];
  shellHook = "exec cuda-env";
}
</nowiki>}}
* By making a nix-shell
{{file|cuda-shell.nix|nix|<nowiki>
{ pkgs ? import <nixpkgs> {} }:
pkgs.stdenv.mkDerivation {
  name = "cuda-env-shell";
  buildInputs = with pkgs;
                  [ git gitRepo gnupg autoconf curl
                    procps gnumake utillinux m4 gperf unzip
                    cudatoolkit linuxPackages.nvidia_x11
                    libGLU_combined
                    xorg.libXi xorg.libXmu freeglut
                    xorg.libXext xorg.libX11 xorg.libXv xorg.libXrandr zlib
                    ncurses5 stdenv.cc binutils
                  ];
  shellHook = ''
      export CUDA_PATH=${pkgs.cudatoolkit}
      # export LD_LIBRARY_PATH=${pkgs.linuxPackages.nvidia_x11}/lib:${pkgs.ncurses5}/lib
  export EXTRA_LDFLAGS="-L/lib -L${pkgs.linuxPackages.nvidia_x11}/lib"
  export EXTRA_CCFLAGS="-I/usr/include"
  '';         
}
</nowiki>}}
== See also ==
* [https://github.com/grahamc/nixos-cuda-example nixos-cuda-example]
* [https://github.com/grahamc/nixos-cuda-example/pull/2 nix-shell envs for Cuda]
* [https://discourse.nixos.org/t/cuda-setup-on-nixos/1118 CUDA setup on NixOS]


[[Category:Video]]
[[Category:Video]]