Thanks for the response everyone, I will remove the graphics card and try to replace it. I don't want to throw this machine away, it's powerful enough to be used as a second computer (I need one anyway), so I think it's worth repairing, if I can manage to repair it myself.
If it has one of the more expensive GPUs, you can look into baking the GPU. People have been baking the GPU with varying success for a while.
A few years ago, my friend found an iMac in a dumpster, and he tried to boot it, and it didn't boot. He gave it to me, and found out it had a bad HDD. I replaced it with a SSD and found out that this dumpster find was a top of the line BTO Mid 2011 iMac with the rare 2GB 6970M GPU. A short time later, the GPU started to show signs of failure. I did the bake method, placing the GPU in the oven @400F for about 10 minutes, and it fixed it.
Baking is considered a temporary fix, but it has worked for years now without issue in my case.
I wouldn't bother if yours had the base model GPU, as it was pretty underpowered.
If you decide to replace the GPU with anything other than the OEM one, check out this thread:
https://forums.macrumors.com/threads/2011-imac-graphics-card-upgrade.1596614/
It is long, but the beginning has really helpful information on current compatibility of non-Apple supplied GPUs.
If you stick with a GPU from the Late 2009 to Mid 2011 iMacs, certain ones have a bigger heatsink. Example, the 6770M has a small heatsink known as the "two pipe", and the 6970M has a large heatsink or "three pipe".
If the iMac is a stock 27" with the 6770M, and you replace it with a 6970M, you have to get the larger heatsink as well.
The same applies to certain non-Apple GPUs as well. The thread gives a lot more info on that.