19

How can I add a virtual monitor with Nvidia proprietary driver?  Previously I used an Intel card with this solution, which worked fine: Add VIRTUAL output to Xorg.

Now I want to switch to new hardware, without an Intel card. The solution mentioned in VNC-Server as a virtual X11 monitor to expand screen doesn't work in my case. When I want to add the mode to an output, xrandr throws an error.

xrandr --newmode test 173.00  1920 2048 2248 2576  1080 1083 1088 1120 -hsync +vsync
xrandr --addmode "DP-1" test
X Error of failed request:  BadMatch (invalid parameter attributes)
  Major opcode of failed request:  140 (RANDR)
  Minor opcode of failed request:  18 (RRAddOutputMode)
  Serial number of failed request:  41
  Current serial number in output stream:  42

Basic data:

  • Hardware: HP ZBook 15 G3, configured for discrete graphics (Optimus doesn't work!)
  • Software: Debian 10.0.2; Kernel: 4.19.0, Nvidia-Driver-Module: xserver-xorg-video-nvidia-legacy-390xx

If you ask, why I am doing this: I use a software to transfer the virtual screen to another machine via ethernet to achieve dual monitors with two notebooks. (https://github.com/B-LechCode/sooScreenShare)

Update: There is now a proposed solution which works on my machine, but it's unable to add new modes like 1920x1200. Maybe someone has an idea?

1
  • same problem... were you able to fix it?
    – Carlos
    Commented Nov 15, 2020 at 17:10

3 Answers 3

7

I have a solution that works for me, though it's missing the ability to choose completely arbitrary resolutions. To be clear, this is just for the proprietary nvidia driver; the open-source nouveau driver works differently, as do other video card drivers.

The short version is: Use the ConnectedMonitor nvidia xorg.conf Screen option to activate the extra output in addition to your main monitor.

Here's the long version:

Run xrandr --query to get the names of your primary output and the unconnected one you plan to use for the virtual screen. For example, I get the following output:

LVDS-0 connected primary 1440x900+0+0 (normal left inverted right x axis y axis) 331mm x 207mm
   [various monitor modes elided]
DP-0 disconnected (normal left inverted right x axis y axis)
DP-1 disconnected (normal left inverted right x axis y axis)
DP-2 disconnected (normal left inverted right x axis y axis)
DP-3 disconnected (normal left inverted right x axis y axis)
DP-4 disconnected (normal left inverted right x axis y axis)
DP-5 disconnected (normal left inverted right x axis y axis)

So in my case, the laptop screen is LVDS-0 and I have DP-0 through DP-5 available. Like you, I'll choose DP-1 for the virtual screen.

You will need to add an xorg.conf Screen configuration, as well as a Device section for the screen to use. That can be anywhere xorg will find it. I put mine in /etc/X11/xorg.conf.d/30-virtscreen.conf . In that file, a minimal setup is:

Section "Device"
    Identifier  "nvidiagpu"
    Driver      "nvidia"
EndSection

Section "Screen"
    Identifier  "nvidiascreen"
    Device      "nvidiagpu"
    Option      "ConnectedMonitor" "LVDS-0,DP-1"
EndSection

This tells the driver to use the DP-1 output even if it doesn't detect a monitor connected to it. Note that you have to list your laptop monitor (or a real, physical monitor) too, if you want to use it! If you only list the virtual output, the driver will not activate any other outputs, even if it detects monitors connected to them.

Now restart X. You should see two active monitors with xrandr and other display-querying programs.

On my system the newly-activated virtual output has a variety of resolutions available. I can select any of them (e.g. via xrandr --output DP-1 --mode 1600x900) and the virtual output will resize itself. I cannot, however, add new modes (e.g. if I wanted a 1920x1080 resolution). That still gives me the "invalid parameter attributes" error. Fortunately, I can live with the modes available to me. With luck, you'll have something useful preset for you, too.

3
  • WOW! Thank you, I will test this, as soon I have time for it.
    – B-LechCode
    Commented Apr 3, 2021 at 12:53
  • It works! The only thing is: There is no 1920x1200 mode available. Maybe there are other options for the config file to achieve this?
    – B-LechCode
    Commented Jul 4, 2021 at 11:47
  • This worked for me as well, but in my case I needed to directly modify /etc/X11/xorg.conf, for some reason it was not working through xorg.conf.d. Commented Oct 20, 2022 at 20:26
1

https://askubuntu.com/a/803053/1568608 resolve asciiphil problem but You can't change resolution to for example 1920x1080 (invalid parameter attributes problem in asciiphil answer). To resolve this problem just add second Option in section "Screen":

Section "Screen"
    Identifier  "nvidiascreen"
    Device      "nvidiagpu"
    Option      "ConnectedMonitor" "LVDS-0,DP-1"
    Option      "ModeValidation" "NoDFPNativeResolutionCheck,NoVirtualSizeCheck,NoMaxPClkCheck,NoHorizSyncCheck,NoVertRefreshCheck,NoWidthAlignmentCheck"
EndSection
1
  • (1) asciiphil’s answer is over 2500 characters (> 400 words) long, and it’s not obvious to me what you mean by ‘their problem’.  Please say what your suggestion does and what problem it is solving. (2) I’m having trouble telling whether you are answering B-LechCode’s question or not.  If you are, please be clearer about that (referring to asciiphil’s post, if appropriate).  If not, you probably shouldn’t be posting it here at all. … … … … … … … … … … … … … … … … … … … … … … … … … … … … Please do not respond in comments; edit your answer to make it clearer and more complete. Commented Feb 6, 2022 at 18:38
0

If you'd like to attach a virtual display, just use

Option         "ConnectedMonitor" "HDMI-0"

replacing HDMI-0 with whatever display port you'd like your graphics card to use for the virtual display to the "Screen" section of your xorg.conf. Adding the following lines to will disable all of the necessary checks to allow you to set any unsupported resolution on newer NVIDIA graphics cards. Under Section "Screen":

Option         "UseEDIDFreqs" "False"
Option         "ModeValidation" "NoDFPNativeResolutionCheck,NoVirtualSizeCheck,NoMaxPClkCheck,NoHorizSyncCheck,NoVertRefreshCheck,NoWidthAlignmentCheck AllowNonEdidModes"

then add the mode using the results from cvt and you're good to go! If you're still having trouble getting the resolution to set, you can add the ModeLine to your Monitor section and add the mode to your Display section to load it. More complete example:

Section "Monitor"
Modeline "2560x1440_120.00" <cvt output stuff>
EndSection

and

Section "Screen"
    SubSection     "Display"
        Depth       24
        Modes      "2560x1440_120.00"
    EndSubSection
    Option         "ConnectedMonitor" "HDMI-0"
    Option         "UseEDIDFreqs" "False"
    Option         "ModeValidation" "NoDFPNativeResolutionCheck,NoVirtualSizeCheck,NoMaxPClkCheck,NoHorizSyncCheck,NoVertRefreshCheck,NoWidthAlignmentCheck AllowNonEdidModes"
EndSection

These options should be added to a configuration file you generated by running nvidia-xconfig and are not representative of a complete or functional xorg.conf.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .