There's no such thing as a free lunch, as the old saying goes, and that's as true in the renewable energy world as anywhere else. Every means of making energy has its energy cost, from the electricity used to pump oil out of the ground and the diesel that powers coal mining machinery, to the power to charge cordless drills for installing rooftop solar.
The concept is referred to in renewable energy circles as "energy return on energy invested," or EROEI, and it's a crucial measurement of how viable a source of energy is, renewable or not. The higher the EROEI, the more energy is "returned" on the energy you invest to get it, and thus the more efficient the energy source is.
Calculating EROEI is not an exact science. It's straightforward enough to figure out that the power used to operate an oil rig counts toward the oil's EROEI. But do you count the energy it took to build the power plant that powers the oil rig? Some sources count energy invested only if that energy is invested in the US, giving imported petroleum a higher EROEI than oil from domestic wells: we let someone else "pay" the energy costs of getting the stuff out of the ground. Still, it's not hard to get a rough baseline sense of just how much energy we need to put in to an energy source for every megawatt of energy we get out of it.
Fossil fuels tend to have a very high EROEI, and for good reason: they're concentrated sunlight, long chains of carbon built by living things, accumulated over millions of years of geologic time, and stored in a form that's relatively easy to move around. Coal is the best example, with an EROEI of around 80. For every megawatt of energy we use to mine and transport coal, that coal gives us around 80 megawatts of power. Oil and gas had an EROEI of around 30 back in 1970, but as reserves get tapped out and drilling takes place in more and more difficult circumstances, that figure has dropped, to around 15 in 2005.
That's still pretty good compared to most renewable energy sources, which is part of the problem with which we find ourselves confronted. If there was an easily accessible renewable energy source with a high EROEI, we could switch over from burning coal with little effect on our economy or our lifestyle. But most renewable energy sources have EROEIs running less than 7. Photovoltaic costs are dropping and energy investment per unit drops as more are built, but in 2010 PV's EROEI was slightly above 6. Biomass comes in even less efficient: sugarcane ethanol has an EROEI of 5, corn ethanol and biodiesel at 1.3.
Geothermal energy isn't common enough that the experts agree on how to quantify its EROEI, and the math involved is daunting. It looks as though somewhere in the range of 20 isn't too far off. Wind claims an EROEI of around 20 as well.
The true star in the renewable energy field is large hydroelectric, with an EROEI around 100, even better than coal. This makes sense: hydroelectric plants can have very long lifespans and the "fuel" -- water uphill of the turbine ---- is replenished by solar energy whether we have a dam there or not. All that EROEI must account for is construction and maintenance. (Of course large hydro carries a huge list of other ecological costs, but few of those are accounted for in EROEI) As PV cells become more durable and the energy cost of their manufacture drops, their EROEI may well climb toward hydro's.