10

The answer on Nvidia drivers - Unable to check "Force full composition pipeline" does something that makes my laptop unable to detect the external monitor. Undoing the solution restores the ability to detect the second monitor. I'm still left with tearing on any type of video playback. Youtube, video player, etc.

I am using Ubuntu 18.04 with i7-8750H and RTX 2070 (nvidia-driver-430).

Edit:

Output of inxi:

Graphics:  Card-1: Intel Device 3e9b
           Card-2: NVIDIA Device 1f10
           Display Server: x11 (X.Org 1.20.4 )
           drivers: modesetting,nvidia (unloaded: fbdev,vesa,nouveau)
           Resolution: 2560x1440@59.95hz, 1920x1080@144.00hz
           OpenGL: renderer: GeForce RTX 2070/PCIe/SSE2
           version: 4.6.0 NVIDIA 430.26

Screenshot of nvidia settings:

nvidia settings

Kulfy
  • 17,696
gord0
  • 305

1 Answers1

20

Update 08/09/2019:

It seems that gord0 (OP) is right in their comment. You don't need to go through all of the steps that I had previously described (I'm not deleting them, just in case that someone finds them helpful) to get rid of tearing.

What you have to do to is:

  1. Open NVIDIA X Server Settings.

  2. Go to X Server Display Configuration.

  3. Select the screen that you want.

  4. Click the Advanced button.

  5. Enable Force Composition Pipeline or Force Full Composition Pipeline (try both and enable the one that gives you the best results).

  6. Click the Apply button.

Alternatively, you can enable Force Composition Pipeline or Force Full Composition Pipeline by running the following commands in your terminal:

  • For Force Composition Pipeline:

    nvidia-settings --assign CurrentMetaMode="$(xrandr | sed -nr '/(\S+) connected (primary )?([0-9]+x[0-9]+)(\+\S+).*/{ s//\1: \3 \4 { ForceCompositionPipeline = On }, /; H}; ${ g; s/\n//g; s/, $//; p }')"
    
  • For Force Full Composition Pipeline:

    nvidia-settings --assign CurrentMetaMode="$(xrandr | sed -nr '/(\S+) connected (primary )?([0-9]+x[0-9]+)(\+\S+).*/{ s//\1: \3 \4 { ForceFullCompositionPipeline = On }, /; H}; ${ g; s/\n//g; s/, $//; p }')"
    

These commands use xrandr and sed with some regular expressions to get the current monitor setup in the appropriate format and use it as input to the nvidia=settings --assign command, which enables the desired setting.

You should now have no screen tearing.

In case the changes are not persistent and get discarded after reboot, you can do the following:

  1. Run the appropriate, for your case, command from the commands above and make sure that it works correctly, that is you have no screen tearing in your monitors.

  2. Add one of the following commands (depending on what worked best for you) to your Startup Applications.

    • For Force Composition Pipeline:

      bash -c "sleep 10 && nvidia-settings --assign CurrentMetaMode=\"$(xrandr | sed -nr '/(\S+) connected (primary )?([0-9]+x[0-9]+)(\+\S+).*/{ s//\1: \3 \4 { ForceCompositionPipeline = On }, /; H}; ${ g; s/\n//g; s/, $//; p }')\""
      
    • For Force Full Composition Pipeline:

      bash -c "sleep 10 && nvidia-settings --assign CurrentMetaMode=\"$(xrandr | sed -nr '/(\S+) connected (primary )?([0-9]+x[0-9]+)(\+\S+).*/{ s//\1: \3 \4 { ForceFullCompositionPipeline = On }, /; H}; ${ g; s/\n//g; s/, $//; p }')\""
      

    The sleep 10 command just adds a 10 seconds delay to ensure that the desktop has fully loaded before running the nvidia=settings --assign ... command. You may need to add a larger delay if your desktop takes more time to fully load.

Alternatively, you can save the configuration by clicking Save to X Configuration File button in NVIDIA X Server Settings.


Old answer. Try these if the above method doesn't work for you.

What is suggested in the answer you posted is correct for Ubuntu 16.04.

For Ubuntu 18.04 and later versions, you have to change options nvidia_387_drm modeset=1 to options nvidia-drm modeset=1 (the Nvidia driver version is no longer needed).

So what you have to do is:

  1. Create a file in your /etc/modprobe.d directory called zz-nvidia-modeset.conf

    nano /etc/modprobe.d/zz-nvidia-modeset.conf 
    
  2. Add the following lines to it:

    #enable prime-sync
    options nvidia-drm modeset=1
    
  3. Save the file by pressing Ctrl+O and Ctrl+X.

  4. From the terminal run:

    sudo update-initramfs -u
    
  5. Reboot.

To enable the NVIDIA adapter, after rebooting you have to run:

sudo prime-select nvidia

Then log out and log back in.

Edit: If you are using GNOME, you may have to use another display manager, such as lightdm, since gdm does not allow external monitors to work with nomodeset=1 (I had to do this on 18.04 but not on 20.04).

  • To install lightdm run:

    sudo apt install lightdm
    
  • After installing lightdm run

    sudo dpkg-reconfigure lightdm
    

    and select it as your display manager in the terminal window that appears.

  • Nope. You this is incorrect. You're listing the steps I already did. I did them again and sure enough bye bye external monitor. Did sudo prime-select nvidia it told me I was already using nvidia. Undid the solution, well hello external monitor. Hello tearing. – gord0 Sep 03 '19 at 07:11
  • The instructions are correct. The problem is gdm, if you are using Gnome. You have to use lightdm as your display manager, since gdm with nomodeset does not allow external monitors. The steps above are what I do to have my second monitor without tearing on Xubuntu. I have read them in an Ask Ubuntu post that I couldn't find yesterday, but I found it today. Here it is: https://askubuntu.com/questions/1079135/screen-tearing-on-ubuntu-18-04 – BeastOfCaerbannog Sep 03 '19 at 08:18
  • @gord0 I updated my answer to include the steps to install lightdm. – BeastOfCaerbannog Sep 03 '19 at 08:27
  • The monitor stays connected, tearing still happens. – gord0 Sep 03 '19 at 22:57
  • Did you play around with the Nvidia settings? For example, did you enable Force Full Composition Pipeline for your external monitor? – BeastOfCaerbannog Sep 04 '19 at 06:21
  • updated question with screen shot – gord0 Sep 04 '19 at 20:00
  • So did you enable Force Full Composition Pipeline? Did it have any effect? – BeastOfCaerbannog Sep 04 '19 at 22:48
  • It would seem enabling it fixes tearing. I suspect I didn't need to do any of the other steps other than checking that box. – gord0 Sep 05 '19 at 20:29
  • @gord0 I updated my answer based on your last comment. Please check it out and tell me what you think. May I also suggest that you change the title of the question, so that others with the same problem can find it more easily? – BeastOfCaerbannog Sep 08 '19 at 10:37
  • Edited the title. – gord0 Sep 08 '19 at 15:04
  • It did fix my screen tearing issue on 20.04 lts, but since i changed the display manager to lightdm, ubuntu's screen lock is no longer working – z3r0c00l_2k May 17 '20 at 09:06
  • @z3r0c00l_2k In 20.04 I didn't have to switch to LightDM to remove screen tearing. GDM works fine, at least in my case. So, maybe try to change your display manager to GDM by running sudo dpkg-reconfigure lightdm and selecting GDM. – BeastOfCaerbannog May 17 '20 at 09:50
  • This didn't work for me in Ubuntu 20.04 but this other answer worked perfectly: https://askubuntu.com/a/1266161/21195 – Rodrigo Oliveira Oct 24 '20 at 22:35
  • FYI, this does not work on some Optimus configurations as they don't have that force composition option – unixandria Jan 28 '21 at 16:25