Jump to content
linuxserver.io

[Plugin] Linuxserver.io - Unraid Nvidia

1464 posts in this topic Last Reply

Recommended Posts

Posted (edited)
13 minutes ago, phasetwo said:

Thank you for this script and a massive thank you to everybody involved with this project!👏

Worked flawlessly on 6.7.0-rc4 with an NVIDIA Quadro P600.

In case a non-programmer like me will run into the same question I have, here is the exact procedure which worked for me:

  • Copy the script into an editor
  • Modify the "con" value (e.g. "binhex-plexpass")
  • Save as an .sh file
  • Copy to desired folder on Unraid server (if not working on server already)
  • Open terminal from Unraid webgui and enter "bash /path/to/script.sh

No problems.  Two points...

  1. Another user updated on this patch a bit later in this thread.  It auto-sets the con variable for you, and only runs if it hasn't done already.  I'll update mine shortly with that
  2. Forgot to mention that it's best to run it using the User Scripts plugin - you can copy and paste it straight into the plugin and run it there.  It's then saved for running in the future.

 

Edit: @JasonM beat me to it.

Edited by Cessquill
realised somebody had already replied

Share this post


Link to post
34 minutes ago, JasonM said:

One can also install the CA User Scripts plugin and do this from the web UI, and even set a scheduled run to keep it patched in the event of Plex container updates.

 

26 minutes ago, Cessquill said:

No problems.  Two points...

  1. Another user updated on this patch a bit later in this thread.  It auto-sets the con variable for you, and only runs if it hasn't done already.  I'll update mine shortly with that
  2. Forgot to mention that it's best to run it using the User Scripts plugin - you can copy and paste it straight into the plugin and run it there.  It's then saved for running in the future.

 

Edit: @JasonM beat me to it.

Thank you both for these inputs. I will install CA User Scripts. Can the script be run regularly without any undesired effects, or should it only be run after an update of the Plex container?

Share this post


Link to post
8 minutes ago, phasetwo said:

 

Thank you both for these inputs. I will install CA User Scripts. Can the script be run regularly without any undesired effects, or should it only be run after an update of the Plex container?

As long as you use the current script version as Cessquill indicated, it will check to see if the patch is applied each time it's run. I have mine set to run nightly, after my backup and Docker containers update.

Share this post


Link to post
11 minutes ago, phasetwo said:

 

Thank you both for these inputs. I will install CA User Scripts. Can the script be run regularly without any undesired effects, or should it only be run after an update of the Plex container?

Run this version in User Scripts...

 

 

Share this post


Link to post

Thank you. 

 

Everything works great on either the linuxserver or limetech plex except the script for hardward decode, that only worked on linuxserver.

 

This in combo with my new upgraded internet connection makes me very happy.

 

Using on an MSI GAMING GeForce GTX 1060 6GB GDRR5 192-bit

 

Reposting the correct code for the script:

#!/bin/bash

#This should always return the name of the docker container running plex - assuming a single plex docker on the system.
con="`docker ps --format "{{.Names}}" | grep -i plex`"

echo ""
echo "<b>Applying hardware decode patch...</b>"
echo "<hr>"

#Check to see if Plex Transcoder2 Exists first.
exists=`docker exec -i $con stat "/usr/lib/plexmediaserver/Plex Transcoder2" >/dev/null 2>&1; echo $?`

if [ $exists -eq 1 ]; then # If it doesn't, we run the clause below
	docker exec -i $con mv "/usr/lib/plexmediaserver/Plex Transcoder" "/usr/lib/plexmediaserver/Plex Transcoder2"
	docker exec -i $con /bin/sh -c 'printf "#!/bin/sh\nexec /usr/lib/plexmediaserver/Plex\ Transcoder2 -hwaccel nvdec "\""\$@"\""" > "/usr/lib/plexmediaserver/Plex Transcoder";'
	docker exec -i $con chmod +x "/usr/lib/plexmediaserver/Plex Transcoder"
	docker exec -i $con chmod +x "/usr/lib/plexmediaserver/Plex Transcoder2"
	docker restart $con
	echo ""
	echo '<font color="green"><b>Done!</b></font>' #Green means go!
else
	echo ""
	echo '<font color="red"><b>Patch already applied or invalid container!</b></font>' #Red means stop!
fi

 

Share this post


Link to post
36 minutes ago, JasonM said:

As long as you use the current script version as Cessquill indicated, it will check to see if the patch is applied each time it's run. I have mine set to run nightly, after my backup and Docker containers update.

 

34 minutes ago, Cessquill said:

Run this version in User Scripts...

 

 

Thanks! The script by Xaero works great with the User Scripts plugin.

Share this post


Link to post

Unraid + Plex + Nvidia GPU HW Transcoding + AVI files: 

 

Has anyone experienced issues with running older .avi files (e.g older shows where mkv not available)  I ask because for me those files refuse to play in Plex. Upon disabling HW, they play just fine.

 

I understand avi's are problematic and possibly unsupported by HW transcoding, but was hopeful that in such cases those files would just automaticallly fall back on the cpu to transcode. This appears to not be the behavior, as it just fails to play.

 

I've presently disabled HW transcoding , but wold like to switch back once i can resolve this problem.

 

If anyone has experienced this (or can quickly test), i'd be forever grateful. Thanks!

Share this post


Link to post

Need some quick guidance to make sure I've got this done correctly for Unraid 6.6.7 Stable with a P2000.

 

  • install Plex by linuxerver.io
  • Install nVidia by linuxserver.io
    • open the plugin's page and select from the left dropdown what.... says nvidia 6.6.6 or 6.7.0rc1-4 ... do I select 6.6.6? or have to update my build to an rc version?

Share this post


Link to post
2 minutes ago, mkyb14 said:

Need some quick guidance to make sure I've got this done correctly for Unraid 6.6.7 Stable with a P2000.

 

  • install Plex by linuxerver.io
  • Install nVidia by linuxserver.io
    • open the plugin's page and select from the left dropdown what.... says nvidia 6.6.6 or 6.7.0rc1-4 ... do I select 6.6.6? or have to update my build to an rc version?

Facing the same situation, I chose to upgrade to a RC version. No regrets so far bu I understand if you are reluctant. 

Share this post


Link to post
30 minutes ago, phasetwo said:

Facing the same situation, I chose to upgrade to a RC version. No regrets so far bu I understand if you are reluctant. 

yes, just want someone who's installed it to verify what my next step should be.  Stay on 6.6.7 and choose what nvidia drivers from the list?  or do I need to upgrade to an rc version.

Share this post


Link to post
38 minutes ago, mkyb14 said:

open the plugin's page and select from the left dropdown what.... says nvidia 6.6.6 or 6.7.0rc1-4

It's a dropdown because it's a choice you can make.

 

The plugin actually installs a customized version of Unraid, whichever version you choose from the dropdown. It is simply the Unraid version you choose with support for NVidia added to it.

Share this post


Link to post
Just now, trurl said:

It's a dropdown because it's a choice you can make.

 

The plugin actually installs a custom version of Unraid, whichever version you choose from the dropdown.

ok that makes sense.  so it's not loading them on the side, it's a complete change to unraid itself with underlying drivers for nvidia. 

Share this post


Link to post
Just now, mkyb14 said:

ok that makes sense.  so it's not loading them on the side, it's a complete change to unraid itself with underlying drivers for nvidia. 

yes

Share this post


Link to post
4 hours ago, JasonM said:

As long as you use the current script version as Cessquill indicated, it will check to see if the patch is applied each time it's run. I have mine set to run nightly, after my backup and Docker containers update.

 

Do you call it from within the CA Backup Restore Settings (Path to custom start script) or in User Script?  if in UserScript, how to know the backup is completed before running it ?

Share this post


Link to post
4 hours ago, trurl said:

yes

Followed the directions, worked like a charm after reboot and plex gui updates.

 

Last question, I have a VM that is for BlueIris, and I'd like to take advantage of the HW GPU for endcoding since I do not have a intel quick assist CPU.  With this installed, am I able to pass this through to a windows 10 VM at the same time?

Share this post


Link to post
4 hours ago, trurl said:

yes

Followed the directions, worked like a charm after reboot and plex gui updates.

 

Last question, I have a VM that is for BlueIris, and I'd like to take advantage of the HW GPU for endcoding since I do not have a intel quick assist CPU.  With this installed, am I able to pass this through to a windows 10 VM at the same time?

Share this post


Link to post
6 hours ago, pimogo said:

Unraid + Plex + Nvidia GPU HW Transcoding + AVI files: 

 

Has anyone experienced issues with running older .avi files (e.g older shows where mkv not available)  I ask because for me those files refuse to play in Plex. Upon disabling HW, they play just fine.

 

I understand avi's are problematic and possibly unsupported by HW transcoding, but was hopeful that in such cases those files would just automaticallly fall back on the cpu to transcode. This appears to not be the behavior, as it just fails to play.

 

I've presently disabled HW transcoding , but wold like to switch back once i can resolve this problem.

 

If anyone has experienced this (or can quickly test), i'd be forever grateful. Thanks!

Has anyone replicated this? I have a ton of .avi files and I'm looking to use this Nvidia plugin in the near future when I do my build. If it's a reproducible problem and not fixable, then I might have to rethink my build.

Share this post


Link to post
Posted (edited)

 

8 hours ago, pimogo said:

Unraid + Plex + Nvidia GPU HW Transcoding + AVI files: 

 

Has anyone experienced issues with running older .avi files (e.g older shows where mkv not available)  I ask because for me those files refuse to play in Plex. Upon disabling HW, they play just fine.

 

I understand avi's are problematic and possibly unsupported by HW transcoding, but was hopeful that in such cases those files would just automaticallly fall back on the cpu to transcode. This appears to not be the behavior, as it just fails to play.

 

I've presently disabled HW transcoding , but wold like to switch back once i can resolve this problem.

 

If anyone has experienced this (or can quickly test), i'd be forever grateful. Thanks!

 

2 hours ago, ramblinreck47 said:

Has anyone replicated this? I have a ton of .avi files and I'm looking to use this Nvidia plugin in the near future when I do my build. If it's a reproducible problem and not fixable, then I might have to rethink my build.

 

This is fixable. Remember the HW decoding they are doing is more of a work around. You need to adjust the script to tell it to not play AVI files with the -hwaccel parameter 

 

#!/bin/bash
marap=$(cut -c 10-14 <<<"$@")
if [ $marap == "mpeg4" ]; then
     exec /usr/lib/plexmediaserver/Plex\ Transcoder2 "$@"
else
     exec /usr/lib/plexmediaserver/Plex\ Transcoder2 -hwaccel nvdec "$@"
fi

 

Edited by halfelite

Share this post


Link to post
Posted (edited)
#!/bin/bash

# This should always return the name of the docker container running plex - assuming a single plex docker on the system.
con="$(docker ps --format "{{.Names}}" | grep -i plex)"

echo -n "<b>Applying hardware decode patch... </b>"

# Check to see if Plex Transcoder2 Exists first.
exists=$(docker exec -i "$con" stat "/usr/lib/plexmediaserver/Plex Transcoder2" >/dev/null 2>&1; echo $?)

if [ "$exists" -eq 1 ]; then 
	# If it doesn't, we run the clause below
	
	# Move the Plex Transcoder to a different location so we can replace it with our wrapper
	docker exec -i "$con" mv "/usr/lib/plexmediaserver/Plex Transcoder" "/usr/lib/plexmediaserver/Plex Transcoder2"
	
	# For Legibility and future updates - if needed, use a heredoc to create the wrapper:
	docker exec -i "$con" /bin/sh -c 'xargs -0 printf > "/usr/lib/plexmediaserver/Plex Transcoder";' <<-'EOF'
		#!/bin/bash
		marap=$(cut -c 10-14 <<<"$@")
		if [ "$marap" == "mpeg4" ]; then
			exec /usr/lib/plexmediaserver/Plex\ Transcoder2 "$@"
		else
			exec /usr/lib/plexmediaserver/Plex\ Transcoder2 -hwaccel nvdec "$@"
		fi
		EOF
	
	# chmod the new wrapper to be executable:
	docker exec -i "$con" chmod +x "/usr/lib/plexmediaserver/Plex Transcoder" 

	echo '<font color="green"><b>Done!</b></font>' # Green means go!
else
	# If we ended up here, the patch didn't even try to run, presumably because the patch was already applied.
	echo '<font color="red"><b>Patch already applied!</b></font>' # Red means stop!
fi

 


Did some re-tooling of the script to make things a bit more sane, again.

The wrapper script is now in a heredoc which allows it to be edited inline normally, rather than having a bunch of awkward escapes and such. Seems to work from my limited testing just now. Also includes the conditional posted above, fwiw.

EDIT:

If someone way more versed in FFMPEG limitations knows what a good list of exclusions from the nvdec parameter would be - we can certainly work that into the script fairly easy. Just store the formats in a string and test the return of grep against that variable, instead of testing specifically for each format.


EDIT2:

I just noticed that the resulting wrapper inside the docker loses the formatting in the heredoc. I'll try and fix that eventually. This has no impact on the script actually doing it's job or not.

EDIT3:

Script above has now been fixed. If copy and paste from here doesn't work from some reason, here's a gist:
https://git.io/fhhe3

I'll be updating at that gist from now on, as well. Makes things easier.

Edited by Xaero

Share this post


Link to post
17 hours ago, Pducharme said:

 

Do you call it from within the CA Backup Restore Settings (Path to custom start script) or in User Script?  if in UserScript, how to know the backup is completed before running it ?

I just use a custom cron schedule in User Scripts to run an hour after the backup runs. My backups don't take nearly that long, so I know the timing is safe and nobody is likely to be watching anything at 4 AM.

Share this post


Link to post
14 hours ago, mkyb14 said:

Followed the directions, worked like a charm after reboot and plex gui updates.

 

Last question, I have a VM that is for BlueIris, and I'd like to take advantage of the HW GPU for endcoding since I do not have a intel quick assist CPU.  With this installed, am I able to pass this through to a windows 10 VM at the same time?

 

Read the first posts for this info. Should be mentioned there. 

Share this post


Link to post

Has anyone figured out how to monitor the gpu usage through netdata docker or telegraf- Grafana?

Share this post


Link to post

Are there any drawbacks to running the decode patch? For reference, I have a p2000 I would be testing this on.

Share this post


Link to post
7 hours ago, fr0stbyt3 said:

Are there any drawbacks to running the decode patch? For reference, I have a p2000 I would be testing this on.

Currently using a P2000 myself. The decode patch has basically no drawbacks other than being unsupported. Eventually the nvdec support will be a standard plex feature, and the patch will become obsolete at that point. There is one possible downfall for the patch currently, which I need to figure out a "proper" way to approach:
If for some reason your docker starts, and the nvidia card/driver is not working, your transcoder will cease to function entirely rendering playback impossible outside of native DirectPlay. This is a pretty impossible circumstance if you've configured everything and the nvenc side of the house works fine - but is certainly of concern because hardware failures occur, and changing to mainline unraid from the unraid-nvidia branch would also break Plex with the current script.

Share this post


Link to post
Posted (edited)
12 hours ago, Dazog said:

Has anyone figured out how to monitor the gpu usage through netdata docker or telegraf- Grafana?

That is something that would need support added for the netdata docker. There's a plugin here:
https://github.com/coraxx/netdata_nv_plugin

That would allow you to monitor various GPU statistics via netdata. Note that it doesn't monitor the nvdec and nvenc pipelines, so you wouldn't be able to see the transcoding usage - just the memory usage.

Edit:
Updated my script on gist;
https://git.io/fhhe3

Edited by Xaero

Share this post


Link to post

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.