Switch between GPUs in Fedora35

Install Nvidia driver from rpmfusion,

yum install --nogpgcheck https://mirrors.tuna.tsinghua.edu.cn/rpmfusion/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.tuna.tsinghua.edu.cn/rpmfusion/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
dnf install akmod-nvidia

Before rebooting, must sign nividia driver using MOK.der, if not, we will receive at boot, "nvidia kernel module missing. falling back to nouveau".

Or install Nvidia driver from official site,

Clean up akmod-nvidia,

dnf remove akmod-nvidia
dnf remove xorg-x11-drv-nvidia

To blacklist the nouveau drivers,

dracut -v /boot/initramfs-`uname -r`.img `uname -r` --force

/etc/default/grub

GRUB_CMDLINE_LINUX="rhgb quiet rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1"
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

After rebooting, download NVIDIA-Linux-x86_64-XXX.XX.XX.run from official site, install it using /root/signed-modules/MOK.* and reboot,
https://www.nvidia.com/download/index.aspx?lang=en-us

Check current GPU vendor,

1
glxinfo | egrep "OpenGL vendor|OpenGL renderer"

How to dynamically switch GPUs?

I found ue4 selecting /dev/nvidia0 by itself, we needn't care about if switch.

https://pellegrino.link/2015/11/29/signing-nvidia-proprietary-driver-on-fedora.html
https://www.cnblogs.com/Mingxx/p/3192483.html
https://docs.fedoraproject.org/en-US/quick-docs/how-to-set-nvidia-as-primary-gpu-on-optimus-based-laptops/