What is the recommended way to have the nvidia persistence daemon run at log in?
At the moment I have a systemd unit file that does this and doesn’t actually enable persistence [see below]
but the idea of the daemon is that it runs in user space right? so should I instead simply launch it with a line in .bashrc ? or is there some way to not require me to type the sudo password again on logging in?
sudo nvidia-persistenced --user $USER
Description=NVIDIA Persistence Daemon
ExecStopPost=/bin/rm -rf /var/run/nvidia-persistenced
$ ps -aux | grep nvidia
root 268 0.0 0.0 0 0 ? S 09:30 0:00 [nvidia-modeset]
root 1210 0.0 0.0 17144 1592 ? Ss 09:30 0:00 /usr/bin/nvidia-persistenced --user root --no-persistence-mode --verbose
root 1473 0.5 0.0 0 0 ? S 09:30 1:07 [irq/156-nvidia]
root 1474 0.0 0.0 0 0 ? S 09:30 0:00 [nvidia]
luke 29162 0.0 0.0 14524 948 pts/2 S+ 12:55 0:00 grep --color=auto nvidia
according to the documentation:
“it will typically require some sort of manual installation into the init system.”
The exact method to install a new script into the init system is distro-specific. You can google how to do it for your specific distro.
Regarding this statement:
"but the idea of the daemon is that it runs in user space right? "
Note the documentation:
“After doing a minimal amount of setup tasks that require super-user privileges, the daemon will drop super-user privileges and run as user ‘foo’.”
Thanks for quick reply. I neglected to explicitly mention that I am using systemd (Ubuntu 16.04). I have read that page and Googled for my distro which is what led to my current setup - one solution I read was to install nvidia-persistend package through apt - this didn’t work and stopped nvidia-smi from working so I removed it. Another solution was what I wrote above. As can be seen above, this gives me “/usr/bin/nvidia-persistenced --user root --no-persistence-mode --verbose” running as root, not as $USER. Is there some straight-forward way that you know of for Ubuntu 16.04?
In case somebody else wants to be able to automatically enable persistence mode on boot and cap GPU power. I found the following worked on Ubuntu 16.04 server with 2080Ti- (will probably work on other systemd linuxes and I guess with most recent GPUs)
sudo mkdir -p /usr/lib/systemd/system
Description=set persistence mode and cap power usage of GPU
ExecStart=/bin/sh -c "sudo nvidia-smi -pm 1 && sudo nvidia-smi -pl 249"
WantedBy=multi-user.target' | sudo tee --append /usr/lib/systemd/system/nvidia-powerlimit.service > /dev/null
sudo systemctl enable nvidia-powerlimit
a simple way to achieve this would be adding the line
nvidia-smi -pm 1
to the file /etc/rc.local, so it gets executed at system startup