From d7da16ecfa5cadb643df78694db44963ba665cbe Mon Sep 17 00:00:00 2001 From: Shubham Saini Date: Wed, 8 Feb 2023 16:19:28 -0800 Subject: init --- content/posts/optimus-void.md | 98 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100755 content/posts/optimus-void.md (limited to 'content/posts/optimus-void.md') diff --git a/content/posts/optimus-void.md b/content/posts/optimus-void.md new file mode 100755 index 0000000..6ae889c --- /dev/null +++ b/content/posts/optimus-void.md @@ -0,0 +1,98 @@ +--- +title: "Using Optimus on Void or Non Systemd Distros" +date: 2019-09-13T12:10:56+05:30 +description: This article is for those who are a victim of laptop vendors but want to squeeze out maximum performance of their machine. +draft: false +--- + +## What is optimus technology? +According to gentoo wiki +> NVIDIA Optimus is a proprietary technology that seamlessly switches between two GPUs. It is typically used on systems that have an integrated Intel GPU and a discrete NVIDIA GPU. The main benefit of using NVIDIA Optimus is to extend battery life by providing maximum GPU performance only when needed. + +There is a great wiki about using bumblebee(not transformer) on void linux but bumblebee’s project last commit was in 2013 and it doesn’t support vulkan, so no luck for linux gamers. A better way is to use a utility like nvidia-prime which is available for ubuntu or optimus-manager which is available for arch-based distros(available in AUR). Sadly, these projects require systemd as a init system. There is only one project which uses shell script and partly depends on systemd but is pretty hackable - [nvidia-xrun](https://github.com/Witko/nvidia-xrun). + +## Problem on void +libglvnd is broken in void repos which makes it hard to have multiple drivers from different vendors to coexist on the same filesystem. This results in having either openGL libraries from mesa or nvidia. + +## The Hack +Install nvidia openGL libraries in /opt directory and point nvidia-xrun to use them. This is just a workaround of libglvnd. + +First of all install these packages: +- nvidia-dkms - for kernel modules +- libGL libEGL - mesa drivers +- xrandr xorg - display server +- any wm/de + +Create a file /etc/modprobe.d/nvidia.conf for blacklisting nvidia kernel modules so that they won’t be loaded at boot. Add the following text: +``` +blacklist nvidia +blacklist nvidia-drm +blacklist nvidia-modeset +blacklist nvidia-uv +blacklist nouveau +``` + +Next create some directories +```shell +$ sudo mkdir /opt/nvidia +$ sudo mkdir -p /opt/nvidia/fakeroot/usr/lib +$ sudo mkdir -p /opt/nvidia/fakeroot/usr/lib32 +$ sudo mkdir /etc/X11/nvidia +``` + +Now we have to create a fakeroot directory with nvidia openGL libraries +```shell +$ sudo ln -s /opt/nvidia/fakeroot/usr/lib /opt/nvidia/fakeroot/lib +$ sudo ln -s /opt/nvidia/fakeroot/usr/lib32 /opt/nvidia/fakeroot/lib32 +$ sudo chmod 755 -R /opt/nvidia/fakeroot +$ xbps-install --rootdir /opt/nvidia/fakeroot --repository https://alpha.de.repo.voidlinux.org/current --repository https://alpha.de.repo.voidlinux.org/current/nonfree --repository https://alpha.de.repo.voidlinux.org/current/multilib --repository https://alpha.de.repo.voidlinux.org/current/multilib/nonfree --yes --sync nvidia nvidia-libs nvidia-libs-32bit +``` + +Next clone my repo and move the scripts to respective location +```shell +$ git clone https://github.com/fd0e/optimus-hack.git +$ cd optimus-hack/ +$ sudo cp -r xorg.conf xorg.conf.d /etc/X11/nvidia/ +$ sudo cp run.sh /opt/nvidia/ +``` + +There is also off.sh which ensures that GPU is off. Run this as root at boot. + +Also add these lines in your ~/.xinitrc. +```shell +# load additional configs +if [ "$2" = "nvidia" ]; then + XINIT_D="/etc/X11/nvidia/xinit/xinitrc.d" +else + XINIT_D="/etc/X11/xinit/xinitrc.d" +fi + +if [ -d "$XINIT_D" ]; then + for f in "$XINIT_D/?*.sh" ; do + [ -x "$f" ] && . "$f" + done + unset f +fi +unset XINIT_D + +# additional nvidia specific settings +if [ "$2" = "nvidia" ]; then + xrandr --setprovideroutputsource modesetting NVIDIA-0 + xrandr --auto +fi +``` + +Now close your X session and run /opt/nvidia/run.sh. + +And boom! Your X session is now running on nvidia opengl libraries. + +## Troubleshooting +If steam complains about missing libGL. Run steam using this command +```shell +$ STEAM_RUNTIME_PREFER_HOST_LIBRARIES=0 steam +``` + +## Conclusion +I don’t recommend using this method but this is the only thing that worked for me. + +See this article for more details - [here](https://www.ifnull.org/articles/void_optimus_nvidia_intel/#disqus_thread) -- cgit v1.2.3