Stuck in P-State P0 after transcode finished on NVIDIA

Hi,
for me, plex is also waking up my GPU when I run a direct stream.
So the script kills the plex process also when there is a direct stream running, resulting in a not so nice experience if you run it every other minute.

1 Like

For me, gpu doesnt change from P8 nor on directplay or directstream.
Not even when transcoding MKV to MP4 for the browser player.

+1 the same for me. Does not help and kills Plex in derect stream as well.

If you read a little further up this thread, there is already a semi-working script from ComasSky1, which with my modifications turns it into a fully functional one that can be happily placed in a cron-job running say hourly to check if transcodes are happening and if not, restarting plexmediaserver gracefully which frees up the handle on the GPU that seemingly causes it to stick in P0 mode. Please note, this will not check to first see if anything else which ISN’T being GPU-transcoded is being streamed - I presume a direct stream would fall into this category, and a restart of the Plex server will likely interrupt this…

Here’s the script again anyway with my small modification (credit to ComasSky1).

#!/bin/bash
TOKILL=""
CPT_TRANSCODE=-1
CPT_SERVER=-1

for ELEMENT in $(lsof /dev/nvidia0 | awk '{print $1 "@" $2}')
do
 IFS='@' read -r -a array <<< "$ELEMENT"
 if [ "${array[0]}" != "Xorg" ] && [ "${array[0]}" != "ffmpeg" ]
 then
  if [ "${array[0]}" = "Plex\x20T" ]
  then
  ((CPT_TRANSCODE++))
  fi
  if [ "${array[0]}" = "Plex\x20M" ]
  then
   ((CPT_SERVER++))
   TOKILL="${array[1]}"
  fi
 fi
done

if [ $CPT_SERVER -gt 0 ] && [ $CPT_TRANSCODE -lt 1 ] && [ "$1" != "test" ]
then
 kill -9 "$TOKILL" ;service plexmediaserver restart
fi
if [ "$1" == "test" ]
then
 echo "$TOKILL"
fi

If your system uses systemd, and to avoid a 90-sec wait for timeout at the stop phase of the service restart, you may like to tweak your DefaultTimeoutStopSec value in /etc/systemd/system.conf followed by a sudo systemctl daemon-reexec.

I’ve got this exact issue with a Quatro P400 and Unraid 6.8.2 running the nvidia build and plex 1.18.7.2457, it just doesn’t want to come down from P0, GPU-Util is 0% but it’s parked in P0 and the fan at 40%. Curiously this doesn’t seem to be a problem when I test transcoding with Jellyfin so maybe a fix is soon?

Any update on this issue? Its happening on my 1060 also. Using unraid, that script running each minutes helps a bit, but…

Nothing yet. We are in discussions with Nvidia regarding this issue.

1 Like

One year has passed without any solution…
Which ffmpeg are you currently using for plex?
I’ve read somewhere that it can be related and using an upstream version solves the issue.

Crazy that this is still a problem. Makes me wonder, here they are forcing all of these new features that no one wants (Plex Movies & TV) and we can’t even properly use hardware acceleration on Linux.

This issue has no bearing on whether or not Linux hw transcoding works.

Mine works perfectly fine other than the power state.

Yes, my apologies. The transcoder not functioning properly was my mistake. I wrapped the Transcoder script in a wrapper to enable NVDEC but it seams that its natively supported now?

Although I am in the p_state 0 boat along with everyone else in this thread using double the power I should be.

Jellyfin doesn’t have this problem. Can you guys take a look at their code to see what the problem is with Plex?

We already know what the issue is, and Nvidia have been able to reproduce the issue. They mentioned they were not able to reproduce it with some internal drivers that are in testing. So we suspect this will be resolved with updated drivers in due corse. Once we know more we will share :slight_smile:

6 Likes

This is great news!

There are ways to check whether Plex is actively playing a movie, whether transcoded or direct. Take a look at the ā€œrunningā€ code snippet (starting on line 180) from the plexupdate tool located here:

It seems to me that you could combine the script previously posted with some logic similar to what the plexupdate tool is doing in order to have it handle more scenarios. You could even put in something to monitor playback, record the last timestamp something was playing, and not restart the plexmediaserver process unless it has been at least x minutes since something was played. That would help to prevent a restart if someone is not actively playing any media but still browsing the libraries. I’d also be curious about background transcodes for sync and background media scanning and thumbnail creation processes because you wouldn’t want to restart if those were running either.

1 Like

any news on this issue?

Another instance here, and I suspect from reading around it’s very very widespread in these cases, you aren’t going to spot it unless you are specifically looking.

I’m using unRAID and the linuxserver Plex docker with a 1660 super and the moment Plex touches the GPU it gets stuck in p0 with higher idle power consumption (25-33w).

Mind you, the other ā€˜oddity’ is even in p8 idle (which it is in when it first boots) the idle draw is ~11w… My Titan Xp in my gaming PC with an Ultrawide 3840x1600 and a second display (1024*600) just browsing the web etc only draws 10-12w (according to HW Info)…
So either the 1660 Super is far less efficient (considering it’s less performant than a Titan Xp) or the linux driver (440.59) in my case which I’m stuck on is not as advanced as windows for power management.

I am also seeing this issue. I’m glad to hear that Nvidia is approaching a fix from at the driver level. Hopefully we get a fix in the next Driver release.

1 Like

Same issue. I will try one of the posted scripts. My current nvidia driver is 440.82 which was released on 2020.4.7 so I hope we see this ā€œinternal driverā€ they are testing from the Mar 26 post soon…

1 Like

Anyone tried the new 450.36.06 which can be downloaded from the NVIDIA site?
changelog:

https://www.phoronix.com/scan.php?page=news_item&px=NVIDIA-450-Linux-Beta
It says there are some changes regarding power management on Linux.

1 Like