Based on the information you have provided, anything obvious with the components you use to build your computer. is that it takes a period of time for this to happen. If it was an overheating problem, it should happen within a few minutes after you turn it on. In some cases, the graphics processor can overheat and cause the system to shut down. But this is usually a very rare occurrence.
A more likely scenario is the power supply is starting to fail. Still, before you buy a new power supply, you need to check out some other possibilities.
Do you have any other RAM, you can use? It is just possible that one RAM stick, or even both,. But that is even more rare, almost unheard of.
Once in a while a component like a hard drive or a DVD-ROM drive can develop symptoms like that. They draw excessive current and force the power supply to shut down. But that is going to be hard to diagnose because, as you said, it takes several hours for the computer to shut down. The failure of a hard drive or DVD drive could cause the computer to fail right away. Once they warm up.
So it would seem the power supply is the most likely cause.
If you have a motherboard with a built-in you could try removing your video card and use just the internal video and see what happens.
That's the best I can do.