Frigate with MemryX on Proxmox LXC

Introduction

This guide is intended for Frigate users interested in integrating the MemryX detector into Proxmox-hosted Linux containers (LXCs). Follow along to create your LXC in Proxmox and enable passthrough for the MemryX detector.

Proxmox Host Setup

To begin, you will need to install the MemryX drivers on the Proxmox host. Please follow the instructions on the Developer Hub to install SDK 2.1 drivers until steps 1 through 6 have been completed.

Create a Privileged LXC

Use pct to create a privileged Ubuntu 24.04 LXC configured to your preference. The config file located at /etc/pve/lxc/<container_id>.conf will need to resemble the following:

In particular, to the config file, add the following lines:

mp0: /run/mxa_manager,mp=/mnt/mxa_manager,backup=0
lxc.cap.drop:
lxc.cgroup2.devices.allow: a
lxc.mount.entry: /dev/memx0 /dev/memx0 none bind,create=file,optional 0 0
lxc.mount.entry: /dev/memx0_feature /dev/memx0_feature none bind,create=file,optional 0 0

Enter the LXC and Verify Passthrough

Enter the LXC using pct enter <container_id> and verify that all MemryX mounts from the <container_id>.conf file on the Proxmox host are showing up. In particular, the below commands should return the following:

Next, you can create the following three directories and navigate to /opt/frigate:

mkdir -p /opt/frigate/config
mkdir -p /opt/frigate/media
mkdir -p /opt/frigate/cache
cd /opt/frigate

Create docker-compose.yml

Create the docker-compose.yml file as follows and paste the content that appears below:

nano docker-compose.yml

version: "3.9"

services:
  frigate:
    container_name: frigate
    image: ghcr.io/blakeblackshear/frigate:stable
    privileged: true
    restart: unless-stopped
    shm_size: "512mb"

    devices:
      - /dev/memx0:/dev/memx0

    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./config:/config
      - ./media:/media/frigate
      - ./cache:/tmp/cache
      - /mnt/mxa_manager:/run/mxa_manager

    ports:
      - "5000:5000"
      - "8971:8971"
      - "8554:8554"
      - "8555:8555/tcp"
      - "8555:8555/udp"

Create config/config.yml for Frigate

Next, you can create the Frigate config.yml file and paste the content below (of course, the cameras/model selection will have to be adjusted to your preferences):

nano config/config.yml

mqtt:
  enabled: false

detectors:
  memx0:
    type: memryx
    device: PCIe:0

model:
  model_type: yolo-generic
  width: 320
  height: 320
  input_tensor: nchw
  input_dtype: float
  labelmap_path: /labelmap/coco-80.txt

cameras:
   camera_1:
    ffmpeg:
      inputs:
        - path: 
            rtsp://your-camera-url
          roles:
            - detect
    detect:
      enabled: true
version: 0.17-0

Start the Frigate Docker Container

Start the container by running docker-compose up -d and verify things are working as expected with docker logs -f frigate. To stop the container and clean up its resources, run docker-compose down.

Final Thoughts

We hope this guide is helpful to the Frigate community. As always, we are here to help with any questions that may arise, and we would love to hear from you!

Thanks so much for the guide!

I notice that there are a few proxmox-specific quirks that are important to know when following the instructions on the Developer Hub to install the SDK 2.1 drivers on the host. Linux gurus would have no issue figuring it all out, but for those who just want to follow a guide and don’t really know what is happening, here are the important things:

First, you don’t use sudo with proxmox (unless you have something other than a default install). So remove “sudo” from all commands before you run them.

Next, on step 1, instead of running the command in the guide, run this command:

apt install proxmox-default-headers

Finally, when you get to step 3, replace the double-equal-signs with single equal signs. So the command will look like this:

apt install memx-drivers=2.1.1-1.1 memx-accl=2.1.2-1 mxa-manager=2.1.1-1

Aside from these listed items, you will follow the guide as written and this will install the drivers on the proxmox host! Don’t forget to reboot, as instructed in the guide.

Then you can follow @lindsay.morel 's guide to set up your privileged LXC with MemryX!

Here is a correction to this guide. You must remove these leading slashes or the pass-through won’t work

UNPRIVILEGED SUCCESS!
@lindsay.morel

Great news:

With a tiny adjustment, you can use this same guide to create an unprivileged container with MemryX!

Disclaimer: This information assumes that the ONLY device you are passing through from the host is the MemryX. If you are passing through any other devices such as your video card or render device, these instructions will likely not suffice. In my case, MemryX is the only device I’m passing through to the LXC.

Instead of adding the lines mentioned above to your LXC config file, add these lines instead:

mp0: /run/mxa_manager,mp=/mnt/mxa_manager
lxc.cgroup2.devices.allow: c 234:* rwm
lxc.cgroup2.devices.allow: c 235:* rwm
lxc.mount.entry: /dev/memx0 dev/memx0 none bind,create=file,optional 0 0
lxc.mount.entry: /dev/memx0_feature dev/memx0_feature none bind,create=file,optional 0 0

Note: The lines above with the numbers 234 and 235 may be different on your system. You should run this command on your HOST:

ls -alh /dev/memx*

You should see output like the following:
image

Simply substitute 234/235 with the numbers shown when you run this command.

Aside from this small change, you can follow the rest of the instructions in the guide to create your own UNPRIVILEGED Frigate LXC in Proxmox with your MemryX!

Have fun!