I have an Asus Zenbook, and I’m running nixos-unstable.
nix-shell -p pciutils --run "lspci | grep -E 'VGA|3D'"
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 620 (rev 02)
01:00.0 3D controller: NVIDIA Corporation GM107 [GeForce 940MX] (rev a2)
xrandr --listproviders
Providers: number : 2
Provider 0: id: 0x46 cap: 0xf, Source Output, Sink Output, Source Offload, Sink Offload crtcs: 3 outputs: 4 associated providers: 0 name:modesetting
Provider 1: id: 0xc8 cap: 0x0 crtcs: 0 outputs: 0 associated providers: 0 name:modesetting
nvidia-smi
Fri Jun 25 09:27:59 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 460.73.01 Driver Version: 460.73.01 CUDA Version: 11.2 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 GeForce 940MX On | 00000000:01:00.0 Off | N/A |
| N/A 34C P8 N/A / N/A | 0MiB / 2004MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
nix-shell -p nix-info --run "nix-info -m"
- system: `"x86_64-linux"`
- host os: `Linux 5.10.44, NixOS, 21.05.1153.0ccd0d91361 (Okapi)`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.3.12`
- channels(root): `"nixos-21.05.1153.0ccd0d91361, nixpkgs-21.11pre297243.b27eaa18b47"`
- channels(oskar): `"nixpkgs-21.11pre297243.b27eaa18b47"`
- nixpkgs: `/home/oskar/.nix-defexpr/channels/nixpkgs`
These are the parts of my configuration.nix that are related to the gpu:
let
nvidia-offload = pkgs.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 -a "$0" "$@"
'';
in
services.xserver.videoDrivers = [ "modesetting" "nvidia" ];
hardware.nvidia.nvidiaPersistenced = true;
hardware.nvidia = {
prime = {
offload.enable = true;
# Bus ID of the Intel GPU. You can find it using lspci, either under 3D or VGA
intelBusId = "PCI:0:0:2";
# Bus ID of the NVIDIA GPU. You can find it using lspci, either under 3D or VGA
nvidiaBusId = "PCI:0:1:0";
};
powerManagement.enable = true;
};
I have read on other forums that modesetting prevented prime offloading from working, but when I don’t include it, I end up in a tty when I boot up the laptop.
glxinfo | grep "OpenGL renderer"
OpenGL renderer string: Mesa Intel(R) HD Graphics 620 (KBL GT2)
nvidia-offload glxinfo | grep "OpenGL renderer"
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 152 (GLX)
Minor opcode of failed request: 24 (X_GLXCreateNewContext)
Value in failed request: 0x0
Serial number of failed request: 39
Current serial number in output stream: 40
I used to be able to use PRIME on arch using optimus-manager.