TomBursch / kitchenowl

KitchenOwl is a self-hosted grocery list and recipe manager. The backend is made with Flask and the frontend with Flutter. Easily add items to your shopping list before you go shopping. You can also create recipes and add items based on what you want to cook.
https://kitchenowl.org/
GNU Affero General Public License v3.0
1.3k stars 76 forks source link

Bug: OpenBLAS thread create not permitted #248

Closed Baton4986 closed 1 year ago

Baton4986 commented 1 year ago

Is this urgent?

None

What parts are affected

Backend

What are the Server/Client versions of KitchenOwl

latest

What's the problem 🤔

backend restarting every few seconds.

Share your logs

OpenBLAS blas_thread_init: pthread_create failed for thread 1 of 4: Operation not permitted
OpenBLAS blas_thread_init: RLIMIT_NPROC -1 current, -1 max
OpenBLAS blas_thread_init: pthread_create failed for thread 2 of 4: Operation not permitted
OpenBLAS blas_thread_init: RLIMIT_NPROC -1 current, -1 max
OpenBLAS blas_thread_init: pthread_create failed for thread 3 of 4: Operation not permitted
OpenBLAS blas_thread_init: RLIMIT_NPROC -1 current, -1 max

Aborted!
Traceback (most recent call last):
  File "/usr/src/kitchenowl/upgrade_default_items.py", line 2, in <module>
    from app import app
  File "/usr/src/kitchenowl/app/__init__.py", line 1, in <module>
    from app.config import app, jwt, socketio
  File "/usr/src/kitchenowl/app/config.py", line 115, in <module>
    scheduler.start()
  File "/opt/venv/lib/python3.11/site-packages/flask_apscheduler/scheduler.py", line 105, in start
    self._scheduler.start(paused=paused)
  File "/opt/venv/lib/python3.11/site-packages/apscheduler/schedulers/background.py", line 38, in start
    self._thread.start()
  File "/usr/local/lib/python3.11/threading.py", line 957, in start
    _start_new_thread(self._bootstrap, ())
RuntimeError: can't start new thread
[uWSGI] getting INI configuration from wsgi.ini
*** Starting uWSGI 2.0.22 (64bit) on [Thu Sep 21 13:51:26 2023] ***
compiled with version: 12.2.0 on 15 September 2023 06:46:39
os: Linux-4.19.0-25-amd64 #1 SMP Debian 4.19.289-2 (2023-08-08)
nodename: 5edf88aef5e5
machine: x86_64
clock source: unix
pcre jit disabled
detected number of CPU cores: 4
current working directory: /usr/src/kitchenowl
detected binary path: /opt/venv/bin/uwsgi
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
your memory page size is 4096 bytes
detected max file descriptor number: 1048576
- async cores set to 200 - fd table size: 1048576
lock engine: pthread robust mutexes
thunder lock: disabled (you can enable it with --thunder-lock)
uwsgi socket 0 bound to TCP address 0.0.0.0:5000 fd 3
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
Python version: 3.11.5 (main, Sep  7 2023, 12:46:15) [GCC 12.2.0]
Python main interpreter initialized at 0x7f89f049e6b8
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
python threads support enabled
your server socket listen backlog is limited to 100 connections
your mercy for graceful operations on workers is 60 seconds
mapped 4307328 bytes (4206 KB) for 200 cores
*** Operational MODE: async ***
uWSGI running as root, you can use --uid/--gid/--chroot options
*** WARNING: you are running uWSGI as root !!! (use the --uid flag) *** 
spawned uWSGI master process (pid: 9)
spawned uWSGI worker 1 (pid: 10, cores: 200)
OpenBLAS blas_thread_init: pthread_create failed for thread 1 of 4: Operation not permitted
OpenBLAS blas_thread_init: RLIMIT_NPROC -1 current, -1 max
OpenBLAS blas_thread_init: pthread_create failed for thread 2 of 4: Operation not permitted
OpenBLAS blas_thread_init: RLIMIT_NPROC -1 current, -1 max
OpenBLAS blas_thread_init: pthread_create failed for thread 3 of 4: Operation not permitted
OpenBLAS blas_thread_init: RLIMIT_NPROC -1 current, -1 max
Traceback (most recent call last):
  File "wsgi.py", line 4, in <module>
    from app import app, socketio
  File "/usr/src/kitchenowl/app/__init__.py", line 4, in <module>
    from app.controller import *
  File "/usr/src/kitchenowl/app/controller/__init__.py", line 4, in <module>
    from .recipe import *
  File "/usr/src/kitchenowl/app/controller/recipe/__init__.py", line 1, in <module>
    from .recipe_controller import recipe, recipeHousehold
  File "/usr/src/kitchenowl/app/controller/recipe/recipe_controller.py", line 11, in <module>
    from ingredient_parser import parse_ingredient
  File "/opt/venv/lib/python3.11/site-packages/ingredient_parser/__init__.py", line 1, in <module>
    from .parsers import parse_ingredient, parse_multiple_ingredients
  File "/opt/venv/lib/python3.11/site-packages/ingredient_parser/parsers.py", line 10, in <module>
    from .preprocess import PreProcessor
  File "/opt/venv/lib/python3.11/site-packages/ingredient_parser/preprocess.py", line 8, in <module>
    from nltk.stem.porter import PorterStemmer
  File "/opt/venv/lib/python3.11/site-packages/nltk/__init__.py", line 133, in <module>
    from nltk.collocations import *
  File "/opt/venv/lib/python3.11/site-packages/nltk/collocations.py", line 36, in <module>
    from nltk.metrics import (
  File "/opt/venv/lib/python3.11/site-packages/nltk/metrics/__init__.py", line 17, in <module>
    from nltk.metrics.aline import align
  File "/opt/venv/lib/python3.11/site-packages/nltk/metrics/aline.py", line 41, in <module>
    import numpy as np
  File "/opt/venv/lib/python3.11/site-packages/numpy/__init__.py", line 139, in <module>
    from . import core
  File "/opt/venv/lib/python3.11/site-packages/numpy/core/__init__.py", line 23, in <module>
    from . import multiarray
  File "/opt/venv/lib/python3.11/site-packages/numpy/core/multiarray.py", line 10, in <module>
    from . import overrides
  File "/opt/venv/lib/python3.11/site-packages/numpy/core/overrides.py", line 8, in <module>
    from numpy.core._multiarray_umath import (
  File "<frozen importlib._bootstrap>", line 216, in _lock_unlock_module
KeyboardInterrupt
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. GAME OVER ***
SIGINT/SIGTERM received...killing workers...
OOPS ! failed loading app in worker 1 (pid 10)
Thu Sep 21 13:51:28 2023 - need-app requested, destroying the instance...
goodbye to uWSGI.

Share your configuration

version: "3"
services:
  front:
    image: tombursch/kitchenowl-web:latest
    restart: unless-stopped
    # environment:
    #   - BACK_URL=back:5000 # Change this if you rename the containers
    ports:
      - "8001:80"
    depends_on:
      - back
  back:
    image: tombursch/kitchenowl:latest
    restart: unless-stopped
    # ports: # Should only be needed if you're not using docker-compose
    #   - "5000:5000" # uwsgi protocol
    environment:
      - JWT_SECRET_KEY=mysecret
      # - FRONT_URL=http://localhost # Optional should not be changed unless you know what youre doing
    volumes:
      - kitchenowl_data:/data

volumes:
  kitchenowl_data:
TomBursch commented 1 year ago

Strange issue, can you share some information about your system? It could be that your system limits the number of threads somehow? Can you add OPENBLAS_NUM_THREADS=1 to the backend environment and see if that fixes the issue (as suggested here)?

Baton4986 commented 1 year ago

wow that was fast, this fixed the issue!

thanks a lot :+1:

Baton4986 commented 1 year ago

System is Univention Corporate Server (based on debian)