Nvidia driver

These are a summary of my notes on how I got Steam and Nvidia working. It might be helpful in your case.

1. Nvidia Driver

If you are not sure what Nvidia graphics card you have, install nvidia-detect:

apt install nvidia-detect

It is used to identify your Nvidia graphics card. So at least you need to know what brand of graphics card you have. In my case:

nvidia-detect
Detected NVIDIA GPUs:
01:00.0 VGA compatible controller [0300]: NVIDIA Corporation GK104 [GeForce GTX 770] [10de:1184] (rev a1)

Checking card:  NVIDIA Corporation GK104 [GeForce GTX 770] (rev a1)
Your card is supported by all driver versions.
It is recommended to install the
        nvidia-driver
package.

apt info on nvidia-driver:

Description: NVIDIA metapackage
 This metapackage depends on the NVIDIA binary driver and libraries
 that provide optimized hardware acceleration of
 OpenGL/GLX/EGL/GLES/Vulkan applications via a direct-rendering X Server.
 .
 Please see the nvidia-kernel-dkms or
 nvidia-kernel-source packages
 for building the kernel module required by this package.
 This will provide nvidia-kernel-390.87.

The goal is to install the binary driver as we want top performace. Since I tried the legacy driver early on, I had to make sure nothing from those packages were left:

apt purge nvidia-legacy-340xx-driver
apt purge nvidia-legacy-340xx-alternative
apt autoremove

We aim for a system where the driver is automagically recompiled for every new version installed. This can be done with DKMS.

First, we will the correct kernel headers as the nvidia driver is compiled against a certain kernel.:

apt install linux-headers-$(uname -r|sed 's/[^-]*-[^-]*-//')

Install the following packages:

apt install xserver-xorg-video-nvidia nvidia-kernel-dkms nvidia-driver

This will install a binary driver and the DKMS system to automagically compile the driver. apt info on xserver-xorg-video-nvidia:

Package: xserver-xorg-video-nvidia
Description: NVIDIA binary Xorg driver
 The NVIDIA binary driver provides optimized hardware acceleration of
 OpenGL/GLX/EGL/GLES applications via a direct-rendering X Server
 for graphics cards using NVIDIA chip sets.
 .

To create a basic xconf.:

apt install nvidia-xconfig
nvidia-xconfig

If you reboot and have an error "screen not found", try to load the nvidia-driver:

modprobe nvidia-driver

Check the module:

lsmod | grep nvidia
modprobe nvidia

For instance, if you find in syslog that the driver is not loaded:

Mar  5 18:46:26 <machine> linux-boot-prober: debug: linux detected by /usr/lib/linux-boot-probes/50mounted-tests
Mar  5 18:48:28 <machine> systemd-modules-load[467]:
 modprobe: FATAL: Module nvidia-current-modeset not found in directory /lib/modules/4.9.0-4-amd64
Mar  5 18:48:28 <machine> systemd-modules-load[467]: modprobe: FATAL: Module nvidia-current-drm not found in directory /lib/modules/4.9.0-4-amd64
Mar  5 18:48:28 <machine> systemd-udevd[493]: modprobe: FATAL: Module nvidia-current not found in directory /lib/modules/4.9.0-4-amd64

No module found, built failed. Wrong headers installed apparently. Rebuilt the nvidia kernel module and it worked. Use DKMS to do this. If xorg works, this is the result in Xorg.conf.log:

[   510.832] (--) PCI:*(0:1:0:0) 10de:1184:1458:3603 rev 161, Mem @ 0xee000000/16777216, 0xe0000000/134217728, 0xe8000000/33554432, I/O @
[   510.832] (II) LoadModule: "glx"
[   510.832] (II) Loading /usr/lib/xorg/modules/linux/libglx.so
[   510.835] (II) Module glx: vendor="NVIDIA Corporation"
[   510.835]    compiled for 4.0.2, module version = 1.0.0
[   510.835]    Module class: X.Org Server Extension
[   510.835] (II) NVIDIA GLX Module  375.82  Wed Jul 19 20:30:13 PDT 2017
[   510.835] (II) LoadModule: "nvidia"
[   510.835] (II) Loading /usr/lib/xorg/modules/drivers/nvidia_drv.so
[   510.835] (II) Module nvidia: vendor="NVIDIA Cor+poration"
[   510.835]    compiled for 4.0.2, module version = 1.0.0
[   510.835]    Module class: X.Org Video Driver
[   510.835] (II) NVIDIA dlloader X Driver  375.82  Wed Jul 19 20:05:50 PDT 2017
[   510.835] (II) NVIDIA Unified Driver for all Supported NVIDIA GPUs
[   510.835] (II) Loading sub module "fb"
[   510.835] (II) LoadModule: "fb"
[   510.835] (II) Loading /usr/lib/xorg/modules/libfb.so
[   510.836] (II) Module fb: vendor="X.Org Foundation"
[   510.836]    compiled for 1.19.2, module version = 1.0.0
[   510.836]    ABI class: X.Org ANSI C Emulation, version 0.4
[   510.836] (II) Loading sub module "wfb"
[   510.836] (II) LoadModule: "wfb"
[   510.836] (II) Loading /usr/lib/xorg/modules/libwfb.so
[   510.836] (II) Module wfb: vendor="X.Org Foundation"
[   510.836]    compiled for 1.19.2, module version = 1.0.0
[   510.836]    ABI class: X.Org ANSI C Emulation, version 0.4
[   510.836] (II) Loading sub module "ramdac"
[   510.836] (II) LoadModule: "ramdac"
[   510.836] (II) Module "ramdac" already built-in
[   510.836] (**) NVIDIA(0): Depth 24, (--) framebuffer bpp 32
[   510.836] (==) NVIDIA(0): RGB weight 888
[   510.836] (==) NVIDIA(0): Default visual is TrueColor
[   510.836] (==) NVIDIA(0): Using gamma correction (1.0, 1.0, 1.0)
[   510.836] (**) NVIDIA(0): Enabling 2D acceleration
[   511.449] (--) NVIDIA(0): Valid display device(s) on GPU-0 at PCI:1:0:0
[   511.449] (--) NVIDIA(0):     CRT-0
[   511.449] (--) NVIDIA(0):     DFP-0 (boot)
[   511.449] (--) NVIDIA(0):     DFP-1
[   511.449] (--) NVIDIA(0):     DFP-2
[   511.449] (--) NVIDIA(0):     DFP-3
[   511.449] (--) NVIDIA(0):     DFP-4
[   511.450] (II) NVIDIA(0): NVIDIA GPU GeForce GTX 770 (GK104) at PCI:1:0:0 (GPU-0)
[   511.450] (--) NVIDIA(0): Memory: 2097152 kBytes
[   511.450] (--) NVIDIA(0): VideoBIOS: 80.04.e6.00.10
[   511.450] (II) NVIDIA(0): Detected PCI Express Link width: 16X
[   511.456] (--) NVIDIA(GPU-0): CRT-0: disconnected
...
[   511.644] (II) Loading sub module "dri2"
[   511.644] (II) LoadModule: "dri2"
[   511.644] (II) Module "dri2" already built-in
[   511.644] (II) NVIDIA(0): [DRI2] Setup complete
[   511.644] (II) NVIDIA(0): [DRI2]   VDPAU driver: nvidia

2. Screen tearing

I encountered screen tearing and to test, I did the following:

nvidia-settings --assign CurrentMetaMode="DP-4:1920x1080_60 +0+0 { ForceFullCompositionPipeline = On }, HDMI-1-1:1920x1080_60 +1920+0 { ForceFullCompositionPipeline = On }"

For 4K:

nvidia-settings --assign CurrentMetaMode="DP-4:3840x2160_60 +0+0 { ForceFullCompositionPipeline = On }, HDMI-1-1:1920x1080_60 +3840+0 { ForceFullCompositionPipeline = On }"

Use arandr(xrandr) to find monitor name(s). An xorg.conf for 2 screens example:

 Section "Screen"
 Identifier "nvidia"
 Option "metamodes" "nvidia-auto-select +0+0 { ForceFullCompositionPipeline = On }"
 Option "TripleBuffer" "on"
 Option "AllowIndirectGLXProtocol" "off"
 EndSection

Full working xorg.conf
# nvidia-settings: X configuration file generated by nvidia-settings
# nvidia-settings:  version 375.66  (buildd@debian)  Tue May 30 08:42:42 UTC 2017

# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig:  version 375.26  (buildd@debian)  Fri Jan 13 02:38:29 UTC 2017

Section "ServerLayout"
        Identifier     "Layout0"
        Screen      0  "Screen0" 0 0
        InputDevice    "Keyboard0" "CoreKeyboard"
        InputDevice    "Mouse0" "CorePointer"
        Option         "Xinerama" "0"
EndSection

Section "Files"
EndSection

Section "InputDevice"

        # generated from default
        Identifier     "Mouse0"
        Driver         "mouse"
        Option         "Protocol" "auto"
        Option         "Device" "/dev/psaux"
        Option         "Emulate3Buttons" "no"
        Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"

        # generated from default
        Identifier     "Keyboard0"
        Driver         "kbd"
EndSection

Section "Monitor"
        Identifier     "Monitor0"
        VendorName     "Unknown"
        ModelName      "Idek Iiyama PLX2380H"
        HorizSync       30.0 - 83.0
        VertRefresh     55.0 - 76.0
        Option         "DPMS"
EndSection

Section "Device"
        Identifier     "Device0"
        Driver         "nvidia"
        VendorName     "NVIDIA Corporation"
        BoardName      "GeForce GTX 770"
EndSection

Section "Screen"

# Removed Option "metamodes" "DVI-I-1: nvidia-auto-select +1920+0, HDMI-0: nvidia-auto-select +0+0 { ForceCompositionPipeline = On }"
        Identifier     "Screen0"
        Device         "Device0"
        Monitor        "Monitor0"
        DefaultDepth    24
        Option         "Stereo" "0"
        Option         "nvidiaXineramaInfoOrder" "DFP-1"
        Option         "metamodes" "DVI-I-1: nvidia-auto-select +1920+0 {ForceCompositionPipeline=On}, HDMI-0: nvidia-auto-select +0+0 {ForceCompositionPipeline=On, ForceFullCompositionPipeline=On}"
        Option         "SLI" "Off"
        Option         "MultiGPU" "Off"
        Option         "BaseMosaic" "off"
        SubSection     "Display"
                Depth       24
        EndSubSection
EndSection

3. Steam

Not sure how valid this still is. When I installed Steam, the i386 architecture needed to be activated. To enable i386 (multi architecture) on amd64:

dpkg --add-architecture i386
apt update
apt upgrade

Install deb from website Steam:

dpkg -i steam_latest.deb

After running steam:

Error:
        libGL.1.so
        /usr/lib/i386-linux-gnu/nvidia/current/libGL.so.1.0.0

        glXChooseVisual failed steam debian

Apparently, not all i386 libraries are installed:

apt install xserver-xorg-video-nvidia:i386
apt install --reinstall nvidia-kernel-dkms

Start nvidia-settings and use it to set your screens or use xorg.conf

That's all folks.