Leap 42.1 Optimus system with nvidia-prime instead of bumblebee

A way to check power consumption - if you don’t have an external power meter - is installing powertop
and running it in a console as root.
If your laptop is running on battery it shows the power the laptop is taking up at the moment.

I run the switchoffNvidia.sh right after logging into Plasma.
It’s necessary to power on the Nvidia card during booting up for the correct initialization of the hardware.
The Nvidia kernel modules are loaded thereby, but not needed when you run in ‘prime-select intel’ mode.

The switchoffNvidia.sh script first unloads these Nvidia modules and then the powering off is possible.

If any Nvidia module is still loaded (check with lsmod | grep nvidia), powering off won’t work.

cat /proc/acpi/bbswitch

is showing the actual state of power (ON/OFF) of your graphics card.

Unfortunately running Leap 42.2 gives an error when logging out to switch to nvidia (prime-select nevidia):

Application: ksmserver-logout-greeter (ksmserver-logout-greeter), signal: Aborted

Nvidia already has the repo up and running for Leap 42.2, so I thought it was time to take a look at the beta and also try the suse-prime functionality. But that’ s not working at the moment. If someone wants a log or anything else I’m happy to provide it.

Greetings,

Martin

Hi, I haven’t tried suse-prime on 42.2 beta yet, but just to avoid confusion please be aware that suse-prime needs drivers from the bumblebee project, e.g. from here http://download.opensuse.org/repositories/home:/Bumblebee-Project:/nVidia:/370.28/openSUSE_Leap_42.2/
to avoid overwriting the Intel openGL libraries.
Drivers from the NVIDIA repo, e.g. from here Index of /opensuse/leap/42.2/x86_64 simply don’t work with suse-prime AFAIK.
Leaving the last word to Bruno or Bo, of course :wink:

The first post is pointing to Index of /opensuse/leap/42.1, so I would expect to take the new drivers for 42.2 from there.
I will see if another route will make it work.Thx.

I double checked, you are right, so who is confused now is ME…
So at the moment apparently:

  1. suse-prime should work with 42.1 and the regular NVIDIA driver (original info from this thread);
  2. suse-prime-alt should work with Tumbleweed and the Bumblebee Project driver (what I remembered, info here: Welcome - openSUSE Build Service
  3. neither suse-prime nor suse-prime-alt are currently built for 42.2 beta yet, so we definitely need a word from Bo (or Bruno) :\

k what now? :smiley: all this fidling around for something that’s turned off by default?

My current nvidoff script is the following

#!/bin/sh
modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia
tee /proc/acpi/bbswitch <<<OFF


But if I run this & afterwards check with cat /proc/acpi/bbswitch it says ON - which doesnt seem quite right now does it? :smiley:

also before I ran the script I checked the *lsmod | grep nvidia *which produced this.

vidia_drm             49152  0 
nvidia_modeset        770048  1 nvidia_drm
nvidia_uvm            806912  0 
nvidia              11497472  2 nvidia_modeset,nvidia_uvm
drm_kms_helper        139264  2 i915,nvidia_drm
drm                   385024  4 i915,drm_kms_helper,nvidia_drm


erhm and there’s also something amiss with my “Adjust brightness” slider, which just doesn’t seem to work at all…

Current batterylife gives me about 2hours at 100% - whilst on Windows I easily get double… :frowning:

I have my old Asus clamshell on 13.1, it won’t accept anything newer, but I’m pleased with having it as my summer textprocessor. But if I’m not totally wrong your problem might be that you have, by installing nvidia-drivers, blacklisted the nouveau driver. And, I’m not sure here, but I think that the kernel relies on the noveau driver on boot, and this is what blacklisting blocks, to make this magic powering off the nvidia card. So uninstall everything nvidia and make sure you don’t have any entry in /etc/modprobe.d blacklistning nouveau and when you’re sure of that also make sure you run the command mkinitrd, this last one is often overseen.

Probably your Nvidia card is the graphics card in present use when you executed your nvidoff script.
If a hardware component is in use, you cannot unload the kernel modules (nvidia_drm nvidia_modeset nvidia_uvm nvidia) that are needed to make the component work.
And you cannot switch off a component with kernel modules loaded.

Try to unload manually as root in the console and wait for the systems answer:

modprobe -r nvidia_drm nvidia_modeset nvidia_uvm nvidia

If something like ‘modprobe: FATAL: Module nvidia is in use.’ is the answer, you are using the nvidia card.

Then:
Execute as root in the console

prime-select intel

log out of KDE, log in and then execute your script nvidoff as root, or
one line of the script after the other in the console to check, if everything is working right.

super! everything is working just fine… now how do I automate this? because my batterylife just went up for a good +2hours :slight_smile: Happy camper here… now only to figure out why my brightness slider isnt working… :confused: full brightness all the time isn’t doing any good to my battery as well…

Well, changed to Gnome again because I couldn’t get used to a certain workflow in KDE. Installed Leap 42.2 RC1:

No problems at all! So it might be a KDE issue.

Greetings,

Martin

+1

The same thing happens to me, I’ve tried with the gnome desktop and it works fine but in kde the screen stays black.

I’m talking about opensususe leap 42.2

Greetings.

Big thanks for the howto.
Did as instructed. Not clear where to put script files, but saved them to /usr/sbin. (/usr/sbin/switchoffnVidia.sh, /usr/sbin/selectnVidia.sh, this becaus that no one except root should be able to edit)

To automatically save power this below can be done.
Added one line to /etc/sudoers to allow anyone (in user group) to switch off card to save power.

%users  ALL = (root) NOPASSWD:/usr/sbin/switchoffnVidia.sh

New script, ~/bin/checknVidia, that check if card is in use, if not remove modules and turn of in /proc/acpi/bbswitch

if  ! -f /dev/shm/clearnVidia ]                                       # If file doesn't exists, continue.
    then
        touch /dev/shm/clearnVidia                                     # put a file in RAM to quit script faster if run again, checking above.
        sleep 20                                                       # Sleep for 20 sec. Read somewhere that card needed to get started before turned of
        if  $(glxinfo | grep Open | grep NVIDIA | wc -l) -lt '1' ]]  # If no NVIDIA is used in glx, continue
            then  
                sudo /usr/sbin/switchoffnVidia.sh                      # Execute script to save power
        fi
    fi

Also added one line to ~/.profile, with a & at the end to run in background

/home/***$USER***/bin/checknVidia.sh &

Unfortunately suse-prime seems not to work with Leap42.2 under KDE.
I tried, but get errors like

Qt bearer thread [18243] : segfault at 9 ip ....... error 4 in libQt5DBus.so.5.6.1

Gnome desktop would be an alternative, but I am back to bumblebee at the moment.

Same problem here in KDE. I hope that this problem will be fixed soon.

Sorry, I’m confused here. What doesn’t work in KDE with prime?
Yes, when executing ‘selectnvidia’ or ‘prime-select intel’ some KDE/Plasma parts crash, i.e. log out. I usually run it in konsole logged in as root, and intended to log out to use new prime state. Then I can run, as root, either ‘shutdown -r now’ or more safe, in multi user system ‘loginctl terminate-user quinness’ or whatever the user’s id is.
When logged in again, KDE/Plasma is running with/without nVidia as selected. Now KDE/Plasma work as supposed. I.e. 1700 fps with nVidia, instead of 240 fps running glxsphers on Intel.
Is it that some KDE/Plasma parts crash right after prime-select that’s the problem?

I can basically confirm that on a test install of mine: as long as I avoid SDDM everything else in Plasma5 seems to work properly, even with OpenGL 3.1 compositing.
That is, for instance, by enabling Auto Login and then using another VTx to issue shutdown or reboot as needed.
Logging out the current user apparently works but a new login greeter never appears again.
I’m not a regular user of SUSE-Prime, so cannot debug it myself, sorry.

That is on a fresh 42.2 KDE install from DVD, plus the regular x11-video-nvidiaG04-367.57-18.2.x86_64.rpm and dependencies from Index of /opensuse/leap/42.2 and suse-prime from Knurpht repo.

The same seems true with Gnome and GDM, as long as I bypass the login screen, i.e. by enabling autologin and just shutting down when I am finished.
If I logout something just hangs apparently prior to showing the login greeter again, while the system is still up and running allowing operation on the VTx consoles.

No luck with LightDM, XFCE, IceWM when the Nvidia chip is selected. Everything works with Intel with every desktop I tried so far.

Well its still a no go indeed for KDE and plasma. On Gnome however I have no issues at all on a multi user system. Switching from one user to the other, enableing Intel/Nvidia, all works flawlessly :slight_smile:
Greetings,

Martin
http://server.pinkdot.nl/test/suse-prime_gnome.png

It might depend on HW: still no joy here with Gnome on GeForce GTX 960M.

Might be hardware dependant also, but I tried KDE Neon and could install NVidia-prime. Had the same kms-greeter crash as on openSUSE, but only the first session. After a reboot, I had no problems whatsoever.

Also, I installed openSUSE Leap Gnome. As said, I have no problems is Gnome. When I tried to install KDE alongside Gnome, things went well as long as I only installed the plasma5-session. Installing the backports and a zipper dup brought back the issue in KDE.

I stopped looking at KDE. Although my kids love it, Gnome is more my cup of tea. And Leap is running great with suse-prime here!

Greetings,

Martin