-
-
Notifications
You must be signed in to change notification settings - Fork 316
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
Add ARM images to reallibrephotos dockerhub and integrate it in the CI process #59
Comments
Or even a light version. I don't mind so much about the face recognition. And I guess it is the main reason for the current ressource requirements. |
Somebody on discord already tried it a couple of times. I will create a channel with the current dockerfile, that already works for the backend. |
What is the reason this cannot run in ARM? Can someone who worked on it give a list of the challenges in porting? |
More discussions on this in the discord channel #arm-support https://discord.gg/Et88vTGF3m |
@guysoft Pinged! It is a feature many people want 👍 If you don't want to use discord, I can send the files from the user instead or open a pull request. |
Sure, joined the channel. |
The main issue for the Rpi support is that we are using miniconda as the package manager in python (no support planed for arm conda/conda#8297). I would recommend changing conda back to pip in order to support arm devices. Related: hooram/ownphotos#56 |
We now use python and pip. Could you take a look and try if it now works with arm: https://github.com/LibrePhotos/librephotos-docker ? |
I can take a look |
@derneuere I cloned the referenced repo on my Raspberry Pi 4 and used |
@jwillmer that error means you are trying to run an Intel/amd architecture on an ARM device. Its not the same instructions set (aka format). And it needs to be compiled for ARM. Rpi 4 uses arm64v8. That is what I am.planning to do.tomorrow, or when I have time this week. |
When I attempt to build the backend under ARM, I get this:
|
@radicand a pip could either compile or install a pre-built wheel. there is pytorch version 1.7.1 for arm, but it depends what version of python you have too. Also it depends which version of ARM you are building. I recommend arm64v8. Mainly because I think that you will need a minium of a 3B+ to run this, and both that and the Pi4 use that architecture. Will also mean you can run it on 8GB which might be needed. Update - seems like it has no aarch build. so trying to build from source. |
As a general update to this thread, I've been working over the past week on modifying the Dockerfile to support an arm64 build. I've gotten everything sorted except for faiss (like dlib also needs to be built from source), which I hope to have a resolution for soon. Torch has aarch64 wheels available, and some of the other heavier dependencies can be installed via conda (using miniforge3). I'll share back the working Dockerfile and test image when ready. |
BTW - I've been trying to build pytorch. It took a while because I am not sure how to build it in the Dockerfile an a way I like. Also I had to get a Pi 4 with 4GB to build it. Its still building. @mgrove36 Does using miniforge3 have any downsides? I am not sure what the toolchain is. |
I've built and pushed the frontend and backend as FROM ubuntu:hirsute AS base
ENV DEBIAN_FRONTEND=noninteractive
ENV CONDA_DIR=/opt/conda
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
ENV PATH=${CONDA_DIR}/bin:${PATH}
# system packages installation
RUN apt update && apt install -y ca-certificates curl libopenblas-dev libmagic1 libboost-all-dev libxrender-dev liblapack-dev git bzip2 cmake build-essential libsm6 libglib2.0-0 libgl1-mesa-glx libheif-dev libffi-dev swig --no-install-recommends
# pre trained models download
WORKDIR /data_models
RUN mkdir -p /data_models/places365/ && \
mkdir -p /data_models/im2txt/ && \
mkdir -p /root/.cache/torch/hub/checkpoints/
RUN curl -SL https://s3.eu-central-1.amazonaws.com/ownphotos-deploy/places365_model.tar.gz | tar -zxC /data_models/places365/
RUN curl -SL https://s3.eu-central-1.amazonaws.com/ownphotos-deploy/im2txt_model.tar.gz | tar -zxC /data_models/im2txt/
RUN curl -SL https://s3.eu-central-1.amazonaws.com/ownphotos-deploy/im2txt_data.tar.gz | tar -zxC /data_models/im2txt/
RUN curl -SL https://download.pytorch.org/models/resnet152-b121ed2d.pth -o /root/.cache/torch/hub/checkpoints/resnet152-b121ed2d.pth
RUN mkdir -p /opt/conda && \
curl -SL https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh -o ${CONDA_DIR}/miniforge.sh && \
bash ${CONDA_DIR}/miniforge.sh -b -u -p ${CONDA_DIR} && \
rm ${CONDA_DIR}/miniforge.sh
RUN bash -c "case \"`uname -m`\" in \"x86_64\") pip install torch==1.7.1+cpu torchvision==0.8.2+cpu -f https://download.pytorch.org/whl/torch_stable.html;; \"aarch64\") pip install torch==1.7.1 torchvision==0.8.2 -f https://torch.maku.ml/whl/stable.html;; esac"
RUN conda install -y numpy psycopg2 cython pandas scikit-learn=0.24.1 scikit-image=0.18.1 spacy=2.3.5 gevent=20.12.1 matplotlib=3.3.2
RUN pip install -v --install-option="--no" --install-option="DLIB_USE_CUDA" --install-option="--no" --install-option="USE_AVX_INSTRUCTIONS" --install-option="--no" --install-option="USE_SSE4_INSTRUCTIONS" dlib
# actual project
ARG DEBUG
WORKDIR /code
RUN git clone https://github.com/LibrePhotos/librephotos .
WORKDIR /faiss
RUN git clone https://github.com/facebookresearch/faiss.git /faiss
RUN cmake -B build . -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=ON -DFAISS_OPT_LEVEL=generic
RUN make -C build -j faiss
RUN make -C build -j swigfaiss
RUN (cd build/faiss/python && python setup.py install)
WORKDIR /code
RUN sed -i "s/spacy==2.3.2/spacy==2.3.5/" requirements.txt && \
sed -i "s/sklearn==0.0/scikit-learn==0.24.1/" requirements.txt && \
sed -i "s/gevent==20.9.0/gevent==20.12.1/" requirements.txt && \
sed -i "s/dlib==19.21.1/dlib>=19.21.0/" requirements.txt && \
sed -i "s/scipy==1.5.3/scipy==1.6.0/" requirements.txt && \
sed -i "s/pytz==2020.1/pytz>=2021.1/" requirements.txt && \
sed -i "s/faiss-cpu==1.7.0/faiss>=1.7.0/" requirements.txt && \
pip install -r requirements.txt
RUN if [ "$DEBUG" = 1 ] ; then pip install -r requirements.dev.txt ; fi
RUN python -m spacy download en_core_web_sm
EXPOSE 8001
COPY entrypoint.sh /entrypoint.sh
CMD ["/entrypoint.sh"]
|
that with radicand/librephotos-proxy-arm:test as proxy meanwhile i found in 1 of the logs: tested on Rp4 8gb with Kali for pi |
Got pytorch built for arm64/aarch64. Result and build sources/instructions available here: |
Quick update, I've made good progress here and have working containers created on my DockerHub repo (referenced above). New images are using the "latest" tag. I also got dlib built as a conda package, and it massively speeds up the container build process now. FAISS still needs to be compiled from scratch, but doesn't take super long. I'll be working on bringing these updates in and seeing if we can get a good multiarch image now. |
Got stuck here on getting faiss-cpu to work. There is only faiss-dev on Debian sid (we are using the python3.8 container for now, which is Debian), but then the pip install does not find the headers. I think it might be needed to compile it for it to work on the current image without conda. I did get pytorch, torchvision and bils compiled, so I think its the last thing. |
@guysoft Could you share your dockerfile? I have to create a dockerfile for legacy systems (no SSE or AVX support) and also have to build pytorch and torchvision from source for these systems. |
Hey, just saw now. |
This is now implemented. |
Neat - should I make a RaspberryPi distro that you flash, attach a drive, and it loads ownphotos right from it? |
Yes, but we currently have a problem with faiss. There is a compilation error 😅 Once it gets fixed upstream or when I find a workaround, then it should work again. facebookresearch/faiss#1979 |
…and-ts-eslint-rules separate js and es lint rules
Can we have a list of things because of which this project cannot run on Rpis. Maybe we can work towards making replacing them with something better.
The text was updated successfully, but these errors were encountered: