Ubuntu 12.04 + Nvidia - Heavy CPU usage


Updated: May 23, 2012

All right, the symptoms you're suffering from are the following: You've recently installed Ubuntu 12.04 Precise Pangolin and the proprietary Nvidia drivers for your card from the official repositories. Since, you've noticed sluggish behavior, slow windows switching response, high spikes of CPU when doing even basic things, CPU going up to 50% when opening the Dash, and other things that sour your mood.

Worry not. Dedoimedo will solve all your woes. Just as I solved your initrd issues, your Nvidia activation thingie in Natty, your Realtek problems in Kubuntu, we're gonna tackle this one with simplicity and elegance. So please follow me and enjoy another lesson in statistical engineering applied to resolving home problems.

Problem

How do you know you have a problem? That's the first one. The best thing is to compare your current experience with previous incarnations of Ubuntu, say like the previous LTS release. But what if you've never used Ubuntu till now, how will you know? Well, the simple answer is, with any decent graphics card, Xorg and compiz processes, which contribute to all the lovely graphics you see, should not be tolling too many CPU cycles. Without too many things happening on the screen, the expected figures should be around 2-3% or so. Anything above 10% is probably worrying. And there's the simple matter of heat radiating off the card and the CPU fan going about madly whirring.

CPU usage

Resolution

Now that we know we could be facing a problem, what do we do?

Nvidia drivers

For most people, the simplest solution would be to try a different version of the driver to see whether this resolves the problem. Upon installation, Ubuntu will automatically configure the latest available version for you, which is 295.40 at the moment this article was being written. As it happens, there are quite a few problems with this driver, causing power and performance regressions for many users. Unfortunately, the installer will land you with just that.

Nvidia driver

What you can do, though, is try to install the later, less tested post-release update, a version of the same driver released after the repository was locked down for changes. The new driver might help resolve the problem.

Post-release update

So you should try this and see if it helps.

Nvidia driver tweaks

There's another way, maybe even simpler, especially since you do not need to even re-login, let alone reboot to test the changes. A single checkmark in the Nvidia driver settings might do the trick for you. Better yet, in combination with the driver update, you might get the expected, smooth and slick performance once again.

Specifically, what you may want to do is: Open the Nvidia X Server Settings panel. Click on the X Server XVideo Settings option on the left. Then, in the right pane, uncheck the box that reads Sync to VBlank.

Sync option

This settings also shows in the OpenGL settings. You may also want to consider disabling that one, too. Now, before you do that, ask yourselves, what is this option and how it affects my desktop usability?

The simple answer is, on non-CRT monitors, you will probably not notice anything. In the worst case, the frames-per-second rate of certain applications and games might go unrestricted if you disable the option rather than being calibrated to the refresh rate of your monitor. You can test and see whether it makes a difference. As to what the option actually does, it forces processes to wait until the screen is idle before updating the information, so that no tearing between old and new frames occurs.

Results

My testing shows the most significant effects were achieved with the Sync to VBlank tweak, with a significant reduction in CPU usage and the subsequent improvement in responsiveness.

Normal CPU usage

I've also noticed that the post-release update driver installation reduces the memory usage of the driver somewhat, leading to a total of about 500MB down from 550MB, not to mention a horrendous 800MB with the Nouveau driver. Combined, the two changes restore the expected behavior from the system.

Conclusion

My recommendations to Ubuntu + Nvidia users are as follows - if you can, wait a little longer until you install or update, let the problems be resolved on the driver level. If you are already using the new version, then you should install the post-release update version of the 295.40 driver and test the Sync to VBlank option set to off.

I hope this article was useful to you - not too technical, not much mucking about in the command line, so it's good. You've learned a bit more about how to approach and diagnose problems, observe unusual behavior, test driver changes and settings. There's no golden rule, but hopefully, this short tutorial will put you on the right track.

Cheers.

RSS Feed icon

del.icio.us del.icio.us stumbleupon stumble digg digg reddit reddit slashdot slashdot



Advertise!

Would you like to advertise your product/site on Dedoimedo?

Read more

Donate to Dedoimedo!

Do you want to
help me take early retirement? How about donating
some dinero to
Dedoimedo?

Read more

Donate