Ubuntu restarts randomly
Solution 1:
You are going to want to check the logs to see if you can figure out what is happening.
Log files are stored in /var/log
The first log I would look in would be kern.log.
Also, I don't want to discourage you from asking here, but you would probably get a better answer asking on the ubuntu forums.
Solution 2:
While you problem sound like hardware (check cables and connectors!) I have another wild guess: Screen saver.
Ubuntu ships 3D screensavers, and sometimes they can youse problems with the GFX card in 3D mode. Try to set the screen saver to "blank screen".