BrandonJoffe / home_surveillance

Home surveillance system with facial recognition
1.23k stars 385 forks source link

Couldn't run Docker image(bjoffe/openface_flask_v2) on Jetson nano board #69

Open SaddamBInSyed opened 4 years ago

SaddamBInSyed commented 4 years ago

HI. I have carefully followed the @BrandonJoffe instruction and its working fine with Ubuntu VM PC. But since I want t use GPU, I have tried to run the same onjetson nano, But I get the below error.

jetson-dl@jetsondl-desktop:~/projects/Programs/home_surveillance/system$ sudo docker run -v /home/:/host -p 5000:5000 -t -i bjoffe/openface_flask_v2 /bin/bash standard_init_linux.go:207: exec user process caused "exec format error"

if anyone solved this before please help me here.

SaddamBInSyed commented 4 years ago

@BrandonJoffe ,

I highly appreciated your helo on this.

paultbarrett commented 4 years ago

The Jetson Nano is an ARM CPU and I have a feeling that the reason there is an issue is because the docker container does not support this architecture and only works for x86 which is why your test in Ubuntu on your PC worked. Unless you port the container yourself I doubt you will get a working solution

domcross commented 4 years ago

Another Jetson Nano user here. @BrandonJoffe can you provide the Dockerfile? With that we can build a Arm64 compatible image. Thanks in advance.

domcross commented 4 years ago

Little success story - I modified a fork of this repo to run "dockerless" with Python3 on a Jetson Nano with following results:

My current problem: as soon as a person gets close enough to start the face-recognizer the application crashes. This is hard to debug as this is a os-call to th/torch (which is outdated) where some nested lua-files are executed. I will probably need to rewrite this part to use pytorch.

Any suggestions welcome!

pinging @SaddamBInSyed @paultbarrett as you probably are interested in this

(Note: My changes are not commited to my forked repo yet).

domcross commented 4 years ago

Update: successfully replaced the lua/torch dependencies with pytorch. Training works, face recognition basically works. Now there are some - hopefully minor - bugs in the Webapp waiting to be resolved.

Interesting observation: face recognition/inference for a single frame with GPU takes approx 3 seconds while the same operation on CPU only takes only 0.3 seconds. I have seen such behaviour in other application too: overhead of moving data to/from GPU memory is quite high on the Jetson Nano. For rather small tensors it is faster to do all computation on CPU. EDIT: In my previous tests I only used single image for inference. I modified my test routine to larger batches and now GPU shows much better performance - about 2-3x faster than CPU. Only the first batch item still takes longer on GPU - probably the model must be initialized first... And training of new images is now blazing fast with GPU.

inchix commented 4 years ago

Little success story - I modified a fork of this repo to run "dockerless" with Python3 on a Jetson Nano with following results:

* Flask WebApp works.

* RTSP-videostream of a IP-Camera is shown in the WebGUI.

* Object-detection works as well - rectangles are drawn around persons.

My current problem: as soon as a person gets close enough to start the face-recognizer the application crashes. This is hard to debug as this is a os-call to th/torch (which is outdated) where some nested lua-files are executed. I will probably need to rewrite this part to use pytorch.

Any suggestions welcome!

pinging @SaddamBInSyed @paultbarrett as you probably are interested in this

(Note: My changes are not commited to my forked repo yet).

I'm super interested also, i'm keen to see your updates :)

domcross commented 4 years ago

@SaddamBInSyed @inchix I have pushed a WIP version to my repo: https://github.com/domcross/home_surveillance - in case you are interested please follow me there - any comments/issues/pull requests are highly welcome...

domcross commented 4 years ago

Docker image for Jetson Nano available: domcross/home_surveillance_jetson - see my repo for details...

inchix commented 4 years ago

nice work - i've got it going quite well on an x86 for some testing using a different base image to the nvgc pytorch container and also altered the build for opencv. Brilliant stuff to be tinkering with during the lockdown :)

htilly commented 4 years ago

Docker image for Jetson Nano available: domcross/home_surveillance_jetson - see my repo for details...

@domcross Hi!

Trying to get this running on my Jetson but running into the following errors... After installing according to your guide I get the following problems:

docker run -v /config/:/host -p 5000:5000 -t -i domcross/home_surveillance_jetson /bin/bash

root@f11b745a6af3:/home_surveillance/system# python WebApp.py Traceback (most recent call last): File "WebApp.py", line 19, in from flask import Flask, render_template, Response, redirect, url_for, request, jsonify, send_file, session, g ImportError: No module named flask

And if I then try to install flask: root@f11b745a6af3:/home_surveillance/system# pip install flask Requirement already satisfied: flask in /usr/local/lib/python3.6/dist-packages (0.11.1) Requirement already satisfied: Jinja2>=2.4 in /usr/local/lib/python3.6/dist-packages (from flask) (2.11.1) Requirement already satisfied: click>=2.0 in /usr/local/lib/python3.6/dist-packages (from flask) (7.1.1) Requirement already satisfied: Werkzeug>=0.7 in /usr/local/lib/python3.6/dist-packages (from flask) (0.16.1) Requirement already satisfied: itsdangerous>=0.21 in /usr/local/lib/python3.6/dist-packages (from flask) (1.1.0) Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python3.6/dist-packages (from Jinja2>=2.4->flask) (1.1.1)

When running python3: root@f11b745a6af3:/home_surveillance/system# python3 WebApp.py /usr/local/lib/python3.6/dist-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.uploads is deprecated, use flask_uploads instead. .format(x=modname), ExtDeprecationWarning Segmentation fault (core dumped)

Any idea of how to get it running ?!

domcross commented 4 years ago

Unfortunately the current docker-image for Nano is broken. Improved Dockerfile and pre-build image will be released soon. Updates will be published in my repo: https://github.com/domcross/home_surveillance

htilly commented 4 years ago

@domcross any updates ?! ;)

corgan2222 commented 4 years ago

Docker image for Jetson Nano available: domcross/home_surveillance_jetson - see my repo for details...

@domcross Hi!

Trying to get this running on my Jetson but running into the following errors... After installing according to your guide I get the following problems:

docker run -v /config/:/host -p 5000:5000 -t -i domcross/home_surveillance_jetson /bin/bash

root@f11b745a6af3:/home_surveillance/system# python WebApp.py Traceback (most recent call last): File "WebApp.py", line 19, in from flask import Flask, render_template, Response, redirect, url_for, request, jsonify, send_file, session, g ImportError: No module named flask

And if I then try to install flask: root@f11b745a6af3:/home_surveillance/system# pip install flask Requirement already satisfied: flask in /usr/local/lib/python3.6/dist-packages (0.11.1) Requirement already satisfied: Jinja2>=2.4 in /usr/local/lib/python3.6/dist-packages (from flask) (2.11.1) Requirement already satisfied: click>=2.0 in /usr/local/lib/python3.6/dist-packages (from flask) (7.1.1) Requirement already satisfied: Werkzeug>=0.7 in /usr/local/lib/python3.6/dist-packages (from flask) (0.16.1) Requirement already satisfied: itsdangerous>=0.21 in /usr/local/lib/python3.6/dist-packages (from flask) (1.1.0) Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib/python3.6/dist-packages (from Jinja2>=2.4->flask) (1.1.1)

When running python3: root@f11b745a6af3:/home_surveillance/system# python3 WebApp.py /usr/local/lib/python3.6/dist-packages/flask/exthook.py:71: ExtDeprecationWarning: Importing flask.ext.uploads is deprecated, use flask_uploads instead. .format(x=modname), ExtDeprecationWarning Segmentation fault (core dumped)

Any idea of how to get it running ?!

I got the same errors on my Nano. No Idea how to fix this. @domcross is this here the right place to talk about your fork, cause i couldnt find an issue button on your fork?

domcross commented 4 years ago

@htilly the basics should work, nevertheless this still needs some cleanup and bug fixing. Didn't have the time to look at it in the last few weeks because life happens and needs attention in other areas, e.g. Corona pandemic.

@corgan2222 The Docker image is broken, don't try running it - its a waste of time. You might have better luck installing the dependencies and run the app from my cloned Github repo. You need to run with python3. Wasn't aware about the issue with the issue button - will look into it ;-)