unRAID Nvidia - Graphics Card Sleep Reset Script


Recommended Posts

I have what may be a unique situation, but hopefully someone can point me in the right direction.

 

I have a P2000 for use with my Plex Container and a Radeon VII for passthrough to my VMs.

 

I suffer from the bug where the Radeon will get hung up when I close my VMs. I am using the reset script that puts the server into sleep mode and that get the card operating again without having to restart the whole server.

 

However, I've come to find out that after I do that Plex starts using the CPU to transcode instead of the P2000.

 

#!/bin/bash
echo "disconnecting amd graphics"
echo "1" | tee -a /sys/bus/pci/devices/0000\:03\:00.0/remove
echo "disconnecting amd sound counterpart"
echo "1" | tee -a /sys/bus/pci/devices/0000\:03\:00.1/remove
echo "entered suspended state press power button to continue"
echo -n mem > /sys/power/state
echo "reconnecting amd gpu and sound counterpart"
echo "1" | tee -a /sys/bus/pci/rescan
echo "AMD graphics card sucessfully reset"

 

This is the script I use and it only references the hardware id of the Radeon.

 

Any idea how to make sure hardware encoding on the p2000 survives the reset fix for the Radeon?

Link to comment

Try this (here I'm assuming your Plex docker is named "Plex")

#!/bin/bash
docker stop Plex
sleep 5s
echo "disconnecting amd graphics"
echo "1" | tee -a /sys/bus/pci/devices/0000\:03\:00.0/remove
echo "disconnecting amd sound counterpart"
echo "1" | tee -a /sys/bus/pci/devices/0000\:03\:00.1/remove
echo "entered suspended state press power button to continue"
echo -n mem > /sys/power/state
echo "reconnecting amd gpu and sound counterpart"
echo "1" | tee -a /sys/bus/pci/rescan
echo "AMD graphics card sucessfully reset"
docker start Plex

 

What it does is it stops the Plex docker, wait 5s (for it to stop completely) then does whatever it does in your script and once fully back up, it start the Plex docker. That way hopefully the docker isn't "aware" of the standby and hopefully pick up the P2000 right backup.

Obviously if your P2000 itself hasn't woken up from the sleep then it's a different matter.

Link to comment
1 hour ago, testdasi said:

Try this (here I'm assuming your Plex docker is named "Plex")


#!/bin/bash
docker stop Plex
sleep 5s
echo "disconnecting amd graphics"
echo "1" | tee -a /sys/bus/pci/devices/0000\:03\:00.0/remove
echo "disconnecting amd sound counterpart"
echo "1" | tee -a /sys/bus/pci/devices/0000\:03\:00.1/remove
echo "entered suspended state press power button to continue"
echo -n mem > /sys/power/state
echo "reconnecting amd gpu and sound counterpart"
echo "1" | tee -a /sys/bus/pci/rescan
echo "AMD graphics card sucessfully reset"
docker start Plex

 

What it does is it stops the Plex docker, wait 5s (for it to stop completely) then does whatever it does in your script and once fully back up, it start the Plex docker. That way hopefully the docker isn't "aware" of the standby and hopefully pick up the P2000 right backup.

Obviously if your P2000 itself hasn't woken up from the sleep then it's a different matter.

Thank you for that. Do you think I should have it  sleep the P2000 as well as part of the script?

Link to comment
11 hours ago, veritas2884 said:

Thank you for that. Do you think I should have it  sleep the P2000 as well as part of the script?

It depends. Try to keep the script simple first.

AFAIK the P2000 doesn't have reset issues but then I don't think there are many people sending server to sleep like yours.

Edited by testdasi
Link to comment
3 hours ago, testdasi said:

It depends. Try to keep the script simple first.

AFAIK the P2000 doesn't have reset issues but then I don't think there are many people sending server to sleep like yours.

Got it. Again, thank you very much. This is the second time this week you've come through with an awesome solution for me. Much Appreciated! 

Link to comment
  • 9 months later...

Hello,

 

I am facing the same issue like you with your p2000 but instead with an nvidia 1050TI. I am running Unraid 6.9 Beta 35 with the nvidia-driver plugin to passthrough the gpu to the plex docker for hw transcoding. The HW transcoding is working properly after every reboot, but my server is not running the whole time and goes to sleep after a thershold configured in the dynamics s3 sleep plugin. After the resume, the hw transcoding isn't functional. So I tried to stop and start the plex docker after resume but this will not hlep in my case. So is this solution still valid for you or did you found a other way since your last post? Would be nice to get some feedback. Cheers

Link to comment
  • 1 month later...

I had the same issue, thanks for the advice, i've just shorten the script a bit, i'm using official plex docker image, my

Custom commands after wake-up are theses :

#!/bin/bash 
docker stop Plex-Media-Server 
sleep 3s 
docker start Plex-Media-Server


And it works very well with my Nvidia Quadro P2200 on Unraid 6.9.0-rc2

Edited by doobyns
Link to comment

After some tests i've found a better and fastest option for resume plex docker with hardware media transcoding enabled after S3 sleep (for nvidia users) :

 

- first in Custom commands before sleep :

#!/bin/bash
docker stop Plex-Media-Server

 

- then in Custom commands after wake-up :

#!/bin/bash
docker start Plex-Media-Server

 

now plex server is immediately effective after resume and when you go into S3 Sleep your plex server is stopped correctly !

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.