BTD
May 27, 2024, 8:53am
1
Hello i have a script for setting nvidia gpu power limits and clocks
#!/bin/bash
#Enable persistence mode
sudo nvidia-smi -pm ENABLED
#Set power limit to 140Watts
sudo nvidia-smi -pl 140
#Set clocks
sudo nvidia-smi -lgc 240,1807
#Set target temp to 73c
sudo nvidia-smi -gtt 73
I was wondering if i could make this script autorun and not prompt me for a password on launch
Thanks!
xircon
May 27, 2024, 10:02am
2
Create a systemd service. There are loads of tutorials out there.
BTD
May 27, 2024, 10:50am
3
If you could link me a good one that would be great but its fine if you cant thanks!
pebcak
May 27, 2024, 11:03am
4
Asking my friend:
Could you please generate a list of tutorials for how to make a systemd service?
Sure! Here is a list of tutorials that explain how to create a systemd service:
For more: https://wiki.archlinux.org/title/Systemd#
Please make some research on your own and if anything is unclear ask the forum.
Good luck!
2 Likes
pebcak:
Asking my friend
Yikes, that did not turn out so well–all of those links are 404, except the last one which is not related to making a systemd service at all.
Here are some articles related to creating a systemd service which have not been hallucinated by a chat bot:
While writing web applications, I often need to offload compute-heavy tasks to an asynchronous worker script, schedule tasks for later, or…
Reading time: 3 min read
An example of creating a service for running your script would be like this:
Create a service file with an editor, for example Nano:
sudo nano /etc/systemd/system/gpu-settings.service
Set up a service which will run your script for you. I have not tested this but perhaps it will be a good starting point:
[Unit]
Description=NVIDIA GPU Settings
Wants=graphical.target
After=graphical.target
[Service]
Type=oneshot
ExecStart=/path/to/your/script.sh
[Install]
WantedBy=graphical.target
Systemd sometimes has problems with files stored in the user’s home directory, so if needed you should move your script somewhere else like /usr/local/bin
.
Start and enable the service:
sudo systemctl enable --now gpu-settings.service
Then reboot and see if it works. If not, you can try changing the dependency directives or the target, or examine the journal to see why it is failing (systemctl status gpu-settings.service
).
5 Likes
Seems I asked the wrong friend
1 Like
BTD
May 28, 2024, 8:33am
8
Throws up this error when i try to execute from home directory or /usr/local/bin
gpu-settings.service: Failed to execute /usr/local/bin/nvidia-settings.service: Failed to execute /usr/local/bin/nvidia-pl.sh: Exec format error
BTD
May 28, 2024, 8:37am
9
Nevermind was able to solve it by changing line: 8 from
ExecStart=/usr/local/bin/nvidia-pl.sh
To
ExecStart=/bin/bash /usr/local/bin/nvidia-pl.sh
1 Like
system
Closed
May 30, 2024, 8:38am
10
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.