In August 2015 my late-2011 MBP 17" had problems with a randomly-failing video signal to the 27" Thunderbolt display. (That immediately rules out all the solutions in this thread suggesting new HDMI or DVI cables). My MBP's extended warranty had run out, but the Apple Store said it was a well-known defect in my model of MBP and earlier, for which there was a recall notice to repair all MBP's, even those out of warranty. This is the "MacBook Pro Repair Extension Program for Video Issues" program, https://www.apple.com/support/macbookpro-videoissues/
I got my MBP back from the store, Apple said they replaced a logic board to fix it. Back at my office, the external video didn't work on the Thunderbolt display. Not just randomly. Absolutely nothing. Everything else on the Thunderbolt (webcam, microphone, attached USB devices) worked perfectly when connected to my MBP. My Thunderbolt showed a picture when connected to a co-worker's MBP. I tried the co-worker's Thunderbolt on my MBP and that didn't work. I tried all the solutions mentioned in this thread without success. I spent hours on several occasions talking to Apple support. They even talked me into recovering my hard drive from an ancient backup because the video driver was no longer compatible with the new logic board, but there was no other way to remove it from my system. Even tried switching back to the onboard Intel chipset as recommended by gfxCardStatus.
The external video had gone from failing randomly to not working at all while in their possession. I returned my MBP to the Apple store, explained how my external display no longer worked since their video repair. I was sick of explaining it over-and-over to someone else. They reproduced the problem in-store. Clearly it was my MBP. They shipped it away for repairs, then Apple called me back after a week and said my 4-year old laptop would cost me $1100 to fix because it was no longer in warranty. Whatever they did to "repair" it left it broken, or even worse than it was, and now they wanted me to pay for them to fix their FUBAR.
I elevated this to some senior guru (their words not mine) at Apple who said he never gets to talk to the customers. He was really nice, he agreed with my diagnosis and said he would follow up with their repair guys. The repair guys came back and said my logic board had severe corrosion on it, so it was my fault for spilling liquid on it. The guru agreed with me that a logic board installed for a week could not be corroded, EVEN IF I DID SPILL LIQUID ON IT. He said he would "advocate" for a free repair. Then he promptly went on vacation without telling me and all of a sudden my MBP has been returned to the store NOT FIXED. Upon his return he flaked out on me and stopped returning my calls and emails. That was the last I heard from Apple.
Eight months later, my MBP still works well, except for the video problem. Apple screwed me. I've had better experiences with used-car dealers.