Code Done Right!

Ubuntu – AMD CPU/nVidia GPU pairing problem

If you have an AMD Ryzen CPU paired with nVidia GPU you will run into some problems as Ubuntu does not play well with this pairing. In order to remedy this you have to tweak configs a bit by yourself.

Cause of the problem: Ubuntu’s prime-select feature still does not work for AMD/nVidia pairing and requires manual tweaking, it works only for Intel/nVidia pairing.

Modify /etc/X11/xorg.conf if exists, or create if it does not
sudo nano /etc/X11/xorg.conf

Inside paste the following

Section "ServerLayout"
  Identifier "layout"
  Option "AllowNVIDIAGPUScreens"
Modify /usr/share/X11/xorg.conf.d/10-amdgpu.conf
sudo nano /usr/share/X11/xorg.conf.d/10-amdgpu.conf 


Driver "amdgpu"


Driver "modesetting"
Modify OutputClass of /usr/share/X11/xorg.conf.d/10-nvidia.conf
sudo nano /usr/share/X11/xorg.conf.d/10-nvidia.conf 

by adding

Option "PrimaryGPU" "Yes"

Caution! This step needs to be repeated after every nVidia driver update.

Create two files named optimus.desktop in the following locations
  • /etc/xdg/autostart/
  • /usr/share/gdm/greeter/autostart/
sudo nano /etc/xdg/autostart/optimus.desktop
sudo nano /usr/share/gdm/greeter/autostart/optimus.desktop

Inside both paste the following

[Desktop Entry]
Exec=sh -c "xrandr --setprovideroutputsource modesetting NVIDIA-0; xrandr --auto"

Caution! Exec… line is long, make sure it is actually one line

After all files have been modified correctly – reboot

Greeter displayed on the wrong screen

Caution! If you have the auxiliary display plugged in, greeter might be displayed only on the auxiliary monitor! Mouse movement can be restricted to that monitor as well!

  • Open Ubuntu Settings
  • Navigate to Displays
  • Select Single Display option
  • Set Primary Display to 1 Built-in display
  • Click Apply
    • You should have only your laptop display working right now
  • Go back to Displays settings and set them however you like now
    • Displays should work correctly now
  • To force greeter on built-in display open terminal and run the following
cd ~/.config
sudo cp monitors.xml /var/lib/gdm3/.config/

Now everything should be set-up correctly


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.