Thanks to team at NCSU, they updated bumblebee project that can work on Thinkpad P51. After a small tweak, multiple monitors work on it.
First, should switch to text UI because nvidia should be compiled with kernel
sudo init 3
Then, login with your username.
sudo rpm -ivh https://linux.itecs.ncsu.edu/redhat/public/bumblebee/rhel7/noarch/bumblebee-release-1.3-1.noarch.rpm
sudo rpm -ivh https://linux.itecs.ncsu.edu/redhat/public/bumblebee-nonfree/rhel7/noarch/bumblebee-nonfree-release-1.3-1.noarch.rpm
sudo yum install bumblebee-nvidia bbswitch-dkms primus kernel-devel
Now, check if nvidia module was compiled correctly
sudo bumblebee-nvidia -check
IF it was not compiled correctly, it will be compiled automatically.
Now, you can use the discrete graphic card without much effort.
optirun glxgears # test
optirun command # run command with the discrete graphic card
However, many guys want to use more monitors, try this for dual monitors:
yum install intel-gpu-tools
At this time, intel-virtual-output does not detect displays, or if a no VIRTUAL outputs on ":0" message is obtained, edit the following two files as follows (and rebooting):
/usr/share/X11/xorg.conf.d/20-intel.conf
Section "Device" # This file does not exist by default Identifier "intelgpu0" Driver "intel" EndSection
/etc/bumblebee/xorg.conf.nvidia
Section "ServerLayout" Identifier "Layout0" Option "AutoAddDevices" "true" # Bumblebee defaults to false Option "AutoAddGPU" "false" EndSection Section "Device" Identifier "DiscreteNvidia" Driver "nvidia" VendorName "NVIDIA Corporation" Option "ProbeAllGpus" "false" Option "NoLogo" "true" Option "UseEDID" "true" # Bumblebee defaults to false Option "AllowEmptyInitialConfiguration" # Add this line # Option "UseDisplayDevice" "none" # Remove or comment out this line EndSection Section "Screen" # Add this section Identifier "Screen0" Device "DiscreteNvidia" EndSection
Once you reboot to graphic mode, you can try dual monitors, as
intel-virtual-output # extend desktop to a HDMI-port monitor, light it
optirun command # run command on the discrete graphic card
If you run kernel 5.5.6-2, try the unmanaged version of bumblebee-nvidia, which is best for you.
References:
1. https://www.linux.ncsu.edu/bumblebee/
2. https://wiki.archlinux.org/index.php/Bumblebee#Output_wired_to_the_NVIDIA_chip
2. https://unix.stackexchange.com/questions/321151/do-not-manage-to-activate-hdmi-on-a-laptop-that-has-optimus-bumblebee
3. http://www.tim-richardson.net/index.php/technology/linux-on-thinkpad-p50
4. https://askubuntu.com/questions/920644/17-04-cant-detect-hdmi-monitor-thinkpad-p51
5. https://github.com/Bumblebee-Project/Bumblebee
6. https://forums.centos.org/viewtopic.php?t=66178
7. https://linux.itecs.ncsu.edu/redhat/public/bumblebee/7Workstation/x86_64/
8. https://github.com/Bumblebee-Project/Bumblebee/issues/974
9. https://linuxhint.com/install-nvidia-drivers-centos/
10. https://negativo17.org/nvidia-driver/#Limitations_with_the_Nvidia_driver