New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SIngle Container version of Compreface #651
Comments
|
I don't think that running CompreFace in one image is a good idea. I haven't used HA, but I see that it has another thing - integrations. In this case, you have to run CompreFace himself, but there is still an integration with HA. Will it work for you? |
|
I agree with you, but in order to use CompreFace as an addon in HassOS, we need a single container, it's a pre-requirement in order to have a supported addon in the HA environment. And I'm not asking this just for myself, there are literally hundreds of users that are using Double Take + Frigate to do face recognition automation, and unfortunately they are forced to use DeepStack now because it's the only addon available, while advanced users are installing CompreFace manually, even if HA doesn't support it, because of its superior recognition capabilities. We are recommending users to use CompreFace but the feedback is that it's too hard to install. So we need to develop the addon to install it directly in HA, like it has been done for DeepStack. It's a pity these users have to revert to an inferior solution like DeepStack, they deserve CompreFace, I hope you can understand this and help us reach the objective. As you can see here, DoubleTake is the only addon that @jakowenko has been able to implement, we are waiting for a single container version of CompreFace now so users can have the better choice.
CompreFace addon will be used as an engine by the Double Take addon, right now we are using CompreFace in an unsupported way manually installing it into HA's docker. Once installed, Double Take gets the snapshots from Frigate, and passes them to CompreFace for recognition, then it processes the result and creates HA sensors to do the automations. It's working beautifully but this kind of setup is unsupported unfortunately so users are reverting to DeepStack. :( Thanks for your reply and I hope you can deliver the single container version as soon as possible. :) |
|
I second this also for the Unraid community. It would be ideal to have it in a single container that can pulled from the App store template. Currently it's a steep learning curve and requires the "compose.manager" plugin to work. So the majority of users will default to deepstack with reportedly poor recognition performance when pairing frigate with double take for facial recognition on rtsp feeds. |
That's the main problem we're facing now for the Double Take project: 90% of support questions are for Deepstack installation and poor recognition rate. We need to switch them to CompreFace, but we need a single container version to be able to do that. I hope @pospielov can give us an idea of the time frame for this version to be available... |
|
I am working on it right now and already have the first working version. There are still some problems. In an optimistic scenario, I'll publish it this week and write a short description of how to run it here. Normal readme I'll write a little bit later. |
Amazing news Pospielov. Thank you so much. Users will be happy to switch from DeepStack to CompreFace, like we suggested. Please let me know when it's ready so we can test it. Thank you. |
Thank you. A lot of Unraid users have an Nvidia GPU for containers like plex so if you could include a method to pass extra parameters for the GPU custom builds also that would be ideal. Again thank you for your effort and time. |
|
Thanks for the work on this. We greatly appreciate it and look forward to the end result. |
Awesome, that's great News! I have written the unraid docker templates for double-take and facebox, but because unraid did not support docker-compose the users are stuck to a command-line installation of compreface, which isn't ideal for the average user. As @bigbangus mentioned, if you could add support for GPU processing, it would be awesome, but not mandatory. |
|
Hi all, it looks like I managed to make a single image of CompreFace
|
|
Pospielov, thank you so much, we will test and let you know in case of problems. @jakowenko will try to build an addon for Home Assistant out of this. |
|
Thanks. I'll test once an unRAID app template is done. I look forward to that. 😀 |
|
Awesome! Will test this on Unraid! |
|
@corgan2222 in my example I used named volume: When you set the exact folder to mount, docker created a bind mounts: So I would follow docker recommendations and use named volumes. In case this is impossible or you still prefer using binding to a folder, there is a workaround for such case if you still want to mount the exact folder into the docker container: And then use it as named volume during start: |
|
@pospielov Thanks for clarification, now the behavior make sense. We as App's Maintainer create only XML Templates. The Unraid GUI then creates the Docker Containers. GUI View: I'm not that deep into the Unraid Docker System. Do you have an Idea left, or should I forward this to the Unraid DEvs? |
|
What if you in |
|
Not sure if this helps regarding mounted volumes, but I'm running compreface now in Unraid with the modifications to docker-compose.yml below and it works fine. (not using app templates, but docker compose plugin) @pospielov are you after performance when you decided to use a named volume instead of a bind mount? |
|
@bigbangus CompreFace uses named volumes by default because this is the only way it can work for everyone. Of course, experienced users can change it if they want. Also, your docker-compose file adds even more questions. So you also use bind mounts. But in your case docker copied image content into the folder. I don't know why - probably docker-compose does something similar to what I showed as a workaround. Still, as I understand, the problem is that Unraid doesn't support it. |
Yes, that's also for me the main point. @bigbangus: the reason for this ticket and @pospielov work with a single container was to bring compreface to more users. I think only a few users would install docker.compose on the command line. |
Yes 100% agree. It should be in a single container to reach a greater audience. I was just trying to show it works with binding when using docker compose so why can't it work that way with templates in Unraid. What's the actual problem? |
|
@corgan2222 Please contact Unraid team, ask what workaround they see in this case. I think this is not the first time somebody face this problem. |
|
Thank you so much @pospielov for getting this single container version working. With the help of @bentasker and @alexdelprete we got the Home Assistant add-on working with persistent storage! I'm going to let the HA community know as well which should help drive traffic towards CompreFace. |
One month ago I told you we needed the CompreFace addon so users could have the best solution (I hate DeepStack). I started this thread, and here we are...sometimes magic happens. Thanks to @pospielov and @bentasker. :) |
|
@pospielov a question: the addon is working fine, but some users let us notice that the addon is allocating 3-4GB of RAM at startup without releasing it. @bentasker that helped us creating the addon confirmed it's a java config setting. I checked in the container info and found this: here's the allocated ram: and we found these configuration env. variables: we were wondering if we could modify please take into account that on average Home Assistant users are not running on very powerful systems with tons of RAM, so this might be a problem for an 8GB system with other apps/addons running. I hope we can fine tune the memory requirement. Thanks for any suggestion. Tagging also @jakowenko so we're all aligned. |
|
@jakowenko I have one favor to ask, could you rename CompreFace to Exadel CompreFace in your addon? |
|
@alexdelprete Java caches in memory embedding for each subject example. In my experience, 50 000 examples need about 8Gb of RAM. So I think you can reduce this number. Java consumes all the memory it sees, but garbage collector is quite effective and we tested CompreFace for memory leaks, looks like everything ok. |
|
@corgan2222 Any news from Unraid? |
I tested with Postgres 11.5 and Postgres 13.5. Both worked fine. |
|
Thank you Pospielov, so now we have the base image without the named volume and using a variable the user can decide if he wants to use the internal postgres or the external one. In case he wants to use the internal one, a volume has to be created, right? We'll have to provide some instructions regarding this in the addon readme. Thanks a lot for making all this possible. |
It can work without volume, but then the user will lose all the data if he deletes the volume |
Obviously we'll recommend creating a persistent storage for data, so the creation of a volume. |
|
@pospielov the tag So with a docker-compose like this I would have a single image version of Compreface MobileNet version, with an external Postgres (they have to manually create an empty db, and the user/pw), and optimized regarding java memory requirements correct? version: '3.4'
services:
compreface:
image: exadel/compreface:0.6.1-mobilenet
restart: unless-stopped
container_name: "compreface"
ports:
- "8000:80"
environment:
- POSTGRES_USER=compreface
- POSTGRES_PASSWORD=password
- POSTGRES_DB=comprefacedb
- POSTGRES_URL=jdbc:postgresql://postgres.mydomain.lan:5432/comprefacedb
- EXTERNAL_DB=true
- API_JAVA_OPTS=-Xmx1g
- ADMIN_JAVA_OPTS=-Xmx1g |
|
yes, correct |
|
Thanks for confirming. Docs are very well written. I tried spinning up the single container version on a small debian server, a virtual machine on proxmox: I assigned 15GB of storage space, and during startup it went out of space. So I gave it 50GB, and restarted: it went up to 48GB, but it was running. :( Is it normal? Why is it taking up so much space? The DB was external, my central postgres server. |
|
I created a new LXC container on Proxmox, 20GB of space, Debian 11, updated with latest patches: 700MB more or less before the setup of Compreface. Docker-compose has just completed this: version: '3.4'
services:
compreface:
image: exadel/compreface:0.6.1-mobilenet
restart: unless-stopped
container_name: "compreface"
ports:
- "8000:80"
environment:
- POSTGRES_USER=compreface
- POSTGRES_PASSWORD=password
- POSTGRES_URL=jdbc:postgresql://postgres.mydomain.lan:5432/comprefacedb
- EXTERNAL_DB=true
- API_JAVA_OPTS=-Xmx1g
- ADMIN_JAVA_OPTS=-Xmx1gAnd this is the ending result of the setup: During the setup I had to enlarge the disk 4 times, up to 40GB. :( Here are the requested commands' outputs, and it seems you're right, but Proxmox is telling me that almost 38GB have been used after the setup. This is one of the reasons why I don't like docker...too much magic happening in the backstage. :) |
|
Maybe @bentasker can shed some light about this... |
|
I digged into it a little bit, looking for the top 5 folders by size: The beast is vfs/dir, top 5 in there: Checked one of them: Checked another one, looks the same...I guess they're all the same... |
|
I wanted to see what is inside this directory on my machine and I didn't find it.
It looks like this storage driver uses disk space in a very non-optimal way. Here is from docker documentation:
Not sure why it is chosen on your docker version |
Sorry, been busy. @pospielov is correct, this is because your docker instance is using VFS, it's quite inefficient compared to Overlay(2). VFS gets used on a variety of devices/environments though because it's robust and supported (more or less) everywhere. But, @pospielov, the image does use a lot of layers, can I suggest removing some of those? In the dockerfile rather than having lots of As a particular example You'll have 4 layers here, the first 3 of which will contain all of If instead you do Then you'll have a single layer, and That way VFS users won't see massive storage usage. |
|
Hi @bentasker / @pospielov, I just finished migrating all my physical servers to a central proxmox server. I'm using mainly LXC containers to optimize resource usage. The LXC container I used for Compreface is a clean and minimal Debian 11, headless, only openssh+docker+compose plugin. After the container went up, I used compose to spin up the service using this: version: '3.4'
services:
compreface:
image: exadel/compreface:0.6.1-mobilenet
restart: unless-stopped
container_name: "compreface"
ports:
- "8000:80"
environment:
- POSTGRES_USER=compreface
- POSTGRES_PASSWORD=password
- POSTGRES_URL=jdbc:postgresql://postgres.mydomain.lan:5432/comprefacedb
- EXTERNAL_DB=true
- API_JAVA_OPTS=-Xmx1g
- ADMIN_JAVA_OPTS=-Xmx1gAs soon as it starts unpacking, I noticed the storage being consumed very very fast, and the process interrupted several times with out of disk errors. So I had to expand it 4 times, adding 5GB each time, reaching 40GB, only to complete the installation process. I didn't configure Docker specifying VFS, and the installation of docker was made with their official procedure. I'm no docker fan nor docker expert, where should I check for VFS config, and modify it with overlay2? Is it something that has to be done at docker's config level or in the compose file? Thanks for the help. |
|
It's configured at the docker level, so has a system wide effect, there are docs here - https://docs.docker.com/storage/storagedriver/overlayfs-driver/ It doesn't sound like there is in this case, but it's a little more a pain if you've got existing/other containers you want to preserve (as you start having to copy stuff about). I've never tried it within a LXC container though |
|
I've installed a central Docker LXC container with 15 services on it, and it's occupying very little space and also memory, very happy about it. I think it doesn't make sense to redo everything again, as it depends on how the specific docker service is built. Probably those 15 I installed are pretty simple and I don't notice the effect I had with Compreface. Strange thing is that I now started a Debian 11 virtual machine, and installed Compreface on it with no issue, because it's using overlay2 in there. Problem is that the VM consumes a lot of resources respect to the LXC container. Thanks for all the explanations Ben, lot to learn about these things...and I'm just starting, because I never really liked Docker...maybe I'll start taking a look at Podman, they told me there's less overhead there...and it should be compatible with docker configs and compose files. |
|
@alexdelprete Looks like this is a common problem with proxmox LXC and docker: @bentasker This dockerfile was created in such a non-optimal way to simplify its support. It consists of parts of original dockerfiles. If I optimize it, it will be harder to update it if we update another docker files. But I believe it won't help. As alexdelprete does not build CompreFace in his servers, he just uses it. |
I found out that when using ZFS, and you install docker in a LXC container, docker will revert to VFS for compatibility issues with overlay2 and ZFS. :( Now I created a VM to bypass the issue, so in there overlay2 is the default and Compreface installs correctly. :) The only problem is that the mobilenet version didn't work correctly, gave me a lot of errors, couldn't even create a new app/service after the login. So I reverted to |
but in the single-image version, it could actually be optimized since it's not the typical one that will be built, right? Thanks for the links, the 2nd one https://forum.proxmox.com/threads/docker-lxc-unprivileged-container-on-proxmox-7-with-zfs.99796/ looks quite promising to bypass the problem, I'll test it. Thanks. |
|
@bentasker solved it with the fuse-overlayfs driver in the container: it's compatible with ZFS. Credit to this guide. Now I have a container which is the main docker system, that manages 12 containers, and it's on VFS. :( I wonder if I can change its driver and restart it without much hassle...hope I don't have to redo everything from scratch. What do you think Ben? |
|
any documentation on main branch for this case ? it is great to have only one container for people working on some functionalities and allow only one container... |
|
https://github.com/exadel-inc/CompreFace/blob/master/docs/Installation-options.md#single-docker-container |
|
Since the 1.10 update, I haven't been able to get this to install through Home Assistant. Last error was |
|
Do you build it from scratch or use the published image? I also don't get at what stage you have this error, as I don't recall us installing or use anywhere |
|
Has anyone used CompreFace with postgres 14? |
|
Hi! Jose |
|
I have a reasonably stable install using the HA addon, but wanted to take the workload off that and put it on my unraid server. Starting from scratch with a clean install i am having issues where after some time (usually after interacting with deleting traned images or similar) something breaks and compreface cannot be recovered. |
|
This is the worst thing about the Single Container version. It's hard to check what is wrong. |
If you removing it from HA then I'd just use standard install process as you're no longer limited to just 1 container |











Is your feature request related to a problem? Please describe.
We're using Compreface as the recog engine of Double Take (an Home Assistant addon): https://github.com/jakowenko/double-take
Double Take dev (@jakowenko) created the addons for Double Take and other recognition frameworks: DeepStack and Facebox, but our preferred solution is Compreface. Unfortunately we can only build an addon starting from a single container, while Compreface requires five separate containers, unlike DeepStack and Facebox.
Describe the solution you'd like
A single-container build of Compreface, so we can create an Home Assistant addon for Double Take users, that right now are using DeepStack only because there's an addon available, while we recommend Compreface for best recognition results.
The text was updated successfully, but these errors were encountered: