NVIDIA with Bumblebee and improving Battery BackupTags: nvidia, bumblebee, battery
The issue of Graphic cards and Battery Life has been a sticky one for me, and I believe most other laptop users too. The battery backup under Linux is simply awful. For instance, I can get ~5 hours on my Laptop using Windows. Linux lands me at max 1.5-2 hours under similar usage. I believe most Linux users would have similar experiences.
Here’s some of the things I did which have helped increase the battery backup by a large amount in my case:
Get your graphics card straight
This is one of the biggest reasons on Linux for low battery backup. So what happens is, if your laptop has a dedicated graphics card, its going to stay on no matter whether its being used or not, no matter whether you’re reading a PDF or watching a movie. Even if your laptop is using the default fallback graphics most of the time, Intel HD graphics as they’re called in Windows; even then the dedicated graphics card stays on.
One straightforward way to fix this is to disable the graphics card entirely in the systems settings of your laptop accesible during bootup. That’s not a pretty idea, I can almost see some frowns on this.
Of course we have a better way, its Linux :) . I’ll be mentioning about NVIDIA only, as that’s the one I’m using. There’s a project called Bumblebee for NVIDIA cards on Linux which handles the job of graphics switching. You can install bumblebee, and it’ll happily make the integrated graphics the default, and start the dedicated one only when needed. Here’s how I’ve got Bumbleebee to work for me in the past
If you’re on Arch Linux, do exactly what this says: You guessed it right, ArchWiki. Try to do these steps when you haven’t installed your Graphics drivers yet. If you have them already, then remove them first. I always install the proprietary NVIDIA drivers, so I cannot comment about Nouveau, but given ArchWiki’s reputation, it should be easy too.
For Gentoo I found information very hard to find. Gentoo Wiki is literally clueless about Bumblebee. I stumbled upon this really good link here: http://blog.fkmclane.net/nvidia-optimus-gentoo. Again, proprietary drivers work for me.
Once you have Bumblebee done (remember to add your user to the bumblebee group), try restarting and running
glxspheres64 with and without
optirun prefixed. You should see the difference.
This step is of quite some significance. Now your Graphic card won’t be put to work unless it’s told to, by the
primusrun commands. That also means that if you play games on Steam, they won’t use the Graphics card. A fix for that is as follows. Right click on the game in your Steam Library and go to properties. Click on ‘set launch options’ and put this there:
optirun %command% -nojoy. This should do the trick.
Powertop is a great nifty tool to monitor your power usage. But importantly here, you can actually use it to fix your battery life. * sudo pacman -S powertop * sudo emerge –ask powertop * sudo apt-get install powertop
Fire it up (it requires sudo), have a look at the current stats. See if some program is causing more wakeups than it should (more the number of wakeups, more the power consumtion). Look at your CPU idle stats. If they’re too high, you should perhaps consider setting up a CPU governor.
The interesting part, look at the ‘Device Stats’ tab. Here you’d see what hardware is consuming battery. You’d see things like Bluetooth, and your graphics card. I personally disable my Bluetooth completely using this script at startup https://github.com/sakshamsharma/my-configs/blob/master/.myscripts/blueoff. It might not work for you, but you get the point. About the Graphics card still being at 100%, that’s because of one last trick up Powertop’s sleeve.
Shift to the tunables tab, and mark every ‘bad’ tunable to ‘good’ unless you have a problem with anyone of those. I’ve never hard one, but then everyone uses their laptop differently. Once you’ve done this, you should finally see your graphics card at 0% in the Device Stats, unless you’re using it.
I often like to open powertop and see the battery discharge rate in Watts. Try doing it a few times to see how your usage affects the consumption.
Concluding this section, you can use
sudo powertop --auto-tune to make all the tunables to good. I made a small systemd service to run this command at every boot by enabling it.
These tips are just a drop in the ocean, there is a plethora of information on the Arch Wiki about power management. But anyhow, with these 2 tricks (and a userspace CPU governor), I now get about 3.5 hours of battery reading PDFs etc (when I don’t open new webpages on my Browser, that is). Good enough for Library visits during Exam days :)
Feel free to comment whether these tips improved your laptop’s battery backup or not.