1

I need a script to run at startup with sudo permissions that changes GPU power limits and KEEPS the GPU power limits set as long the computer is on. The power limits reset to factory defaults after the computer fully boots.

I tried putting the script in /etc as rc.local after seeing this Q and A, and it sets the power limits where I want them but only for about two seconds. If I press esc during the boot process I can see the script setting the GPU power limits but after the computer is fully booted and I open a terminal and type nvidia-smi to look at the power caps they are back to their factory defaults as if my script never ran.

The contents of my script...

#!/bin/sh -e

sudo nvidia-smi -i 0 -pl 250 sudo nvidia-smi -i 1 -pl 289 sudo nvidia-smi -i 2 -pl 244 sudo nvidia-smi -i 3 -pl 260 exit 0

I can manually run this script after startup with a sudo ./script.sh in the commandline and it does what I want to, but I need it to run automatically when I'm not there to type my password. Can nvidia-smi be made to run without the need for sudo?

I also tried running the script in systemd with the accepted answer here, but it didn't work.

Unit]
Description=Spark service

[Service] ExecStart=/path/to/spark/all.sh

[Install] WantedBy=multi-user.target

chmod u+x /path/to/all.sh Start it:

sudo systemctl start myfirst Enable it to run at boot:

sudo systemctl enable myfirst

I'm sure this is also running the script because I put a sleep for 20 seconds in the script and it takes 20 extra seconds to startup, but again, no power limits are changed when the computer has started.

Ant
  • 171

0 Answers0