Jump to content
linuxserver.io

[Plugin] Linuxserver.io - Unraid Nvidia

1168 posts in this topic Last Reply

Recommended Posts

linuxserver_medium.thumb.png.e9ced0e19571bc3bdd696f172623dbe1.png

nvidia-png-nvidia-geforce-gtx-780-review-300.png.399e456f7eefe1408f9ccb618e6e396e.png

 

Plugin Name: Unraid Nvidia

Github: https://github.com/linuxserver/Unraid-Nvidia-Plugin

 

This plugin from LinuxServer.io allows you to easily install a modified Unraid version with Nvidia drivers compiled and the docker system modified to use an nvidia container runtime, meaning you can use your GPU in any container you wish.

 

Any posts discussing circumvention of any Nvidia restrictions we will be asking mods to remove. 

We have worked hard to bring this work to you, and we don't want to upset Nvidia. 

If they were to threaten us with any legal action, all our source code and this plugin will be removed. 

 

Remember we are all volunteers, with regular jobs and families to support. 

 

Please if you see anyone else mentioning anything that contravenes this rule, flag it up to the mods. 

People that discuss this here could potentially ruin it for all of you.

 

 

EDIT: 25/5/19

OK everyone, the Plex script seems to be causing more issues than the Unraid Nvidia build as far as I can tell.

 

From this point on, to reduce the unnecessary noise and confusion on this thread, I'm going to request whoever is looking after, documenting or willing to support the Plex scripts spins off their own thread.

 

We will only be answering any support questions on people not using the script.  If your post is regarding Plex and you do not EXPLICITLY state that you are not using the Plex script then it will be ignored.

 

I know some of you may think this is unreasonable but it's creating a lot of additional work/time commitments for something I never intended to support and something I don't use (Not being a Plex user)

 

May I suggest respectfully, that one of you steps forward to create a thread, document it, and support it in it's own support place.  I think we need to decouple issues with the work we've done versus issues with a currently unsupported script.

 

Thanks.

Edited by linuxserver.io
Plex Script announcement

Share this post


Link to post

Read this first

1.  Any posts discussing circumvention of any Nvidia restrictions we will be asking mods to remove.  We have worked hard to bring this work to you, and we don't want to upset Nvidia.  If they were to threaten us with any legal action, all our source code and this plugin will be removed. 

 

Remember we are all volunteers, with regular jobs and families to support. 

 

Please if you see anyone else mentioning anything that contravenes this rule, flag it up to the mods.  People that discuss this here could potentially ruin it for all of you!

 

2.  If you attempt to start a VM passing through a GPU that is actively transcoding, you will hard lock your server and it will need an unclean shutdown.


3.  If you use Unraid in GUI mode and have only a single GPU in your server and you use that GPU in a virtual machine, trying to start that VM will crash libvirt.
 
4.  You can passthrough a GPU that is being passed through to a docker container as long as when you start that VM there is no active transcode processes happening, the docker container will fallback to software transcoding.  Check the webui of the docker container to check if transcoding is occurring before starting the VM, or if your GPU supports it, you can use

watch nvidia-smi

to check for transcoding processes.


5.  To be 100% safe, we recommend a dedicated GPU for transcoding that is not being used for any virtual machines, if you decide to ignore this, then you're on your own, we are not responsible for any problems that ensue.


6.  We will produce one Nvidia build per Unraid release, we will not be updating the drivers multiple times for each Unraid version, unless there is a critical bug that demands this.  So please don't ask.


7.  We are reliant on a lot of upstream projects here, we don't have any control over them, so we can't guarantee this will work for every release.

 

8.  We will look at a DVB solution in the future.  Once we know this is stable and working.

 

 

Background

Unraid Nvidia is a way of leveraging a Nvidia graphics card in your Unraid server to offload transcoding from the CPU to your GPU.

 

Although people have long been asking for Nvidia drivers on Unraid, there seems to have been a lack of understanding that this wouldn't solve a fundamental problem.  It would mean that only processes run on the host would be able to use them, they wouldn't be useful within docker containers unless the same drivers were then installed within each container, which is both inefficient and requires a special build of every container you wish to use Nvidia within.

 

We began to look at a possible solution about 5 months ago and it has required a number of different steps to get this working.

 

1.  Installing Nvidia drivers and kernel modules into Unraid utilising upstream SlackBuild packages, namely nvidia-kernel, nvidia-driver, google-go-lang, libseccomp & runc.  Modifying a part of the nvidia-driver due to the lack of a desktop environment on Unraid.

 

2.  Modifying the docker runtime to a version that can use an Nvidia wrapper to enable any docker container on your system to use the Nvidia graphics card using the Nvidia docker project.

 

3.  Rolling all this together and completely repackaging Unraid to implement all these changes, only bzroot-gui is left unaltered.

 

4.  Development of a plugin to enable easy downloading of the modified Nvidia release of Unraid.

 

All in all, not a simple task. 

 

Initial attempts by @CHBMB were hindered by segfaults, at which point, his real life commitments took over and the project hit a hiatus, @bass_rock then forked the work and hit the same issue.

 

After reaching out bass_rock we invited him to join the LinuxServer.io team to collaborate and to try one final strategy we had in mind to get this working, but hadn't got around to.

 

This strategy was instead of installing the drivers at boot time from a custom built Slackware package, taking the approach at build time of unpackaging bzroot and installing the drivers directly there, removing the need for an install at boot time and to our delight solving the segfault issue.   

 

Enthusiastically bass_rock implemented this and also made the original scripts nothing short of a work of art, adding shine and polish.

Edited by linuxserver.io

Share this post


Link to post

Now that's said and done, lets move on to the bits you're all interested in.

 

Please note that hardware (GPU) enabled transcoding requires either a

Plex Pass or Emby Premium subscription. 

Note: Emby will both decode and encode using the Nvidia GPU, Plex currently only encodes.

 

nvidia-smi requires a compatible video card - Some older nvidia cards are incompatible, sorry nothing we can do about that, everything will work apart from using watch nvidia-smi to view transcoding processes.

 

Step 1

Install the Unraid-Nvidia plugin from Community Applications or alternatively manually by copying this into the plugin page.

 

 

https://raw.githubusercontent.com/linuxserver/Unraid-Nvidia-Plugin/master/plugins/Unraid-Nvidia.plg

 

 

Step 2

Select the version of Unraid you wish to download and click the download and install button the reboot your server

 

Step 3

Go back to the Unraid-Nvidia page and you should find the information on Nvidia graphics cards is populated like below.

screenshot01.thumb.png.6dde1b36f4fd8162eddb1bdd81481c7b.png

 

There are three pieces of information for each card, looking at GPU 0, you can see the GPU name, the bus location and the GPU UUID.  Before you start, copy and paste the GPU UUID somewhere handy, or keep the Unraid-Nvidia screen open in a separate browser tab as you'll need it shortly.

 

screenshot02.png.04f61a6651b60fc25e5f765b05125526.png

 

How to Utilise the GPU in LinuxServer.io Emby, Jellyfin or Plex Docker Containers

 

With new installs of any of these containers from LinuxServer.io we have simplified the process of getting this working.

 

1.  Add the desired Application from CA.

2.  Switch the template to advanced mode

screenshot03.thumb.png.0c64157b66acc99a877d56edf42b5459.png

 

3.  Copy the GPU UUID to the existing NVIDIA_VISIBLE_DEVICES parameter

2019-06-11_11-13.thumb.png.804ee4cdeca3eb619acb72977f20234e.png

 

3.  Start the container.

 

How to Utilise the GPU in Docker Containers from other authors.

 

Now to utilise GPU 0 in a docker container, lets look how to do so using Plex, (although this can be applied to any container).  Add or edit Plex as per normal and switch the template to advanced mode.

 

screenshot03.thumb.png.0c64157b66acc99a877d56edf42b5459.png

 

Now add

--runtime=nvidia

to Extra Parameters: and then switch advanced mode off again.

screenshot04.png.4b165c75b416a7bfa116104e419a2173.png

 

Now we need to add two extra parameters, the first is the easiest one, as it will be identical to all containers. 

 

Click on Add another Path, Port, Variable, Label or Device and change config type to variable.  then add in the KEY field

NVIDIA_DRIVER_CAPABILITIES

and in the VALUE field add

all

screenshot05.thumb.png.b2b5cbfa50a7a75325d2fab7c776b650.pngscreenshot06.png.9304ef38d9e806cef6accc2f08151f9a.png

 

Now the 2nd parameter to add do exactly the same process as before but in the KEY field add

NVIDIA_VISIBLE_DEVICES

and in the VALUE field add the GPU UUID of the card you want to use.

screenshot07.png.c84efe506ee5b7083f6cc80e29ea6bf6.png

 

Configuring Plex

Go to your server settings and configure like below.

screenshot08.thumb.png.ba5ede7ac6daac3a5a8df9bb45121538.png

 

and you should find when playing content that is being transcoded you get a hw indication in the webui like below.

screenshot09.thumb.png.9653e2b24cddc3a59882b5689fb7a369.png

 

and running

watch nvidia-smi

from the terminal shows the transcoding process

screenshot10.png.fdc1cb286479310005ca835b9510ce09.png

 

Configuring Emby

Go to your server settings and configure like below.

screenshot11.thumb.png.bdb86725fe60d3dbd245b2cf5c9e30ea.png

 

Now you should find when playing content that is being transcoded it shows in the webui like so.

 

screenshot12.png.a9061c27dbead0ee421cda6989ce6cc6.png

 

and running

watch nvidia-smi

from the terminal shows the transcoding process

 

screenshot13.png.5cba2a8b900446044afbd0e10bb046a8.png

 

Configuring Jellyfin

Go to your server settings and configure like below.

2019-06-11_11-17.thumb.png.9dc63dd102c238a8387c3710bbc218b3.png

 

Now you should find when playing content that is being transcoded it shows in the webui like so.

2019-06-11_11-21.png.423292339921b8a8a8b0dc7584297336.png

 

and running

watch nvidia-smi

from the terminal shows the transcoding process

2019-06-13_21-36.png.f216509a5ee2941953fe787b4e851495.png

 

That's it.  Have fun.

Edited by linuxserver.io

Share this post


Link to post

This is incredible! Great work! I need to find a spot to fit another GPU in my system for this :)

 

 

My only question is that I'm having to used a patched kernel already. I'm assuming these won't be compatible with each other since it builds a new bzImage right?

 

Share this post


Link to post

Great work. Too bad my extra GPU is a 1030 or I would be all in on this.

Sent from my SM-N960U using Tapatalk

Share this post


Link to post
5 minutes ago, m0ngr31 said:

This is incredible! Great work! I need to find a spot to fit another GPU in my system for this :)

 

 

My only question is that I'm having to used a patched kernel already. I'm assuming these won't be compatible with each other since it builds a new bzImage right?

 

Correct, although iirc you only replace bzimage for your needs.  So you may get lucky if you continue to do the same.

Share this post


Link to post

v6.7.0rc3 compiled and uploaded.

Share this post


Link to post

Thank you guys for your awesome work! Installing it now!

 

I take it there is no way to modify the GPUs fans profile?

Share this post


Link to post
2 minutes ago, MowMdown said:

Thank you guys for your awesome work! Installing it now!

 

I take it there is no way to modify the GPUs fans profile?

We haven't explored it, it may be possible with nvidia-smi

Share this post


Link to post

Having some trouble getting this to work with my Plex Media Server.

Unraid version 6.6.6

This is my docker cmd

root@localhost:# /usr/local/emhttp/plugins/dynamix.docker.manager/scripts/docker run -d --name='plex' --net='host' --cpuset-cpus='2,3,4,5,6,7,8,9,10,11,12,13,14,15,18,19,20,21,22,23,24,25,26,27,28,29,30,31' -e TZ="America/Halifax" -e HOST_OS="Unraid" -e 'PUID'='99' -e 'PGID'='100' -e 'VERSION'='latest' -e 'NVIDIA_DRIVER_CAPABILITIES'='all' -e 'NVIDIA_VISIBLE_DEVICES'='GPU-386029cb-55e6-6dca-a528-b1eaf7fdc74f' -v '/mnt/user/media/':'/media':'rw' -v '/dev/shm/':'/transcode':'rw' -v '/mnt/user/appdata/plex':'/config':'rw,slave' --runtime=nvidia 'linuxserver/plex'
/usr/bin/docker: Error response from daemon: Unknown runtime specified nvidia.
See '/usr/bin/docker run --help'.

The command failed.

When I removed 

--runtime=nvidia

 

My docker will startup no problem but no nvidia support.

 

This works with my Emby Docker but the Plex Media Server

tower-diagnostics-20190210-0059.zip

Edited by deaerator

Share this post


Link to post

for some reason, when i tried installing nvidia driver for unraid 6.6.6, i got this error "Checking SHA 256's: failed!". is it a bug or is there a solution for it? 

Share this post


Link to post

everything works fine!  Thanks guys!  I also applied the workaround for NVDEC support on PLEX.  The small script that calls Plex Transcoder with the -hwaccel nvdec switch.

Share this post


Link to post

may a question about multi usability, currently i use the igpu for multiply dockers.

 

emby, plex, tvheadend ... they all also can run simultan, would this also work with this nvidia implentation or

same behavior when using docker & VM ?

Share this post


Link to post

My only real question is, how can I know my GPU will support this before I install it? I swear, I will buy a new GPU JUST for this if I have to!

 

This is such good news, I seriously cannot contain my excitement!

Share this post


Link to post
5 minutes ago, cammelspit said:

My only real question is, how can I know my GPU will support this before I install it? I swear, I will buy a new GPU JUST for this if I have to!

 

This is such good news, I seriously cannot contain my excitement!

my guess would be

 

https://developer.nvidia.com/video-encode-decode-gpu-support-matrix

 

so 1050 up ... you should be good to go

Edited by alturismo

Share this post


Link to post

Having trouble with the runtime not working.

when i first installed the plugin docker was able to use the nvidia runtime after a restart of a plex container docker started throwing the unknown runtime error. i reinstalled the stock unraid...then reboot.... then reinstall nvidia build. same thing no nvidia runtime.

 

i am able to run nvidia-smi from unraids shell all is good there

 

 

/usr/bin/docker: Error response from daemon: Unknown runtime specified nvidia.
See '/usr/bin/docker run --help'.

The command failed.

 

  OK got it - i was able to run docker with the runtime from the shell then i removed the unraid template and used a new template from the community apps and unraid was then able to fire up the nvidia runtime. i then was able to successfully use the GPU for plex

 

Screen Shot 2019-02-09 at 10.48.33 PM.png

Edited by RCFilm

Share this post


Link to post

Looks like I'll be buying a new GPU then because I don't have a spare card that is compatible, thanks for the link!

Share this post


Link to post

i'm wondering what would be a sweet spot a Nvidia card to use only for this trancoding process. Nvidia Quadro P400 maybe?

Share this post


Link to post
My only real question is, how can I know my GPU will support this before I install it? I swear, I will buy a new GPU JUST for this if I have to!
 
This is such good news, I seriously cannot contain my excitement!
There's a link in the plugin to the Nvidia site, select your driver there and it will tell you what cards are supported. Transcoding ability does vary between cards though, so you will need to do some research.

Sent from my Mi A1 using Tapatalk

Share this post


Link to post
may a question about multi usability, currently i use the igpu for multiply dockers.
 
emby, plex, tvheadend ... they all also can run simultan, would this also work with this nvidia implentation or
same behavior when using docker & VM ?
You should be able to use this for multiple containers.

Sent from my Mi A1 using Tapatalk

Share this post


Link to post
Is there a list of compatible cards? 
See my reply two posts up.

Sent from my Mi A1 using Tapatalk

Share this post


Link to post
for some reason, when i tried installing nvidia driver for unraid 6.6.6, i got this error "Checking SHA 256's: failed!". is it a bug or is there a solution for it? 
It's not a bug. Generally it's a DNS issue or something on your LAN causing it, as to a solution, it's something I've never been able to reproduce as we occasionally see the same thing with the DVB plugin. I'd be taking a look at DNS personally.

Sent from my Mi A1 using Tapatalk

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.