Jump to content

How to enable hardware transcoding in Proxmox VE LXC container Docker?


Recommended Posts

Posted

My CPU is Intel N100, the PVE version I use is 8.2.2, the Linux kernel is 6.8.4-2, and the LXC is UBUNTU20.04. I have installed docker, emby, and u in lxc, and by configuring the LXC conf file, I can see card0 and renderD128 in ls -l /dev/dri in LXC and emby, but there is still no option in hardware transcoding.

image.jpeg.d5218033d052cb8483cd41e95c840fbf.jpeg

Posted
52 minutes ago, xiaolulu said:

My CPU is Intel N100, the PVE version I use is 8.2.2, the Linux kernel is 6.8.4-2, and the LXC is UBUNTU20.04. I have installed docker, emby, and u in lxc, and by configuring the LXC conf file, I can see card0 and renderD128 in ls -l /dev/dri in LXC and emby, but there is still no option in hardware transcoding.

image.jpeg.d5218033d052cb8483cd41e95c840fbf.jpeg

Did you also make sure to chmod 660 /dev/dri on the host? You then have to add what ever User your docker is running emby as to the group that has access to /dev/dri.

On a side note why not just install emby as a regular install and not docker. LXC is already a container and lightweight there's no need for docker. There's even proxmox helper scripts that does it all for you

 

Posted
8 hours ago, guunter said:

Did you also make sure to chmod 660 /dev/dri on the host? You then have to add what ever User your docker is running emby as to the group that has access to /dev/dri.

On a side note why not just install emby as a regular install and not docker. LXC is already a container and lightweight there's no need for docker. There's even proxmox helper scripts that does it all for you

 

Are you talking about the PVE host or the LXC container? What do you mean by any user running EMBY? Do you mean the username "docker" in the lxc container?
Because docker can be independent of the LXC container.

 

Posted (edited)
26 minutes ago, xiaolulu said:

Are you talking about the PVE host or the LXC container? What do you mean by any user running EMBY? Do you mean the username "docker" in the lxc container?
Because docker can be independent of the LXC container.

 

On the pve host you chmod the folder. And in the lxc what ever pgid/puid you set in docker run/compose, that user needs to be added to the group that owns /dev/dri in the lxc.

image.thumb.png.a5dfdd6740daac612c182ef5a71d5268.png

 

Edited by guunter
Posted

Also did you install intel runtime on the host and lxc? This is needed for transcoding as well.

apt install -y intel-opencl-icd

Posted

This is the information of /dev/dri on my PVE host
root@PVE:~# ls -l /dev/dri
total 0
drwxr-xr-x 2 root root 80 Nov 1 21:25 by-path
crw-rw---- 1 root video 226, 0 Nov 1 21:25 card0
crw-rw---- 1 root render 226, 128 Nov 1 21:25 renderD128
This is the information in the LXC container
root@Linux:~# ls -l /dev/dri
total 0
crw-rw---- 1 root video 226, 0 Nov 1 13:25 card0
crw-rw---- 1 root ssl-cert 226, 128 Nov 1 13:25 renderD128
This is the information of emby in docker
/ # ls -l /dev/dri
total 0
crw-rw---- 1 root 44 226, 0 Nov 2 00:11 card0
crw-rw---- 1 root 104 226, 128 Nov 2 00:11 renderD128
Information in Docker compose
environment:
- UID=0
- GID=0
- GIDLIST=0
In my LXC container, the renderD128 user group became ssl-cert, and in emby, the user groups became 44 and 104. I don't know what's going on? And I didn't find these two user groups 44 and 104 in emby.

Posted
42 minutes ago, guunter said:

On the pve host you chmod the folder. And in the lxc what ever pgid/puid you set in docker run/compose, that user needs to be added to the group that owns /dev/dri in the lxc.

image.thumb.png.a5dfdd6740daac612c182ef5a71d5268.png

 

This is the information of /dev/dri on my PVE host
root@PVE:~# ls -l /dev/dri
total 0
drwxr-xr-x 2 root root 80 Nov 1 21:25 by-path
crw-rw---- 1 root video 226, 0 Nov 1 21:25 card0
crw-rw---- 1 root render 226, 128 Nov 1 21:25 renderD128
This is the information in the LXC container
root@Linux:~# ls -l /dev/dri
total 0
crw-rw---- 1 root video 226, 0 Nov 1 13:25 card0
crw-rw---- 1 root ssl-cert 226, 128 Nov 1 13:25 renderD128
This is the information of emby in docker
/ # ls -l /dev/dri
total 0
crw-rw---- 1 root 44 226, 0 Nov 2 00:11 card0
crw-rw---- 1 root 104 226, 128 Nov 2 00:11 renderD128
Information in Docker compose
environment:
- UID=0
- GID=0
- GIDLIST=0
In my LXC container, the renderD128 user group became ssl-cert, and in emby, the user groups became 44 and 104. I don't know what's going on? And I didn't find these two user groups 44 and 104 in emby.

 

Posted
1 hour ago, xiaolulu said:

This is the information of /dev/dri on my PVE host
root@PVE:~# ls -l /dev/dri
total 0
drwxr-xr-x 2 root root 80 Nov 1 21:25 by-path
crw-rw---- 1 root video 226, 0 Nov 1 21:25 card0
crw-rw---- 1 root render 226, 128 Nov 1 21:25 renderD128
This is the information in the LXC container
root@Linux:~# ls -l /dev/dri
total 0
crw-rw---- 1 root video 226, 0 Nov 1 13:25 card0
crw-rw---- 1 root ssl-cert 226, 128 Nov 1 13:25 renderD128
This is the information of emby in docker
/ # ls -l /dev/dri
total 0
crw-rw---- 1 root 44 226, 0 Nov 2 00:11 card0
crw-rw---- 1 root 104 226, 128 Nov 2 00:11 renderD128
Information in Docker compose
environment:
- UID=0
- GID=0
- GIDLIST=0
In my LXC container, the renderD128 user group became ssl-cert, and in emby, the user groups became 44 and 104. I don't know what's going on? And I didn't find these two user groups 44 and 104 in emby.

 

How did you do the install in docker? Docker run or docker compose? 

Posted
11 minutes ago, guunter said:

How did you do the install in docker? Docker run or docker compose? 

compose

Posted (edited)
31 minutes ago, xiaolulu said:

compose

Can you post your compose config?

Edited by guunter
Posted
10 minutes ago, guunter said:

Can you post your compose config?

version: '3' 

services:
  emby:
    image: emby/embyserver  
    container_name: emby               
    restart: always                  
    privileged: true 
    ports:
      - '8096:8096'                
      - '8920:8920'                   
      - '1900:1900/udp'              
      - '7359:7359/udp'               
    volumes:
      - /emby/config/:/config              # 将主机上的 ./config 目录挂载到容器的 /config
      - /emby/video/:/data      # 将主机上的 /pt/downloads/link 目录挂载到容器的 /data
      - /etc/timezone:/etc/timezone   # 同步主机和容器的时区设置
      - /etc/localtime:/etc/localtime # 同步主机和容器的本地时间
    environment:
      - UID=0                         # 设置容器用户 ID 为 0 (通常是 root)
      - GID=0                         # 设置容器组 ID 为 0 (通常是 root)
      - GIDLIST=0                     # 设置容器组 ID 列表为 0
      - NVIDIA_VISIBLE_DEVICES=all    # 允许容器访问所有 NVIDIA 设备
    devices:
      - /dev/dri:/dev/dri             # 将主机的 /dev/dri 设备挂载到容器
   

Posted
10 minutes ago, xiaolulu said:

version: '3' 

services:
  emby:
    image: emby/embyserver  
    container_name: emby               
    restart: always                  
    privileged: true 
    ports:
      - '8096:8096'                
      - '8920:8920'                   
      - '1900:1900/udp'              
      - '7359:7359/udp'               
    volumes:
      - /emby/config/:/config              # 将主机上的 ./config 目录挂载到容器的 /config
      - /emby/video/:/data      # 将主机上的 /pt/downloads/link 目录挂载到容器的 /data
      - /etc/timezone:/etc/timezone   # 同步主机和容器的时区设置
      - /etc/localtime:/etc/localtime # 同步主机和容器的本地时间
    environment:
      - UID=0                         # 设置容器用户 ID 为 0 (通常是 root)
      - GID=0                         # 设置容器组 ID 为 0 (通常是 root)
      - GIDLIST=0                     # 设置容器组 ID 列表为 0
      - NVIDIA_VISIBLE_DEVICES=all    # 允许容器访问所有 NVIDIA 设备
    devices:
      - /dev/dri:/dev/dri             # 将主机的 /dev/dri 设备挂载到容器
   

The compose looks fine except you can remove nvidia line. Can you post your lxc.conf?

Posted
Just now, guunter said:

The compose looks fine except you can remove nvidia line. Can you post your lxc.conf?

arch: amd64
cores: 4
features: nesting=1
hostname: Linux
memory: 4096
net0: name=eth0,bridge=vmbr0,firewall=1,gw=10.10.10.1,hwaddr=BC:24:11:48:14:16,ip=10.10.10.11/32,ip6=dhcp,type=veth
ostype: ubuntu
parent: emby
rootfs: local-lvm:vm-103-disk-1,size=20G
swap: 0
lxc.apparmor.profile: unconfined
lxc.cgroup.devices.allow: a
lxc.cap.drop: 
lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.mount.entry: /dev/dri/card0 dev/dri/card0 none bind,optional,create=file
lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file

[emby]
arch: amd64
cores: 4
features: nesting=1
hostname: Linux
memory: 4096
net0: name=eth0,bridge=vmbr0,firewall=1,gw=10.10.10.1,hwaddr=BC:24:11:48:14:16,ip=10.10.10.11/32,ip6=dhcp,type=veth
ostype: ubuntu
parent: portainer
rootfs: local-lvm:vm-103-disk-1,size=20G
snaptime: 1730436160
swap: 0
lxc.apparmor.profile: unconfined
lxc.cgroup.devices.allow: a
lxc.cap.drop: 
lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.mount.entry: /dev/dri/card0 dev/dri/card0 none bind,optional,create=file
lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file

[jellyfin]
arch: amd64
cores: 4
features: nesting=1
hostname: Linux
memory: 4096
net0: name=eth0,bridge=vmbr0,firewall=1,gw=10.10.10.1,hwaddr=BC:24:11:48:14:16,ip=10.10.10.11/32,ip6=dhcp,type=veth
ostype: ubuntu
parent: portainer
rootfs: local-lvm:vm-103-disk-1,size=20G
snaptime: 1730457685
swap: 0
lxc.apparmor.profile: unconfined
lxc.cgroup.devices.allow: a
lxc.cap.drop: 
lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.mount.entry: /dev/dri/card0 dev/dri/card0 none bind,optional,create=file
lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file

[portainer]
arch: amd64
cores: 4
features: nesting=1
hostname: Linux
memory: 4096
net0: name=eth0,bridge=vmbr0,firewall=1,gw=10.10.10.1,hwaddr=BC:24:11:48:14:16,ip=10.10.10.11/32,ip6=dhcp,type=veth
ostype: ubuntu
rootfs: local-lvm:vm-103-disk-1,size=20G
snaptime: 1730428651
swap: 0
lxc.apparmor.profile: unconfined
lxc.cgroup.devices.allow: a
lxc.cap.drop: 
lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.mount.entry: /dev/dri/card0 dev/dri/card0 none bind,optional,create=file
lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file
 

Posted
38 minutes ago, xiaolulu said:

arch: amd64
cores: 4
features: nesting=1
hostname: Linux
memory: 4096
net0: name=eth0,bridge=vmbr0,firewall=1,gw=10.10.10.1,hwaddr=BC:24:11:48:14:16,ip=10.10.10.11/32,ip6=dhcp,type=veth
ostype: ubuntu
parent: emby
rootfs: local-lvm:vm-103-disk-1,size=20G
swap: 0
lxc.apparmor.profile: unconfined
lxc.cgroup.devices.allow: a
lxc.cap.drop: 
lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.mount.entry: /dev/dri/card0 dev/dri/card0 none bind,optional,create=file
lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file

[emby]
arch: amd64
cores: 4
features: nesting=1
hostname: Linux
memory: 4096
net0: name=eth0,bridge=vmbr0,firewall=1,gw=10.10.10.1,hwaddr=BC:24:11:48:14:16,ip=10.10.10.11/32,ip6=dhcp,type=veth
ostype: ubuntu
parent: portainer
rootfs: local-lvm:vm-103-disk-1,size=20G
snaptime: 1730436160
swap: 0
lxc.apparmor.profile: unconfined
lxc.cgroup.devices.allow: a
lxc.cap.drop: 
lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.mount.entry: /dev/dri/card0 dev/dri/card0 none bind,optional,create=file
lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file

[jellyfin]
arch: amd64
cores: 4
features: nesting=1
hostname: Linux
memory: 4096
net0: name=eth0,bridge=vmbr0,firewall=1,gw=10.10.10.1,hwaddr=BC:24:11:48:14:16,ip=10.10.10.11/32,ip6=dhcp,type=veth
ostype: ubuntu
parent: portainer
rootfs: local-lvm:vm-103-disk-1,size=20G
snaptime: 1730457685
swap: 0
lxc.apparmor.profile: unconfined
lxc.cgroup.devices.allow: a
lxc.cap.drop: 
lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.mount.entry: /dev/dri/card0 dev/dri/card0 none bind,optional,create=file
lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file

[portainer]
arch: amd64
cores: 4
features: nesting=1
hostname: Linux
memory: 4096
net0: name=eth0,bridge=vmbr0,firewall=1,gw=10.10.10.1,hwaddr=BC:24:11:48:14:16,ip=10.10.10.11/32,ip6=dhcp,type=veth
ostype: ubuntu
rootfs: local-lvm:vm-103-disk-1,size=20G
snaptime: 1730428651
swap: 0
lxc.apparmor.profile: unconfined
lxc.cgroup.devices.allow: a
lxc.cap.drop: 
lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.mount.entry: /dev/dri/card0 dev/dri/card0 none bind,optional,create=file
lxc.mount.entry: /dev/dri/renderD128 dev/dri/renderD128 none bind,optional,create=file
 

Wait is this one lxc.conf? /etc/pve/lxc/100.conf (example)

Posted (edited)
13 minutes ago, guunter said:

Wait is this one lxc.conf? /etc/pve/lxc/100.conf (example)

Yes, "/etc/pve/nodes/PVE/lxc/103.conf".

[portainer] [jellyfin] [emby]These are snapshots.

And the device: card0 was named card1 before I wrote options i915 enable_guc=3 into the "/etc/modprobe.d/i915.conf" file.

Edited by xiaolulu
Posted
53 minutes ago, xiaolulu said:

Yes, "/etc/pve/nodes/PVE/lxc/103.conf".

[portainer] [jellyfin] [emby]These are snapshots.

And the device: card0 was named card1 before I wrote options i915 enable_guc=3 into the "/etc/modprobe.d/i915.conf" file.

You can try changing the group the group that is passed to the lxc. In the .conf I have this for the igpu

 

lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.cgroup2.devices.allow: c 29:0 rwm
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
lxc.mount.entry: /dev/dri/renderD128 dev/renderD128 none bind,optional,create=file
lxc.hook.pre-start: sh -c "chown 100000:111000 /dev/dri/renderD128"

and then in the lxc you need to create a new group.

if you have a privileged lxc

groupadd -g 111000 lxc_gpu_shares

If it’s a unprivileged lxc 

groupadd -g 11000 lxc_gpu_shares

And then you need to add the user Emby runs as to this group. In your case 0 is root.

gpasswd -a root lxc_gpu_shares

 

if this fails then I would start the lxc all over without docker and just do a standard Emby install or use the proxmox helper script that does everything for you (recommended)

 

Posted
51 minutes ago, guunter said:

You can try changing the group the group that is passed to the lxc. In the .conf I have this for the igpu

 

lxc.cgroup2.devices.allow: c 226:0 rwm
lxc.cgroup2.devices.allow: c 226:128 rwm
lxc.cgroup2.devices.allow: c 29:0 rwm
lxc.mount.entry: /dev/dri dev/dri none bind,optional,create=dir
lxc.mount.entry: /dev/dri/renderD128 dev/renderD128 none bind,optional,create=file
lxc.hook.pre-start: sh -c "chown 100000:111000 /dev/dri/renderD128"

and then in the lxc you need to create a new group.

if you have a privileged lxc

groupadd -g 111000 lxc_gpu_shares

If it’s a unprivileged lxc 

groupadd -g 11000 lxc_gpu_shares

And then you need to add the user Emby runs as to this group. In your case 0 is root.

gpasswd -a root lxc_gpu_shares

 

if this fails then I would start the lxc all over without docker and just do a standard Emby install or use the proxmox helper script that does everything for you (recommended)

 

Still no use. If you can't use docker to deploy, then what's the point of having a docker version of emby?

Where is the help script for proxmox ve? Can you give me a link?

Posted
9 minutes ago, xiaolulu said:

Still no use. If you can't use docker to deploy, then what's the point of having a docker version of emby?

Where is the help script for proxmox ve? Can you give me a link?

It's not the docker version of emby that is the issue... It's docker in an unpriv lxc container. Emby on docker would work fine in a regular vm.

On the PVE Host

bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/emby.sh)"

I recommend doing advanced install so you can set some options pre-install.

 

Posted
1 minute ago, guunter said:

It's not the docker version of emby that is the issue... It's docker in an unpriv lxc container. Emby on docker would work fine in a regular vm.

On the PVE Host

bash -c "$(wget -qLO - https://github.com/tteck/Proxmox/raw/main/ct/emby.sh)"

I recommend doing advanced install so you can set some options pre-install.

 

OK, I hope the official can solve the problem of using emby in lxc container.

Posted
19 minutes ago, xiaolulu said:

OK, I hope the official can solve the problem of using emby in lxc container.

Sure let me know how it goes.

Posted
2 minutes ago, guunter said:

Sure let me know how it goes.

I deployed emby directly under lxc and can see the hardware decoding option normally.

  • Like 1
Posted
3 hours ago, guunter said:

Sure let me know how it goes.

The problem reappeared. I rolled back the LXC snapshot, reinstalled emby, and the transcoding option disappeared again.

Posted
6 hours ago, xiaolulu said:

The problem reappeared. I rolled back the LXC snapshot, reinstalled emby, and the transcoding option disappeared again.

Is this the only lxc/vm running on your machine or did you passthrough the igpu to a vm? The script should work as long as you didn’t make any changes to the host. The script installs Emby in lxc and makes changes to the host so transcoding works. But if you made any changes to the host yourself it might mess up the igpu being able to be used by the lxc

  • Thanks 1
Posted
2 minutes ago, guunter said:

Is this the only lxc/vm running on your machine or did you passthrough the igpu to a vm? The script should work as long as you didn’t make any changes to the host. The script installs Emby in lxc and makes changes to the host so transcoding works. But if you made any changes to the host yourself it might mess up the igpu being able to be used by the lxc

Before the last success, I tried many settings on the host and LXC until it succeeded. After I rolled back the snapshot, I had forgotten which steps I had taken before.

 

Posted
1 hour ago, guunter said:

Is this the only lxc/vm running on your machine or did you passthrough the igpu to a vm? The script should work as long as you didn’t make any changes to the host. The script installs Emby in lxc and makes changes to the host so transcoding works. But if you made any changes to the host yourself it might mess up the igpu being able to be used by the lxc

Resolved

  • Like 1
  • Thanks 1

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