You are not logged in.

#1 2020-04-06 22:16:27

keening
Member
Registered: 2020-04-06
Posts: 4

Issues with startup script or service, AMDGPU [SOLVED]

I have been successful so far in setting a voltage clock curve for my AMD GPU with the steps written in the AMDGPU wiki but I have had issues keeping it persistent after reboot.
I have written a shell script for it (or appropriated parts from the web) located at /usr/local/bin/:

 #!/bin/sh
echo "vc 2 1800 960" > /sys/class/drm/card0/device/pp_od_clk_voltage
echo "c" > /sys/class/drm/card0/device/pp_od_clk_voltage

What I am trying to do is set the second state of the voltage-clock curve to 1800mhz and 960mv, it works when I run it the terminal as " echo "vc 2 1800 960" > /sys/class/drm/card0/device/pp_od_clk_voltage " or if I run this script by itself without the service via ./Set_GPU_Settings.sh
So the script seems to be fine in this regard as it does it job, however the service does not run it on startup and I am left with the stock values. Occasionally I would get the red failed line on bootup regarding the service I am trying to run and the gpu values remain stock. Note that sometimes there is no failed line at all.
This is the service I have for it to launch on startup for /etc/systemd/system/tunegpu.service:

[Unit]
Description=Change GPU clocks
[Service]
ExecStart=/usr/local/bin/Set_GPU_Settings.sh
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target

Here are some things I have tried in hopes of fixing my issue before posting here:

  • #!/bin/bash instead of #!/bin/sh

  • Using /usr/bin/ instead of /usr/local/bin

  • Running the echo lines with sudo sh -c at the start of each line

  • chmod +x or chmod 755 for the script

  • Script file without .sh at the end

  • systemctl daemon-reload

  • rewritting everything and trying as root user

  • Type=oneshot or User=root in the service file

I tired some other things in between but I've spent the last 2 days on this and I can't for the life of me figure out how to fix it. Basically, I have exhausted my options. I have scoured the wiki and the reddit and tried multiple ways of writing the scripts and the service file but it doesn't seem to work.
Since this script works by itself it leads me to believe the way I've written this service is wrong. Or this it not the way this is done at all.




My GPU is a 5700xt Navi and I am running the 5.5.13 kernel. Don't hesitate to scold me if I forgot to mention some critical information, I will try my best to accommodate you, I am definitely a noob when it comes to this and I try to follow the wiki on everything as much as I can.

Last edited by keening (2020-04-07 00:27:40)

Offline

#2 2020-04-06 22:35:39

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: Issues with startup script or service, AMDGPU [SOLVED]

Did you enable the service?


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2020-04-06 22:47:47

keening
Member
Registered: 2020-04-06
Posts: 4

Re: Issues with startup script or service, AMDGPU [SOLVED]

If you mean with systemctl enable, then yes I have enabled the service. In my case systemctl enable tunegpu.service

Last edited by keening (2020-04-06 22:48:21)

Offline

#4 2020-04-06 23:05:51

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: Issues with startup script or service, AMDGPU [SOLVED]

What does systemctl status tunegpu.service show? And journalctl _PID=XXXX from the previous output?


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2020-04-06 23:26:34

keening
Member
Registered: 2020-04-06
Posts: 4

Re: Issues with startup script or service, AMDGPU [SOLVED]

Thanks for the reply. This is the journalctl from the latest boot in regards with this service.

-- Logs begin at Sun 2020-04-05 18:48:42 UTC, end at Tue 2020-04-07 01:21:26 UTC. --
Apr 07 01:19:18 arch Set_GPU_Settings.sh[524]: /usr/local/bin/Set_GPU_Settings.sh: line 2: /sys/class/drm/card0/device/pp_od_clk_voltage: Permission denied
Apr 07 01:19:18 arch Set_GPU_Settings.sh[524]: /usr/local/bin/Set_GPU_Settings.sh: line 3: /sys/class/drm/card0/device/pp_od_clk_voltage: Permission denied
Apr 07 01:19:18 arch systemd[1]: Started Change GPU clocks.
Apr 07 01:19:18 arch systemd[1]: tunegpu.service: Main process exited, code=exited, status=1/FAILURE
Apr 07 01:19:18 arch systemd[1]: tunegpu.service: Failed with result 'exit-code'.

So it would seem there is an issue with the permissions, however I don't know how to remedy this.
I have tried both chmod 744 for the script and chmod 644 for the service, they are both owned by root aswell.
I should mention aswell that I have a getty@tty1 service on bootup that logs me into my user account, hopefully that doesn't conflict with this one?

Additionally, I did ls -l to double check the ownership of the files, is there anything there that indicates an issue?

-rwxr--r-- 1 root root 137 Apr  7 01:17 /usr/local/bin/Set_GPU_Settings.sh
-rw-r--r-- 1 root root 160 Apr  6 23:46 /etc/systemd/system/tunegpu.service

Last edited by keening (2020-04-06 23:29:20)

Offline

#6 2020-04-06 23:40:58

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,520
Website

Re: Issues with startup script or service, AMDGPU [SOLVED]

The permission issue is for the pp_od_clk_voltage file.  What is the output of `stat /sys/class/drm/card0/device/pp_od_clk_voltage`?  When you run your script manually, do you run it as your user, or as root?

There may be a race condition of creating those pseudo-files at boot time too.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2020-04-06 23:49:15

loqs
Member
Registered: 2014-03-06
Posts: 19,079

Re: Issues with startup script or service, AMDGPU [SOLVED]

As Trilby noted it could be a race so you could try ensuring the amdgpu module is loaded or order it the service later for example after systemd-logind.service

Wants=modprobe@amdgpu.service
After=systemd-logind.service

Offline

#8 2020-04-07 00:27:04

keening
Member
Registered: 2020-04-06
Posts: 4

Re: Issues with startup script or service, AMDGPU [SOLVED]

Thanks to you guys I've managed to fix it. I've done as both of you have suggested so I am unsure which solution was correct or if it was both of them, so far I am just happy that it works, I will try each by itself and update this for future reference if anybody else has this issue and needs help.

The pp_od_clk_voltage file was under root ownership but apparently the root group was only allowed to read the file? I've changed that to both read and write permission for the root group.
I have also added both of the conditions from the above post to my service file.

Been banging my head for these last two days trying to figure it on my own, thanks a bunch guys!

Offline

Board footer

Powered by FluxBB