Cannot run nvidia-settings

I'm up to setting up some mining rigs running Ubuntu. I use Nvidia GTX 970 and GTX 780 GPUs. I installed the 16.04 LTS server distro and it's working fine. I can tweak some GPU params using nvidia-smi. However, over- and underclocking can only be done with nvidia-settings utility which I have trouble running. The error msg is this:

Failed to connect to Mir: Failed to connect to server socket: No such file or directory. Unable to init server: Could not connect: Connection refused.

ERROR: The control display is undefined; please run nvidia-settings --help for usage information.

I looked thru internet a lot. Nvidia-settings needs graphic interface, so I installed Xorg, Ubuntu Desktop and everything I could find on the subject. The computer boots into graphic desktop now, however, nothing really happens after a login, the screen is pretty empty, no icon or anything. Nvidia-settings still not working.

I am accessing the computer via SSH, I created the xorg.conf file, I am using custom edid files to emulate monitors. I've also set coolbits to 31.

Maybe I should just install the full graphic version now, I am sort of clueless what to do next.


Solution 1:

After installing nvidia drivers and Xorg, generate a suitable xorg.conf for a headless server :

sudo nvidia-xconfig -a --cool-bits=31 --allow-empty-initial-configuration

Then, as mentioned here on linuxquestions.org, try :

sudo DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/:0 nvidia-settings -t -q GPUUtilization