diff --git a/librephotos.sh b/librephotos.sh index 8004c92..c41040a 100644 --- a/librephotos.sh +++ b/librephotos.sh @@ -4,16 +4,10 @@ set -ex -apt -y install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget libbz2-dev liblzma-dev - -wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz -O - | tar -Jx -C /usr/src/ -cd /usr/src/Python-3.8.2/ -./configure --enable-optimizations -make -j 8 -make altinstall - apt install --no-install-recommends -y \ -swig libpq-dev postgresql-common curl libopenblas-dev libmagic1 libboost-all-dev libxrender-dev liblapack-dev git bzip2 cmake build-essential libsm6 libglib2.0-0 libgl1-mesa-glx gfortran gunicorn libheif-dev libssl-dev rustc liblzma-dev +swig libpq-dev postgresql-common curl libopenblas-dev libmagic1 libboost-all-dev libxrender-dev \ +liblapack-dev git bzip2 cmake build-essential libsm6 libglib2.0-0 libgl1-mesa-glx gfortran gunicorn \ +libheif-dev libssl-dev rustc liblzma-dev python3 python3-pip mkdir -p /data_models/places365/ mkdir -p /data_models/im2txt/ @@ -23,17 +17,16 @@ curl -SL https://s3.eu-central-1.amazonaws.com/ownphotos-deploy/im2txt_model.tar curl -SL https://s3.eu-central-1.amazonaws.com/ownphotos-deploy/im2txt_data.tar.gz | tar -zxC /data_models/im2txt/ curl -SL https://download.pytorch.org/models/resnet152-b121ed2d.pth -o /root/.cache/torch/hub/checkpoints/resnet152-b121ed2d.pth -/usr/local/bin/pip3.8 install pip --upgrade -/usr/local/bin/pip3.8 install psycopg2 -/usr/local/bin/pip3.8 install wheel -/usr/local/bin/pip3.8 install torch==1.7.1+cpu torchvision==0.8.2+cpu -f https://download.pytorch.org/whl/torch_stable.html -/usr/local/bin/pip3.8 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 + +pip3 install torch==1.7.1+cpu torchvision==0.8.2+cpu -f https://download.pytorch.org/whl/torch_stable.html +pip3 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 cd /usr/src git clone https://github.com/LibrePhotos/librephotos cd librephotos -/usr/local/bin/pip3.8 install -r requirements.txt -/usr/local/bin/python3.8 -m spacy download en_core_web_sm +sed 's/geopy==1.11.0/geopy==2.1.0/' -i requirements.txt +pip3 install -r requirements.txt +python3 -m spacy download en_core_web_sm cat << 'EOF' > /etc/systemd/system/librephotos-backend.service [Unit] @@ -75,27 +68,27 @@ export ADMIN_USERNAME=thomas export ADMIN_EMAIL=thomas@lgy.fr export ADMIN_PASSWORD=toto export MAPBOX_API_KEY= +export DEBUG=0 - -/usr/local/bin/python3.8 image_similarity/main.py 2>&1 | tee /logs/gunicorn_image_similarity.log & -/usr/local/bin/python3.8 manage.py showmigrations | tee /logs/show_migrate.log -/usr/local/bin/python3.8 manage.py migrate | tee /logs/command_migrate.log -/usr/local/bin/python3.8 manage.py showmigrations | tee /logs/show_migrate.log -/usr/local/bin/python3.8 manage.py build_similarity_index 2>&1 | tee /logs/command_build_similarity_index.log -/usr/local/bin/python3.8 manage.py clear_cache -/usr/local/bin/python3.8 manage.py createadmin -u $ADMIN_USERNAME $ADMIN_EMAIL 2>&1 | tee /logs/command_createadmin.log +python3 image_similarity/main.py 2>&1 | tee /logs/gunicorn_image_similarity.log & +python3 manage.py showmigrations | tee /logs/show_migrate.log +python3 manage.py migrate | tee /logs/command_migrate.log +python3 manage.py showmigrations | tee /logs/show_migrate.log +python3 manage.py build_similarity_index 2>&1 | tee /logs/command_build_similarity_index.log +python3 manage.py clear_cache +python3 manage.py createadmin -u $ADMIN_USERNAME $ADMIN_EMAIL 2>&1 | tee /logs/command_createadmin.log echo "Running backend server..." -/usr/local/bin/python3.8 manage.py rqworker default 2>&1 | tee /logs/rqworker.log & +python3 manage.py rqworker default 2>&1 | tee /logs/rqworker.log & if [ "$DEBUG" = 1 ] then echo "develompent backend starting" - /usr/local/bin/gunicorn --worker-class=gevent --timeout 36000 --reload --bind localhost:8001 --log-level=info ownphotos.wsgi 2>&1 | tee /logs/gunicorn_django.log + gunicorn --worker-class=gevent --timeout 36000 --reload --bind localhost:8001 --log-level=info ownphotos.wsgi 2>&1 | tee /logs/gunicorn_django.log else echo "production backend starting" - /usr/local/bin/gunicorn --worker-class=gevent --timeout 3600 --bind localhost:8001 --log-level=info ownphotos.wsgi 2>&1 | tee /logs/gunicorn_django.log + gunicorn --worker-class=gevent --timeout 3600 --bind localhost:8001 --log-level=info ownphotos.wsgi 2>&1 | tee /logs/gunicorn_django.log fi EOF chmod +x /usr/local/bin/librephotos-backend