lots
This commit is contained in:
50
hardware/gpu/cuda.nix
Normal file
50
hardware/gpu/cuda.nix
Normal file
@@ -0,0 +1,50 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
# assumes common-gpu-nvidia from nixos-hardware is also added
|
||||
# TODO: should we move it from flake.nix to here?
|
||||
|
||||
# https://nixos.wiki/wiki/Nvidia
|
||||
|
||||
#nixpkgs.config.cudaSupport = true; # TODO: TOO SLOW, BREAKS
|
||||
#nixpkgs.config.nvidiaSupport = true; # TODO: used only by zenith
|
||||
nixpkgs.config.allowUnfreePredicate = pkg: lib.any (x: x) [
|
||||
(lib.hasInfix "nvidia" (lib.toLower (lib.getName pkg)))
|
||||
(lib.hasInfix "cuda" (lib.toLower (lib.getName pkg)))
|
||||
(lib.hasInfix "cudnn" (lib.toLower (lib.getName pkg)))
|
||||
(lib.hasInfix "cublas" (lib.toLower (lib.getName pkg)))
|
||||
];
|
||||
|
||||
hardware.opengl.enable = true;
|
||||
#hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.stable;
|
||||
hardware.nvidia.package = config.boot.kernelPackages.nvidiaPackages.latest;
|
||||
#hardware.nvidia.modesetting.enable = true;
|
||||
|
||||
# add this to the host in question:
|
||||
#hardware.nvidia.prime = {
|
||||
# offload.enable = true;
|
||||
# # Bus IDs. You can find them using lspci, grepping for "3D" or "VGA"
|
||||
# intelBusId = "PCI:0:2:0";
|
||||
# nvidiaBusId = "PCI:1:0:0";
|
||||
#};
|
||||
|
||||
environment.systemPackages = with pkgs; ([
|
||||
nvtop-nvidia
|
||||
|
||||
] ++ lib.optional config.hardware.nvidia.prime.offload.enable [
|
||||
(writeShellScriptBin "prime-run" ''
|
||||
export __NV_PRIME_RENDER_OFFLOAD=1
|
||||
export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
|
||||
export __GLX_VENDOR_LIBRARY_NAME=nvidia
|
||||
export __VK_LAYER_NV_optimus=NVIDIA_only
|
||||
exec "$@"
|
||||
'')
|
||||
# already added by nixos-hardware.common-gpu-nvidia
|
||||
#(writeShellScriptBin "nvidia-offload" ''
|
||||
# export __NV_PRIME_RENDER_OFFLOAD=1
|
||||
# export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
|
||||
# export __GLX_VENDOR_LIBRARY_NAME=nvidia
|
||||
# export __VK_LAYER_NV_optimus=NVIDIA_only
|
||||
# exec "$@"
|
||||
#'')
|
||||
]);
|
||||
}
|
||||
22
hardware/gpu/intel.nix
Normal file
22
hardware/gpu/intel.nix
Normal file
@@ -0,0 +1,22 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
# enable opengl (headless)
|
||||
|
||||
# https://github.com/NixOS/nixpkgs/blob/nixos-22.11/pkgs/development/libraries/ffmpeg/generic.nix
|
||||
# https://github.com/NixOS/nixpkgs/blob/nixos-22.11/pkgs/development/libraries/jellyfin-ffmpeg/default.nix
|
||||
|
||||
nixpkgs.config.openglSupport = true; # why is this not set by hardware.opengl.enable ?
|
||||
nixpkgs.config.vaapiSupport = true;
|
||||
nixpkgs.config.libaomSupport = true;
|
||||
nixpkgs.config.vdpauSupport = true; # intel
|
||||
nixpkgs.config.libmfxSupport = true; # intel
|
||||
|
||||
hardware.opengl.enable = true;
|
||||
hardware.opengl.extraPackages = with pkgs; [
|
||||
mesa.drivers
|
||||
vaapiIntel
|
||||
libvdpau-va-gl
|
||||
vaapiVdpau
|
||||
intel-ocl
|
||||
];
|
||||
}
|
||||
25
hardware/gpu/rocm.nix
Normal file
25
hardware/gpu/rocm.nix
Normal file
@@ -0,0 +1,25 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
# assumes common-gpu-amd from nixos-hardware is also added
|
||||
# TODO: should we move it from flake.nix to here?
|
||||
|
||||
# nixos-hardware common-amd option
|
||||
hardware.amdgpu.opencl = true;
|
||||
|
||||
|
||||
nixpkgs.config.openglSupport = true; # why is this not set by hardware.opengl.enable ?
|
||||
nixpkgs.config.rocmSupport = 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
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"L+ /opt/rocm/hip - - - - ${pkgs.hip}"
|
||||
];
|
||||
environment.systemPackages = with pkgs; [
|
||||
nvtop-amd
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user