NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.25k stars 13.51k forks source link

Broken Intel with or without Nvidia Configurations in unstable running XPS 15 9560 #82819

Closed JeffLabonte closed 4 years ago

JeffLabonte commented 4 years ago

Describe the bug The Nvidia remains ON even tho NixOS is configured to be in offload mode

To Reproduce Steps to reproduce the behavior:

  1. Configure nvidia the way it is explained in the wiki

Expected behavior Run on intel GPU on launch, switch to nvidia when using environment variable

Screenshots If applicable, add screenshots to help explain your problem.

Additional context

   jflabonte@tuxbox-xps15  ~  
▶ glxinfo                                                                                                                                                                                   ~
name of display: :0.0
Error: couldn't find RGB GLX visual or fbconfig

   jflabonte@tuxbox-xps15  ~  
▶ glxinfo                                                                                                                                                                                   ~
name of display: :0.0
Error: couldn't find RGB GLX visual or fbconfig

   jflabonte@tuxbox-xps15  ~  
▶ nvidia-smi                                                                                                                                                                                ~
Wed Mar 18 00:43:27 2020       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.59       Driver Version: 440.59       CUDA Version: 10.2     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1050    Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   37C    P8    N/A /  N/A |      0MiB /  4042MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
   jflabonte@tuxbox-xps15  ~  
▶ __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME="nvidia" __VK_LAYER_NV_optimus="NVIDIA_only"                                                                                        ~
   jflabonte@tuxbox-xps15  ~  
▶ __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME="nvidia" __VK_LAYER_NV_optimus="NVIDIA_only" glxgears                                                                               ~
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:  3 (X_GLXCreateContext)
  Value in failed request:  0x0
  Serial number of failed request:  25
  Current serial number in output stream:  26

lspci:

00:02.0 VGA compatible controller: Intel Corporation HD Graphics 630 (rev 04)
01:00.0 3D controller: NVIDIA Corporation GP107M [GeForce GTX 1050 Mobile] (rev a1)

Configurations:

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.
      ./hardware-configuration.nix
    ];

  # Use the systemd-boot EFI boot loader.
  boot = {
    kernelPackages = pkgs.linuxPackages_latest;
    kernelParams = [ "acpi_rev_override=1" "zswap.enabled=1" "zswap.compressor=lz4"];
    initrd = {
        kernelModules = [ "lz4" ];
    };
    loader = {
        systemd-boot.enable = true;
        efi.canTouchEfiVariables = true;
    };
  };

  nixpkgs.config = {
    allowUnfree = true;
    packageOverrides = pkgs: {
      vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
    };
  };

  networking.hostName = "tuxbox-xps15";
  networking.networkmanager.enable = true;

   console = {
     font = "latarcyrheb-sun32";
     keyMap = "us";
   };

  time.timeZone = "America/Toronto";

   environment.systemPackages = with pkgs; [
        wget
    vim
    curl
    neovim
    firefox
    chromium
    brave
    deja-dup
    jetbrains.pycharm-professional
    xfce4-14.xfce4-xkb-plugin
    xfce4-14.xfce4-pulseaudio-plugin
    vscodium
    sublime3
    gitkraken
    git
    terminator
    pass
    evince
    linuxPackages.cpupower
    ansible
    vagrant
    slack-dark
    python37
    cmake
    gcc
    ghc
    tmux
    neofetch
    weechat
    xscreensaver
   ];

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;

  networking.firewall.allowedTCPPorts = [ ];
  networking.firewall.allowedUDPPorts = [ ];
  networking.firewall.enable = true;
  networking.firewall.allowPing = false;

  services = {
    blueman.enable = true;
    flatpak.enable = true;
    printing.enable = true;
    openssh.enable = true;
    thermald.enable = true;
    tlp = {
        enable = true;
        extraConfig = "
            CPU_SCALING_GOVERNOR_ON_AC=performance
            CPU_SCALING_GOVERNOR_ON_BAT=powersave 
        ";
    };
    xserver = {
        enable = true;
        videoDrivers = [ "intel" "nvidia" ];
        libinput = {
            enable = true;
            tapping = true;
        };
        displayManager = {
            lightdm.enable = true;
            defaultSession = "xfce";
        };
        desktopManager = {
            xfce.enable = true;
        };
    };
    dbus.packages = with pkgs; [ gnome2.GConf ];

  };

  sound.enable = true;
  hardware = {
    bluetooth = {
        enable = true;
#       config = "
#         [General]
#         Enable=Source,Sink,Media,Socket
#       ";
    };
    opengl = {
        enable = true;
        driSupport32Bit = true;
        driSupport = true;
        extraPackages = with pkgs; [
            vaapiIntel
                vaapiVdpau
                libvdpau-va-gl
                intel-media-driver
        ];
    };
    nvidia = {
        prime = {
            offload.enable = true;
            nvidiaBusId="PCI:1:0:0";
            intelBusId="PCI:0:2:0";
        };
    };
    cpu.intel.updateMicrocode = true;
    pulseaudio = {
        enable = true;
            extraModules = [ pkgs.pulseaudio-modules-bt ];
        package = pkgs.pulseaudioFull;
    };
  };

  virtualisation = {
    docker.enable = true;
    virtualbox.host = {
        enable = true;
        enableExtensionPack = true;
    };
  };

  programs = {
    dconf.enable = true;
    zsh.enable = true;
    gnupg.agent = { 
        enable = true;
         enableSSHSupport = true;
     };
  };

  xdg.portal = {
    enable = true;
    extraPortals = [ pkgs.xdg-desktop-portal-gtk ];
  };

  security = {
    sudo = {
        extraConfig = "
            Defaults    env_reset,pwfeedback    
        ";
    };
  };

  # Define a user account. Don't forget to set a password with ‘passwd’.
   users.users.jflabonte = {
     isNormalUser = true;
     shell = pkgs.zsh;
     extraGroups = [ 
        "wheel" 
        "docker"
        "video"
        "audio"
        "sudo"
        "networkmanager"
        "vboxusers"
        "network"
    ]; # Enable ‘sudo’ for the user.
   };

  # This value determines the NixOS release with which your system is to be
  # compatible, in order to avoid breaking some software such as database
  # servers. You should change this only after NixOS release notes say you
  # should.
  system.stateVersion = "19.09"; # Did you read the comment?

}

/var/log/X.0.log

I have also tested other configurations such as bumblebee, and it doesn't work... it seem that it is broken on unstable.

Metadata ▶ nix-shell -p nix-info --run "nix-info -m" ~

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute:
# a list of nixos modules affected by the problem
module:

https://discourse.nixos.org/t/nvidia-offload-mode-no-intel-gpu-running/6298?u=jefflabonte

nixos-discourse commented 4 years ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/nvidia-offload-mode-no-intel-gpu-running/6298/1

jorsn commented 4 years ago

You are using unstable consistently, not only importing the unstable nvidia module into a stable system (like me)?

Then try to leave out the intel driver (-> services.xserver.videoDrivers = [ "nvidia" ]).

If this doesn't work, please post your xorg.conf. I think, the easiest way to find it is to set services.xserver.exportConfiguration = true. This links it to /etc/X11/xorg.conf.

JeffLabonte commented 4 years ago

Yes, I am running completely on unstable.

https://pastebin.com/4BD6D09v

JeffLabonte commented 4 years ago

The weird thing is that nvidia offload seems to be working. It seems that my intel driver aren't working at all.

image

I will change the title

bryanasdev000 commented 4 years ago

Correct me if I'm wrong, but as far as I know, this is the expected behavior when using NVIDIA offload. NVIDIA is never shut down, it only enters a state of lower power consumption, only new GPUs are effectively shut down, and unless NVIDIA environment variables are invoked, processing is running at Intel. For reference: https://forum.manjaro.org/t/nvidia-offloading-not-powering-down-gpu/116633/3 .

If you want to use only Intel or NVIDIA you will need something like optimus-manager.