NVidia come with a feature called PowerMizer that dynamically underclocks the GPU when it's not being used much. This is great for battery power but horrible for performance when using Effects (compiz). Unfortunately, NVidia does not provide a way to configure PowerMizer on Linux however, it's not difficult to create a script that will give you maximum speed while on AC power and maximum power savings while on battery.
This HOWTO is aimed primarily at users of NVidia 8 and 9 series laptop graphics cards (though, it may be useful for 7 series users as well). This HOWTO assumes you are running compiz and have already properly configured the NVidia proprietary . If you are not using compiz, this guide will not be useful for you.
The first thing we will need is a utility called nvidia-settings. If you've installed the NVidia drivers directly from the NVidia website or using envyng, you can skip this step
sudo apt-get install nvidia-settings
The nvidia-settings has a unique property that, with essentially no CPU/GPU activity, when you ask the card to print all of its information, it causes the card to go to maximum power. The nvidia card only drops a power level every 30 seconds so, we are going to take advantage these two facts to keep the card at maximum power if we are on AC power.
If you have no custom scripts, follow these instructions first
mkdir -p ~/bin
Then, open up gedit and paste the following script
while true; do
if on_ac_power; then
nice /usr/bin/nvidia-settings -q all > /dev/null
Save the script as ~/bin/nvidia-power.sh. Then, start a terminal and type the following:
chmod +x ~/bin/nvidia-power.sh
If you are on AC power, the card should now be locked at its maximum power but, if you are on battery power, you should see no difference at all (until you next plug your laptop in).
Next, we will need to add this script to run when you login. On gnome, go to System->Preferences->Sessions, click Add. Add a descriptive name for the startup program (maybe, "NVidia Power") and for Command use, "/home/your_username/bin/nvidia-power.sh" (replace your_username with your username). Now the command should run whenever you login.
is fairly straightforward. Start a terminal and type:
Scroll down to the bottom of the window this command brings up and look on the left side for the PowerMizer option. If your laptop is plugged in, you should see that your is running at full power. Watch it for a minute (the time it takes for the card to normally drop to lowest power) and make sure it stays at the highest power level. Now, unplug your laptop and wait for another minute. After less than a minute, your card should drop down to minimum power (as long as you keep it idle). Now, plug the cable back in and, in less than 30 seconds, the card should come back to full power and stay there.
The one caveat of this approach is that it can take up to 25 seconds for the card to come back up to full power. There are more complex ways to make the card instantly go to full power when plugged in but, on average, it will be at full power within 12 seconds so, it's probably more hassle than it's worth to use more complex methods.
Source from here