Unleash your Home Cameras with FRIGATE Self-Hosted AI Video Recorder! Install on Proxmox LXC

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so if you have security cameras at your house and you're into locally hosted home automation and security you should check out frig the op Source Network video recorder designed to integrate with home assistant I know home security cameras are all the rage now but you really probably don't want something Cloud connected sending all your data up to Google or Amazon or whatever you probably want to keep that data local on your own and fr will help you do that at the same time fr's going to help you do AI oner images to find things like people and cats and cars and trucks and all kinds of other stuff and you can write home automation rules based on how many people are in your image how many cats that kind of stuff and that's really useful in home automation setting so whether you just want to record your cameras to see if your neighbor Patrick has been texting and driving his way into your mailbox again or you want to see your cat get in a fight with a neighborhood cat under your car or like me you want to count how many people are on your back deck so you know if you should turn the lights on or not frig will help you with all of that so today I'm going to set up frig on a proxmox server and not only am I going to set up frig I'm going to use an lxc container for maximum efficiency I'm going to Hardware pass through my graphics card for video decoding and I'm also going to Hardware pass through my Coral TPU for AI detection and all of those things require some more advanced configuration so come along with me on this adventure so to start this project I'm going to create a new lxc container now I know that FR is a Docker container but I'm going to run frig's Docker container inside lxc for management purposes so let's get on that so I'm going to start off here by creating a CT this is going to be number 100 and we're going to call it Corona Corona is the name of uh a satellite that spies on people so I'm going to make it privileged and we're going to need to make sure we enable nesting and we'll give it a password I'm making it privileged so that I can pass through my Hardware Coral TPU accelerator if you don't have a TPU and you're not doing like video encoding with your GPU unprivileged is fine so here for template we're going to pick deian 12 standard so I'm going to put my system drive on ZFS that's my nvme storage this is just the operating system now I'm going to add another Mount point for my videos this is going to be on my data drive and I we'll make it th000 gigs not going to back this one up we're going to put it at VAR far frot CPU cores I don't know two and memory I don't know 20 48 seems reasonable Network I'm going to just use defaults and let's go now before we start the container we need to change some settings that weren't available to us in the Wizard so we are an unprivileged container we're going to go here features we're enable nesting we're enable fuse and we we can go ahead and start it so next step now that we have our container is we need to do updates on the container but also because I don't really like Docker as some of you may know from other videos we're going to use a technology called podman quad and what qulet does is it lets us manage Docker containers or oci containers using systemd so we can write systemd unit files as we normally would for a service and it will manage the container on the back end automatically with podman and it will use the system control journal and all of our noral Linux system utilities that we've come to know and love but to use quad we need at least version 4.4 of podman and that is not included with debban Bookworm it says 4.3 so I'm going to upgrade from Bookworm to Trixie which is the testing release if Trixie is already out you can just use Trixie but so here let's uh upgrade to Trixie and do a full upgrade of all the packages so just copy this command here so what this does is it replaces the word Bookworm with the word Trixie in sources.list and then we update it's not exactly the uh quickest update I mean we're updating distributions so it's there's some stuff to update here perfect now we can set up frig so now the container's ready let's install frig at this point you're going to need a FR config.yml and uh I'm not the expert on writing those config.yml but the frig website has some information on that if you want to read my own config down at the bottom link to the blog post that has my config if you want to read it with some password strip out and stuff so assuming you have a config yaml next up we're going to create the container so the really cool thing about quad is we just create these container files and they have the same syntax as a systemd unit and they automatically turn into podman containers so let's edit this file and then I'm just going to copy this right in there of course blog post has the example feel free to copy it so this file here has a number of things going on so it's a systemd unit and this container section is what podman manages so you can use system D syntax you can add your own system D stuff as you normally would and you can also add the container config and down here at the bottom we have the image so foret stable I've also set up to use host networking for this container because Docker networks cause a lot of problems especially when you're trying to mix Docker and non Docker networking they will completely stomp over all of your IP tables and stuff so we don't want that to happen also in general ipv4 support in Docker is very poor and I don't want to have to deal with that because IPv6 is the future so because all my cameras use IPv6 I need them to be able to get access from FR so I need an IPv6 address and using host networking insurance I can set that up and yeah that's pretty much it so we'll save that so last up we system control game and reload and then we should be able to start frig now the very first time you start the service it's going to take forever because system D is pulling down all the docker files in the background as it starts the service that's why part of the command gives it uh 15 minutes to start up which is a long time after that it shouldn't take as long it'll automatically update in the background as well which is nice so foret is up and running a careful Observer will note I am connected via an IP version 4 address and that is because frig is dumb so if we check what ports are currently bound on the container so this is a list of all of the port bindings so you can see we have some stuff in the system and so 1935 that's the API Port that's bound to 0.0.0.0 it should be bound to colon colon or a star but because it's bound to 0.0.0.0 it's bound to only ipv4 addresses we come in here the web port 5,000 same problem which is uh pretty unfortunate these guys here the RTP ports those are just fine the RT yeah rtsp ports it's just the port 5000 we have a problem with here really the real problem here is that frig in bundling their software also bundle engine X and also bundle a config for engine X that we can't really change easily and that config is not very good so if we would like to use TLS or things like that we could just add them to the engine next it's already running but no it's Docker so we have to have two engine X's or a cad and engine X so I'm going to set up caddy to proxy this so here I got the instructions we need to install caddy so we can come over here paste those in have fun so well that's installing here's the caddy file we're going to use it's pretty simple I just have the domain name reverse proxy import 5000 and we're going to use TLS internal you can of course use lets en Crypt certificates or do your own thing or you can just put in a port number if you don't want want to do a domain name whatever it's a simple caddy file so now we're just going to remove the caddy file and write around now we can start caddy there we go self sign certificate usual stuff there we go so now we fixed the TLs problem and the unst standard Port problem a frot now it's a proper service like it should be so as a final thing I have a coral TPU and I showed in another video link up there the card for that where I installed it in my Mini Server so we're going to try to get that up and running since we're in an lxc container things are a bit tricky because drivers in the kernel need to run on the host kernel which is proxmox so in this case we have to get the driver for the pcie device and get that installed on the proxmox host once we do that and the driver loads we can pass that device on through to the privileged container and then from there we can pass it through in podman to the fre container so let's come over here to the proxmox host and install the driver for the coral TPU so they have documentation here on how to do it and basically they've packaged deban packages for Debian we can use all we really need is gasket dkms so dkms is dynamic kernel module support essentially allows you to dynamically build a kernel module for your kernel on the system so when you install a dkms module every time you download a new kernel it'll rebuild the kernel modules in dkms so that they work with your new kernel we actually don't need lib Edge TPU because we're not actually running software proxmox we just need the kernel module to load so I have a script here that does that on my website you can copy that we come over here we're not going to be in the container we're going to go to the main proxmox system and run it there so let's go ahead with that so as you might have noticed it's going to install a lot of stuff one of the thing it has to install is dkms but it also has to install all the kernel headers for whatever version of proxmox you're running also every single time you update proxmox it's going to recompile this kernel module just so you're aware of that that's how it's supposed to be so slight chance during this step you'll get a kernel headers error if you get that error it's very important that you update proxmox to the latest version then install PVE headers if you install PVE headers without updating the latest version you'll have a newer version of headers and older kernel so update install PV headers instructions in the blog post on how to do that if you didn't get any errors from dkms we should be able to just mod probe Apex that should bring up the Apex driver we should see a new Apex device and sure enough Apex zero so now that Apex shows up we can pass that Apex device on into our container so we need to open up the config file from proxmox and this means the container needs to be not running we need to stop the container so come here to the container and shut down down I'm going to go here here's what we have to add to the container so it's going to pass this Dev Apex zero and also give it permissions to those type of devices and the file is SC PVE lxc and then your container id.com so in the proxmox Shell here on the system and my my case container is at 100 100. conf go to the bottom and paste that in then we can restart the container once we've passed that through the container we can just make sure it showed up sure enough we have Apex right there so now we need to add that device to the frig container and so this is our line so we're going to edit the systemd unit file from earlier where our container is and we're come down to the container section I guess we go to the bottom doesn't really matter and we'll paste in the new changes so add device Apex zero whenever we change this file we have to run system control Damon reload to reload the units and we restart the container then it should be back up and running and last but not least we add that detector to the FR config so we can use it once again I got the contents here this is the yaml so you come over here paste it into the yaml and then we save and restart so here in frig we got coral one and it is working excellent that's exactly what we needed so another neat trick we can do in Frick is we can pass through our GPU to The Container so we can use the graphics card to decode the video it's getting from the cameras as we can see over here FFM Peg for each of these guys is using like 20% of our CPU each well some of them are some doing more than others but um yeah it's doing some stuff so what we'd really like is for the graphics card to be doing this work so let's pass that on through so over here again we need to edit the lxc config and because we need to edit the lxc config we need to stop the LXE so we're going to shut you down so while that shuts down I'm going to come over here to the shell and LS D so in my case I only have one graphics card so it's render d128 if you have more than one graphics card you will have to figure out which render node you need to use for the correct card so now that we know it's d128 we're going to edit the container config file and add these lines the end let's go down to the bottom and we add these guys so we're going to allow this type of group which is the render node and we're going to pass render d128 into the container and then we can restart the container so now that we got the container rebooted let's make sure our device shows up and sure does enter d128 so now we need to edit the podman config for this container to add the device node and some extra capabilities so that's the file we've been editing all day and here are the lines we need to to add these guys here from my blog same container file we've been using let's edit it and we're going to add to the container section here so I'm going to go down to the bottom of the container section so here's where we have ADD device and let's just paste this in so this does a couple things so first we add the render node so devd render d128 depending on what Drive you're using you may have to add this environment variable down here lip vaa driver name you might not try it without it um and if that doesn't work you can try UNC combining one of these it depends a little bit on what Drive you're using and if VA info understands it or whatever um if you're doing Nvidia not helping you at all Nvidia has made a complete mess of containers trying to monetize it so sorry about that if you're using a graphics card with open source drivers such as Intel or AMD it should work like this every time we save that file we have to Dam and reload so we do that and then and we will restart frig that'll restart our container with the new config and we can go from there so frig has VA info built in so we can click on a button and fr to VA info that'll tell us if we've passed everything through correctly and then we can start enabling things in the freak config so here we're going to system it says Hardware not Excel has not been set up so we click VA info and it loaded the ihd driver and it shows all these entry points which is great so next up we need to add an ffmpeg entry to our FR config um if you're using Intel Quicks sync video you have to know if your camera is are h264 or h265 if you're using uh AMD you just use VA API so here's the Fret config little bit here and I'm going to come over to frig and go to my config and we'll paste that in paste save and restart if you have any issues by the way fret has a page on this on how to configure your config.yml and you might have to reference it a little bit so fet came up we get this a lay here there was an arrogating usage stats but if I scroll down I see CPU usage is down across the board from 20% and uh that's probably a good thing so to verify that the GPU is working we need a tool that can monitor our GPU load and if you have a AMD card that's called radon top if you have an Intel card it's called Intel GPU top so I got a little note here so you either install apt install um Intel GPU tools or radi on top and then the executable is called Intel GPU top so over here I'm running it and it has found the video is doing some work also if you have a really new Intel GPU you might have to enable the guck little uh blurb on the blog post about that so good luck so hopefully by this point your setup is working as well as mine feel free to read the guide link down in the description below has all of the commands I've been copying and pasting there's some additional notes and additional quirks and stuff like that if anyone wants to message me with quirks of their setup I can make sure to add them if you're using Hardware I'm not using or things like that um I don't have a USB Coral TPU to test that's why I use the pcie ones that I have but if someone wants to send me a USB one I would love to test that and add it to the guide as well um what else so frig has a whole guide on configuring frig itself mostly I was trying here to configure frig in prox MOX with podman and all that kind of stuff but the actual config yaml for frig has quite a lot of documentation on itself so feel free to read that link in the description below for that as well if you'd like to make a donation or support me monetarily you can head on to my Kofi link for that as well anything's appreciated it really helps out I also have a Discord server link down below for that if you want to chat with me about this or anything else and as always I'll see you guys on the next adventure
Info
Channel: apalrd's adventures
Views: 32,583
Rating: undefined out of 5
Keywords:
Id: sCkswrK0G3I
Channel Id: undefined
Length: 19min 5sec (1145 seconds)
Published: Thu Nov 09 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.