Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

unRAID Nvidia - Graphics Card Sleep Reset Script

Featured Replies

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?

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.

  • Author
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?

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

  • Author
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! 

  • 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

  • 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

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 !

  • 2 years later...
On 1/29/2021 at 4:12 AM, doobyns said:

- 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

This is clutch! To think that this was all I had to do for all these years. This method resolves any GPU initialization issues with Docker containers utilizing an NVIDIA GPU (GTX 1060) after waking from sleep. What this script command does is free up the GPU before the system goes to sleep.


Lastly, I’ve found that you don’t need to include the shebang in the S3 command fields.

 

@testdasi Thank you for your help. 

 

**Edit**
I forgot to mention, you can enable power savings wherein the GPU will go into a low power state. For the longest time I didn't know that you could do such a thing. You can add the following command to your S3 Sleep plugin under the Wake-up Command field. This way when the GPU isn't being used, it will go into a low power state.

 

nvidia-smi -pm 1

 

Edited by Zer0Nin3r
Added command to enable power savings.

  • 9 months later...

Hi , after server wake up from sleep , none of the containers which usually use gpu are using the gpu , its like the gpu is unavailable to the docker after wake up , looking for a fix 

  • 4 months later...
On 12/20/2020 at 8:24 PM, ph0b0s101 said:

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

Did you find any solution for this , im also facing the exact same issue 

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...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.