Xorg randomly hangs with both nvidia and nouveau drivers

Lately Xorg randomly hangs with both nouveau and nvidia drivers. I tried updating to a mainline kernel but nvidia dkms fails when installing a mainline kernel. Any help please? I'm using ubuntu 20.04