gpu rework

This commit is contained in:
Peder Bergebakken Sundt 2024-02-26 11:08:16 +01:00
parent 55920896ee
commit 0f4374d4f5
2 changed files with 23 additions and 26 deletions

View File

@ -2,12 +2,18 @@
{ {
# assumes common-gpu-nvidia from nixos-hardware is also added # assumes common-gpu-nvidia from nixos-hardware is also added
# TODO: should we move it from flake.nix to here? # TODO: should we move it from flake.nix to here?
# https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/nvidia/default.nix
# https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/nvidia/prime.nix
# https://nixos.wiki/wiki/Nvidia hardware.opengl.enable = true;
hardware.opengl.driSupport = true;
hardware.opengl.driSupport32Bit = true;
#https://nixpk.gs/pr-tracker.html?pr=235481 nixpkgs.config.openglSupport = true; # why is this not set by hardware.opengl.enable ?
#nixpkgs.config.cudaSupport = true; # TODO: TOO SLOW, BREAKS nixpkgs.config.cudaSupport = true; # TODO: TOO SLOW, BREAKS
#nixpkgs.config.nvidiaSupport = true; # TODO: slow? used only by zenith nixpkgs.config.vdpauSupport = true;
nixpkgs.config.vaapiSupport = true;
nixpkgs.config.nvidiaSupport = true; # TODO: slow? used only by zenith
nixpkgs.config.allowUnfreePredicate = pkg: lib.any (x: x) [ nixpkgs.config.allowUnfreePredicate = pkg: lib.any (x: x) [
(lib.hasInfix "nvidia" (lib.toLower (lib.getName pkg))) (lib.hasInfix "nvidia" (lib.toLower (lib.getName pkg)))
@ -16,23 +22,21 @@
(lib.hasInfix "cublas" (lib.toLower (lib.getName pkg))) (lib.hasInfix "cublas" (lib.toLower (lib.getName pkg)))
]; ];
hardware.opengl.enable = true; # https://nixos.wiki/wiki/Nvidia
hardware.opengl.driSupport = true;
hardware.opengl.driSupport32Bit = true;
hardware.opengl.extraPackages = [ hardware.opengl.extraPackages = [
#pkgs.vaapiVdpau #pkgs.vaapiVdpau # added by nixos-hardware
#pkgs.libvdpau-va-gl #pkgs.libvdpau-va-gl
pkgs.nvidia-vaapi-driver pkgs.nvidia-vaapi-driver
]; ];
hardware.nvidia.modesetting.enable = lib.mkDefault true; # needed for most wayland compositors hardware.nvidia.modesetting.enable = lib.mkDefault true; # needed for most wayland compositors
hardware.nvidia.nvidiaSettings = lib.mkDefault true; hardware.nvidia.nvidiaSettings = lib.mkDefault true;
virtualisation.docker.enableNvidia = lib.mkDefault true; virtualisation.docker.enableNvidia = lib.mkDefault true;
virtualisation.podman.enableNvidia = lib.mkDefault true; virtualisation.podman.enableNvidia = lib.mkDefault true;
# only do this per-host # only do these per-host
#hardware.nvidia.open = lib.mkDefault true; # open source version of kernel module, only on driver 515.43.04+ #hardware.nvidia.open = lib.mkDefault true; # open source version of kernel module, only on driver 515.43.04+
#hardware.nvidia.powerManagement.enable = lib.mkDefault true; # Fix graphical corruption on suspend/resume #hardware.nvidia.powerManagement.enable = lib.mkDefault true; # Fix graphical corruption on suspend/resume
@ -44,7 +48,6 @@
#hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.latest; #hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.latest;
#hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.beta; #hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.beta;
# add this to the host in question:
#hardware.nvidia.prime = { #hardware.nvidia.prime = {
# offload.enable = true; # offload.enable = true;
# # Bus IDs. You can find them using lspci, grepping for "3D" or "VGA" # # Bus IDs. You can find them using lspci, grepping for "3D" or "VGA"
@ -52,7 +55,6 @@
# nvidiaBusId = "PCI:1:0:0"; # nvidiaBusId = "PCI:1:0:0";
#}; #};
environment.systemPackages = [ environment.systemPackages = [
pkgs.nvtop-nvidia pkgs.nvtop-nvidia
] ++ lib.optionals config.hardware.nvidia.prime.offload.enable [ ] ++ lib.optionals config.hardware.nvidia.prime.offload.enable [

View File

@ -2,31 +2,26 @@
{ {
# assumes common-gpu-amd from nixos-hardware is also added # assumes common-gpu-amd from nixos-hardware is also added
# TODO: should we move it from flake.nix to here? # TODO: should we move it from flake.nix to here?
# nixos-hardware common-amd options
# https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/amd/default.nix # https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/amd/default.nix
hardware.amdgpu.opencl = true;
hardware.amdgpu.amdvlk = true;
hardware.opengl.enable = true; hardware.opengl.enable = true;
# https://libreddit.noximilien.pbsds.net/r/archlinux/comments/nih9c9/amdgpu_vs_modesetting_in_current_510_kernels_xorg/
services.xserver.videoDrivers = [ "amdgpu" ]; # use gpu, adaptive sync and and hardware page flipping
#services.xserver.videoDrivers = [ "modesetting" ]; # integrated (non-accelerated) framebuffer, KMS
hardware.opengl.driSupport = true; hardware.opengl.driSupport = true;
hardware.opengl.driSupport32Bit = true; hardware.opengl.driSupport32Bit = true;
hardware.opengl.extraPackages = [
pkgs.rocm-opencl-icd
(if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11")
then pkgs.rocm-runtime#-ext
else pkgs.rocmPackages.rocm-runtime
)
];
nixpkgs.config.openglSupport = true; # why is this not set by hardware.opengl.enable ? nixpkgs.config.openglSupport = true; # why is this not set by hardware.opengl.enable ?
nixpkgs.config.rocmSupport = true; nixpkgs.config.rocmSupport = true;
nixpkgs.config.vdpauSupport = true; nixpkgs.config.vdpauSupport = true;
nixpkgs.config.vaapiSupport = true; nixpkgs.config.vaapiSupport = true;
# nixos-hardware common-amd options
# https://github.com/NixOS/nixos-hardware/blob/master/common/gpu/amd/default.nix
hardware.amdgpu.opencl = lib.mkDefault true;
hardware.amdgpu.amdvlk = lib.mkDefault false;
# https://libreddit.noximilien.pbsds.net/r/archlinux/comments/nih9c9/amdgpu_vs_modesetting_in_current_510_kernels_xorg/
services.xserver.videoDrivers = [ "amdgpu" ]; # use gpu, adaptive sync and and hardware page flipping
#services.xserver.videoDrivers = [ "modesetting" ]; # integrated (non-accelerated) framebuffer, KMS (default in nixos-hardware)
# https://nixos.wiki/wiki/AMD_GPU#HIP # https://nixos.wiki/wiki/AMD_GPU#HIP
systemd.tmpfiles.rules = let systemd.tmpfiles.rules = let
hip = if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") hip = if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11")