I had a similar issue in the past and it ended up being the power supply was going bad. From what I learned is that random restarts like that happen because not enough power is going to various components causing the CPU to reset, which in turn resets the whole computer. Thankfully power supplies are fairly inexpensive anything above 500W should be more than enough for most set ups.