Ezequiel Mastrasso

View Original

RHEL/CentOS 7.3 nvidia-prime setup

EDITED: 1/07/2018
Added fix to be able to use the laptop display+hdmi output
————————-

Bumblebee (optirun) works in most cases, including CUDA apps. However….
In Some rare cases software (including Autodesk Maya of course!) use direct Nvidia drivers calls that bumblebee currently has no bridge for (instead of the system libs), so Maya for ie: thinks the video card has 0MB of memory and crashes.

This setup uses xrandr (insteand of VirtualGL) to render the buffer on the nvidia gpu  (set up as headless) and copying it to the intel one that has the screen.
This setup works well with 3d software like The Foundry Nuke, Autodesk Maya, Autodesk Mudbox, etc, at the expense of the battery life.

Word of advice:
After the clean install, get a partition cloning software like Acronis True Image or such.
I found xrandr to be a little temperamental, and adding custom modes, wrong modes, modifying defaults one might leave your system without a gui for good (or at least i couldn’t figure out how to revert my changes)
Make a partition clone before the process, and after if all works as expected.

See this page for some info, where i got the setup working.
https://devtalk.nvidia.com/default/topic/957814/linux/prime-and-prime-synchronization/

On a clean RHEL 7.3 (or CentoOS 7.3) install:

  • add elrepo

  • yum upgrade Xorg (you need at least a Xorg with ABI 24 or higher), i got 1..19.xx-x

  • Open /etc/yum.repos.d/elrepo conf file and enable the kernel repo (change the line that says Enabled=0 to 1)

  • Yum install kernel-ml kernel-ml-devel (you need at least 3.13 with DRM enable)

  • Download the latest drivers from nvidia

  • Blacklist Nouveau (the usual drill as in a nvidia only system)

  • systemctl set-default multi-user.target (this will make the system boot into the console)

  • Add this contents to this file (if it doesnt exist, create it) ~/.xinitrc

xrandr --setprovideroutputsource modesetting NVIDIA-0
xrandr --auto
startx

  • lspci |grep VGA, take note of the PCI Bus ID of the Nvidia card (for ie mine is: 01:00:00)

  • Add this contents to this file (if it doesnt exist, create it) /etc/X11/xorg.conf, replacing mine PCI BusID with your Nvidia

Section "Module" Load "modesetting" EndSection Section "ServerLayout" Identifier "layout" Screen 0 "nvidia" Inactive "intel" EndSection Section "Device" Identifier "intel" Driver "modesetting" EndSection Section "Screen" Identifier "intel" Device "intel" EndSection Section "Device" Identifier "nvidia" Driver "nvidia" BusID "PCI:1:0:0" EndSection Section "Screen" Identifier "nvidia" Device "nvidia" Option "AllowEmptyInitialConfiguration" EndSection

  • NOTE: AllowEmptyInitialConfiguration, this is required so the nvidia drivers won’t use the HDMI output as default, leaving you with a headless system if the screen is not present!

  • init 3

  • from the command line Install Nvidia drivers, when asked to setup a xorg.conf for you, press no! we want to keep our own xorg.conf we just did

  • Reboot the system, it will go into the console

  • at this stage, xrandr wont see any devices! as the x server is not loaded, you wont be able to change any config in randr at this point except to add or remove modes

  • dmesg |grep nvidia, check the module is loaded

  • dmesg |grep nouveau, check the module is not loaded! if it is, try another method to blacklist it until it doesnt show here after booting

  • now do xinit, or startx

  • if everything worked correctly, run systemctl set-default graphical.target to boot into the gui

  • if you have any issue, check your /var/log/Xorg.0.log to see what happened

  • NEW: this is the xrandr command i run to setup my single screen

cvt 1920 1080 60 sudo xrandr --newmode "1920x1080_60.00" 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync sudo xrandr --addmode eDP-1-1 1920x1080_60.00 xrandr --output eDP-1-1 --mode 1920x1080_60.00

note: for some reason, i had to add the full hd mode to my 4k laptop screen, if you dont need this, just use the last xrandr line
note2: check your own output names with xrandr –verbose

  • I can now connect the second screen to the hdmi and it will fire up instantly.
    but anyway here is the base command i would run to configure it further on gdm start up

xrandr --output HDMI-0 --mode 1920x1080 --right-of eDP-1-1