That is a problem with the graphics card. These cards have fairly poorly manufactured heat management; instead of thermal paste to heat-couple the GPU to heat sink, they use a padding material. The pads are much easier in a scaled production environment but they dry out over time causing your GPU to over heat. An addition problem you may have with this card is that some solder contacts are eroding, causing the GPU to fail.
Apple replaced these cards for free for quite a while after the warrantee. They replace them now for about 450 (us dollar). First time it happened to my 2011 imac was 3 years ago and they replaced for free, had the unit back in 3 days. Very nice. But since then it failed again and so did my wife’s and son’s (all same machines).
The good news is you can restore these cards to work normally again. The bad news; it is a bit of work. I have restored all our Macs and a few in our neighborhood (word got out)
You need to remove the card, and remove all padding. The card needs to be baked at 200 deg C for 8 minutes. Use thermal paste (messy stuff) to form contact with heatsink. When you do this, be sure to clean the GPU really well, it has a high polish finish (black) you need to see before putting on new thermal paste.
First time it took me over a morning to fix the card, now it is about 1.5 hours. It is perhaps a bit scary at first but entirely doable.