Alternative to nvidia-settings GpuPowerMizerMode in Ubuntu?

According to this comment, you need to have a dummy X server running. Here is how I've been able to accomplish this in Ubuntu 20.04.

  1. Install the necessary packages:
sudo apt install xorg
  1. Run nvidia-xconfig:
sudo nvidia-xconfig -a
  1. Edit /etc/X11/Xwrapper.config and add:
allowed_users=anybody
  1. Start the X server:
startx
  1. In another terminal, run nvidia-settings:
DISPLAY=:0.0 nvidia-settings -a "[gpu:0]/GpuPowerMizerMode=1"

It happily replies with:

Attribute 'GPUPowerMizerMode' (orion:0[gpu:0]) assigned value 1.

Now the Performance State of my GPU stays at P2.


this is how i solved it on my machines (headless servers, using SSH);

make sure tmux is installed, or use SCREEN

tmux new-session -s [your new session's name here]

sudo ls 

sudo X :0 &

export DISPLAY=:0

nvidia-settings -a [whatever commands you want to use]
nvidia-settings -a [whatever commands you want to use]
nvidia-settings -a [whatever commands you want to use]