Jump to content

Enable hardware acceleration on FreeBSD


Duffyx

Recommended Posts

krzysik

Hello, I installed FreeNAS-11.3-U5 on FreeBSD 11.3-RELEASE-p14 amd64. With Emby server installed. To transcode the video I inserted the GTX 1660 super card. I downloaded the driver from https://www.nvidia.pl/Download/driverResults.aspx/184675/pl This is where the problems begin for me; ( Could someone show me step by step how to install the graphics driver in this system?

I downloaded the driver, unpacked the zipped file. In the first step, he gets an error with the "make install" command.

sh: cc: not found
make: "/usr/share/mk/bsd.compiler.mk" line 147: Unable to determine compiler type for CC=cc.  Consider setting COMPILER_TYPE.

I have installed the gcc package (pkg install gcc). The error is the same all the time.

Link to comment
Share on other sites

bbartlomiej

Hey - few hints:

  • if this is new installation, move to TrueNAS 12.x since this is current, FreeNAS is decomissioned
  • for general help with FreeBSD driver installation - try FreeBSD forums
  • for general help with driver installation specifically in TrueNAS - try TrueNAS forums

When you have that figured out, come back here and we can try enable HW acceleration with Emby.

I'm gonna go through the same path with the Quadro I'm waiting for, but I may end up just starting a Linux VM inside TrueNAS and pass through the PCI ID of my GPU inside. That would be a shame though.

  • Like 1
Link to comment
Share on other sites

krzysik
28 minutes ago, bbartlomiej said:

Hey - few hints:

  • ... That would be a shame though.

 

Thank you very much for the tips. I updated to TrueNAS-12.0-U8.

I follow the instructions on the Nvidia website.

http://us.download.nvidia.com/XFree86/FreeBSD-x86_64/495.46/README/installdriver.html

I get an error with make makefile.

In the freeBSD forums I wrote and looked for answers. Unfortunately, nothing helps me.

Link to comment
Share on other sites

bbartlomiej

TrueNAS is a tailored for purpose distribution of FreeBSD - not all guides will work there without additional steps. You will have more luck asking on TrueNAS forums.
Plus - have you read your error message? It actually points you to some fix.

Link to comment
Share on other sites

  • 5 months later...
  • 3 months later...

Just wanted to thank the contributors to this thread; I was able to get this working on FBSD12.4 fairly easily.  The difference between software transcoding and hardware is astounding!

  • Thanks 1
Link to comment
Share on other sites

bbartlomiej

Yes it still works for me as well. It would be awesome though if on FreeBSD we wouldn't have to create a bunch of bogus files around the filesystem 😀

Link to comment
Share on other sites

  • 2 weeks later...
eraser8
On 1/13/2023 at 6:58 PM, orie said:

Just wanted to thank the contributors to this thread; I was able to get this working on FBSD12.4 fairly easily.  The difference between software transcoding and hardware is astounding!

Hi Orie!

I previously tried in the past to get hardware acceleration with ATI card but Was not able to do it and decided to wait for improvement.

What is the hardware GPU you have for acceleration? And more important, do you have a guide to follow to install it?

 

Great thanks

Link to comment
Share on other sites

bbartlomiej
6 hours ago, eraser8 said:

Hi Orie!

I previously tried in the past to get hardware acceleration with ATI card but Was not able to do it and decided to wait for improvement.

What is the hardware GPU you have for acceleration? And more important, do you have a guide to follow to install it?

 

Great thanks

If you'd have followed the thread you you'd see that we're talking about Intel based GPUs mainly. Double check if TrueNAS has your Nvidia/ATI drivers out of the box because otherwise a normal guide for FreeBSD may not be enough.

Link to comment
Share on other sites

eraser8
6 hours ago, bbartlomiej said:

If you'd have followed the thread you you'd see that we're talking about Intel based GPUs mainly. Double check if TrueNAS has your Nvidia/ATI drivers out of the box because otherwise a normal guide for FreeBSD may not be enough.

Thanks for info

Link to comment
Share on other sites

  • 4 weeks later...

port install of emby(version 4.7.11.0_1) failed in freebsd13.1, as reported in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269090

Quote

libavutil/hwcontext_vulkan.c:363:7: error: use of undeclared identifier 'VK_EXT_VIDEO_DECODE_H264_EXTENSION_NAME'
    { VK_EXT_VIDEO_DECODE_H264_EXTENSION_NAME,                FF_VK_EXT_NO_FLAG                },
      ^
libavutil/hwcontext_vulkan.c:364:7: error: use of undeclared identifier 'VK_EXT_VIDEO_DECODE_H265_EXTENSION_NAME'
    { VK_EXT_VIDEO_DECODE_H265_EXTENSION_NAME,                FF_VK_EXT_NO_FLAG                },
      ^
libavutil/hwcontext_vulkan.c:469:29: error: invalid application of 'sizeof' to an incomplete type 'const VulkanOptExtension []'
        optional_exts_num = FF_ARRAY_ELEMS(optional_device_exts);
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libavutil/macros.h:53:34: note: expanded from macro 'FF_ARRAY_ELEMS'
#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
                                 ^~~
libavutil/hwcontext_vulkan.c:1434:29: error: invalid application of 'sizeof' to an incomplete type 'const VulkanOptExtension []'
        for (int j = 0; j < FF_ARRAY_ELEMS(optional_device_exts); j++) {
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libavutil/macros.h:53:34: note: expanded from macro 'FF_ARRAY_ELEMS'
#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
                                 ^~~
4 errors generated.
gmake[2]: *** [ffbuild/common.mak:79: libavutil/hwcontext_vulkan.o] Error 1

may related to the bundled ffmpeg-2022_05_07 (bug #261302)

following the steps included in the bug report , hardware acceleration cannot work any more.

please help.

Edited by emnooo
Link to comment
Share on other sites

15 hours ago, emnooo said:

port install of emby(version 4.7.11.0_1) failed in freebsd13.1, as reported in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269090

following the steps included in the bug report , hardware acceleration cannot work any more.

please help.

Hi, we're happy to help: 

 Let's look at an example. Please attach the information requested in how to report a media playback issue. Thanks!

 

Link to comment
Share on other sites

  • 3 months later...
hadr0n

Hello,

I read quickly through the 8 pages of discussion, just wanted to ask for the status about this. I have Truenas core 13, intel 12100 CPU (quicksync), emby 4.7.11.0 installed in a jail using the truenas interface. I just wanted to know if I have to go through the different steps of the discussion (which seems to consist in creating some links/files here and there in the truenas filesystem) or if there is now a more direct solution?

Thanks

Link to comment
Share on other sites

On 5/19/2023 at 5:19 AM, hadr0n said:

Hello,

I read quickly through the 8 pages of discussion, just wanted to ask for the status about this. I have Truenas core 13, intel 12100 CPU (quicksync), emby 4.7.11.0 installed in a jail using the truenas interface. I just wanted to know if I have to go through the different steps of the discussion (which seems to consist in creating some links/files here and there in the truenas filesystem) or if there is now a more direct solution?

Thanks

HI, I would suggest going through this topic. Did you end up trying anything?

Link to comment
Share on other sites

hadr0n
15 hours ago, Luke said:

HI, I would suggest going through this topic. Did you end up trying anything?

Thank you for the suggestion, I have not tried yet,  right now I'm fighting to make my emby jail accessible through tun openvpn server interface (but that's another topic). I decided to use Truenas core to avoid messing around with ZFS configuration on a standard Debian, and because Truenas scale was full of bugs when I tried it. I'm however starting to wonder if I don't end up with more headache everything considered. Whatever, I will try going through enabling hardware acceleration and get back to this post to report how it went.

  • Thanks 1
Link to comment
Share on other sites

Baenwort

I still have to go through all the steps to have transcoding work on FreeBSD based TrueNAS Core. So far no one has developed a better method.

  • Thanks 1
Link to comment
Share on other sites

eraser8

I chosen to go with Truenas scale for GPU acceleration. Works fine with Emby

Edited by eraser8
Link to comment
Share on other sites

  • 1 month later...
hadr0n

I'm trying to make it work, let's say I'm struggling. My CPU is an Intel core i3 12100, my OS is TrueNAS-13.0-U4. Here is what I have done:

- I have copied the directories in the sys.tar directory shared by "binemeister" to /usr/src/sys (in the jail)

- I have done

In host:

pkg install drm-kmod
sysrc kld_list+="drm"
kldload drm

In jail:

pkg install libva-intel-media-driver
pw groupmod -n video -m emby

- I have a /dev/drm on the host, but no /dev/dri

- I have setup the script poststart_devfs.sh in the Truenas task (at boot), change jail ruleset to 5, and I now have /dev/drm in the jail

- I have added the tunable i915kms_load and drm_load with value YES

 

- I don't have a directory /usr/jail, so "I cannot" exec.poststart = "cd /usr/jail/emby/dev/dri; ln -s card0 render0";

- I don't have a /dev/dri directory on the host

- I don't have any /sys/bus/  neither on host neither in jail

A bit confused, but I think my main issue is that I don't have /dev/dri (on the host) despite having installed drm-kmod, while I have /dev/drm.

Link to comment
Share on other sites

hadr0n

I noticed that the driver installed as drm-kmod is quite old (2022-09-07) so I installed drm-510-kmod (2023-05-12 07:25:00). I installed vainfo (on the host) and I get the following output. So I guess I just don't have the right driver on the host. It is surprising because I have the impression from reading free bsd forums that alder lake is supported, though I must admit it is not very clear, maybe it is only supported by free bsd 14. If someone has more info about this, it would help.

image.png.4dc7ca0e1159fdf14099d775306a7ce7.png

Link to comment
Share on other sites

bbartlomiej

@hadr0nmy notes say you should

kld_list+="i915kms"

instead. I have this added in System > Tunables as a RC tunable.

My exec.poststart is

cd /mnt/tank/iocage/jails/emby/root/dev/dri; ln -s card0 render0

since /mnt/tank is my dataset for jails. What is yours?

Also I have a script run on startup in Tasks > Init/Shutdown scripts:

#!/bin/bash

cat >>/etc/devfs.rules << 'EOF'

[devfsrules_bpfjail=101]
add path 'bpf*' unhide

[plex_drm=1024]
add include $devfsrules_hide_all
add include $devfsrules_unhide_basic
add include $devfsrules_unhide_login
add include $devfsrules_jail
add include $devfsrules_bpfjail
add path 'dri*' unhide
add path 'dri/*' unhide
add path 'drm*' unhide
add path 'drm/*' unhide

EOF

service devfs restart

The devfs ruleset number 1024 is of course referenced in emby's jail configuration as devfs_ruleset. I don't really remember now if I had to make any symlinks in the host's /dev/dri/ or /dev/drm/ directories.

In the emby jail:

#IN JAIL

# install pciid
# pkg install pciids
# ln -s /usr/local/share/pciids/pci.ids /usr/share/hwdata/

#*** Install the supporting Intel VA support library for your GPU
#*** libva-intel-driver: [LEGACY] Intel GMA 4500 or newer
#*** libva-intel-media-driver: Intel HD 5000 (Gen8) or newer

#pkg install libva-intel-media-driver libvdpau-1.5

#***Add emby user to the video group: 

#pw groupmod -n video -m emby

# IN JAIL CONFIG

# exec_poststart = cd /mnt/tank/iocage/jails/emby/root/dev/dri; ln -s card0 render0

I am using this on a Pentium G6400 and it is pretty stable. I had to update emby to beta at one time because it was not fully working but it is solid since then.

  • Thanks 1
Link to comment
Share on other sites

hadr0n

Thanks for helping.

My first question would be how can I be sure that my GPU is well recognized by the host?

Following your comments:

- I have added

kld_list+="i915kms"

I can see the option in /etc/rc.conf.freenas.

image.png.b61ec08a9c2d0726c6bdd1eb1fa7b6a9.png

- About

cd /mnt/tank/iocage/jails/emby/root/dev/dri; ln -s card0 render0

my dataset is nocompressionraidz1, I don't have a directory dri in path "/mnt/nocompressionraidz1/iocage/jails/emby-server-stable-jail/root/dev/"

image.png.c5ae6f13bc145c44a299a1c829d24004.png

Furthermore, I don't have a file "card0" in the directory /dev/drm (host side)

- About the script:

image.png.81feeb91ca795a262e0b2d120e53e01f.png

image.png.9fc9924b67da5ab12f8247aadda0cfca.png

- "pkg install pciids" -> done

- I have an issue with this one

  ln -s /usr/local/share/pciids/pci.ids /usr/share/hwdata/

image.png.542ab1baec1db69926aaea7c93745b41.png

Link to comment
Share on other sites

bbartlomiej

@hadr0nyou need to go through this thread and find the module that will enable /dev/drm/* and /dev/dri/* for your hardware. I did it a year ago so don't remember right now but /dev/dri/* may just be a symlink:

root@jupiter:/dev # ls -l | grep dri
dr-xr-xr-x  2 root  wheel      512 Jul 15 21:18 dri
root@jupiter:/dev # cd dri
root@jupiter:/dev/dri # ls -l
total 0
lrwxr-xr-x  1 root  wheel   8 Jul 15 21:18 card0 -> ../drm/0
lrwxr-xr-x  1 root  wheel  10 Jul 15 21:18 renderD128 -> ../drm/128

Are you rebooting TrueNAS after adding the module to kld_list? What do you have in /dev/drm?

After you reboot TrueNAS and run your emby jail with the devfs ruleset you should see at least some directories in /dev/ of the jail.

The script you showed symlinks /dev/drm into /dev/dri which is not correct.

As for

  ln -s /usr/local/share/pciids/pci.ids /usr/share/hwdata/

It work for me from within the jail just fine.

Are you using a fresh jail where you installed Emby yourself or are you using a TrueNAS plugin for Emby under Plugins > Community ? It seems it's the latter which will not work as plugins don't give you all the permissions.
Create an empty jail and install Emby manually according to: https://emby.media/freebsd-server.html

  • Thanks 1
Link to comment
Share on other sites

hadr0n
On 7/16/2023 at 11:57 PM, bbartlomiej said:

@hadr0nyou need to go through this thread and find the module that will enable /dev/drm/* and /dev/dri/* for your hardware. I did it a year ago so don't remember right now but /dev/dri/* may just be a symlink:

I finally found some time to test things. I have /dev/drm on the host.

root@jupiter:/dev # ls -l | grep dri
dr-xr-xr-x  2 root  wheel      512 Jul 15 21:18 dri
root@jupiter:/dev # cd dri
root@jupiter:/dev/dri # ls -l
total 0
lrwxr-xr-x  1 root  wheel   8 Jul 15 21:18 card0 -> ../drm/0
lrwxr-xr-x  1 root  wheel  10 Jul 15 21:18 renderD128 -> ../drm/128

As I understand, I have to create symlinks /dev/dri/card0 -> /dev/drm/0 and /dev/dri/renderD128 -> /dev/drm/128. So it might not be an issue if I don't have the dir /dev/dri (on the host). Apparently symlinks are not "passed through" using devfs. So I ended up doing this as jail exec post start:

cd /mnt/nocompressionraidz1/iocage/jails/emby-server-stable-jail/root/dev; ln -s drm dri; cd drm; ln -s 0 card0; ln -s 128 renderD128

Are you rebooting TrueNAS after adding the module to kld_list? What do you have in /dev/drm?

Yes. Here is screenshot of part of my /dev/drm content:

image.png.df1251d1c8b2ad77eb77fc1551f82538.png

I created card0 and renderD128 myself as symlink to 0 and 128.

After you reboot TrueNAS and run your emby jail with the devfs ruleset you should see at least some directories in /dev/ of the jail.

I see drm and dri now, dri thanks to the fact that I created the symlinks myself as stated above.

The script you showed symlinks /dev/drm into /dev/dri which is not correct.

I removed it thanks.

As for

  ln -s /usr/local/share/pciids/pci.ids /usr/share/hwdata/

It work for me from within the jail just fine.

Are you using a fresh jail where you installed Emby yourself or are you using a TrueNAS plugin for Emby under Plugins > Community ? It seems it's the latter which will not work as plugins don't give you all the permissions.
Create an empty jail and install Emby manually according to: https://emby.media/freebsd-server.html

 

Indeed I'm using community plugin, thanks for pointing out... I will try creating a jail from scratch now.

 

 

Link to comment
Share on other sites

hadr0n

Well the jail openvpn config I spend days to make working properly was messed up again, while I don't remember having changed anything related to that. So I finally switched to Debian 12, loaded my ZFS pool, installed emby deb package, openvpn and everything works fine. From my side it was a quite bad experience with these "fancy" tools like True Nas, working from scratch ends up being much simpler, so I don't really get the point.

Link to comment
Share on other sites

bbartlomiej

Well you've said yourself - you messed it up :) It works just fine for me and others. TrueNAS's purpose is a bit different so don't complain you need to jump through hoops to make something work. If you don't get the point of the tool, the tool is not for you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...