CPJKU / madmom

Python audio and music signal processing library
https://madmom.readthedocs.io
Other
1.31k stars 200 forks source link

297% cpu usage on `DBNBeatTracker -vvv online -j 1` #507

Closed sloev closed 1 year ago

sloev commented 1 year ago

Expected behaviour

i expected madmom to be able to run DBNBeatTracker -vvv online -j 1 and only use 1 thread, and maybe not 100% cpu for any threads at all.

Actual behaviour

uses 297 % cpu on my macbookpro 2015

Steps needed to reproduce the behaviour

DBNBeatTracker -vvv online -j 1

Information about installed software

Screenshot 2022-10-05 at 17 08 54

python 3.8.6

pip list incl madmom==0.17.dev0: ``` Package Version ---------------------- ------------ aiofiles 0.6.0 aiohttp 3.8.1 aiohttp-socks 0.6.0 aioprocessing 2.0.1 aiosc 0.1.4 aiosignal 1.2.0 anyio 3.6.1 appdirs 1.4.4 arrow 1.2.3 async-timeout 4.0.2 asyncer 0.0.1 attrs 21.2.0 aubio 0.4.9 beautifulsoup4 4.11.1 binaryornot 0.4.4 black 22.8.0 bleach 5.0.1 briefcase 0.3.9 CacheControl 0.12.11 cachy 0.3.0 cairocffi 1.2.0 CairoSVG 2.5.1 certifi 2021.5.30 cffi 1.15.1 chardet 4.0.0 charset-normalizer 2.0.4 cleo 1.0.0a5 click 8.1.3 coloredlogs 15.0.1 commonmark 0.9.1 cookiecutter 2.1.1 crashtest 0.3.1 cssselect2 0.4.1 cycler 0.10.0 Cython 0.29.32 decorator 4.4.2 defusedxml 0.6.0 distlib 0.3.1 dlib 19.21.1 dmgbuild 1.5.2 docutils 0.17.1 drawSvg 1.8.1 ds-store 1.3.0 dulwich 0.20.46 fastapi 0.80.0 filelock 3.0.12 filetype 1.1.0 flatbuffers 2.0.7 frozenlist 1.3.1 future 0.18.2 gdown 4.5.1 gitdb 4.0.9 GitPython 3.1.27 glfw 2.5.5 h11 0.12.0 h2 4.0.0 hpack 4.0.0 html5lib 1.1 humanfriendly 10.0 hyperframe 6.0.1 idna 3.2 ImageHash 4.2.1 imageio 2.9.0 imageio-ffmpeg 0.4.7 importlib-metadata 4.12.0 importlib-resources 5.9.0 imutils 0.5.4 jaraco.classes 3.2.2 Jinja2 3.1.2 jinja2-time 0.2.0 jsonschema 3.2.0 keyring 23.9.1 kiwisolver 1.3.1 llvmlite 0.39.1 lockfile 0.12.2 Logbook 1.5.3 mac-alias 2.2.0 madmom 0.17.dev0 MarkupSafe 2.1.1 matplotlib 3.3.4 matrix-nio 0.18.6 mido 1.2.10 miniaudio 1.52 more-itertools 8.14.0 moviepy 1.0.3 mpmath 1.2.1 msgpack 1.0.4 multidict 5.1.0 mypy-extensions 0.4.3 networkx 2.5 numba 0.56.2 numpy 1.21.6 numpy-ringbuffer 0.2.2 onnxruntime 1.12.1 opencv-python 4.6.0.66 opencv-python-headless 4.6.0.66 packaging 21.3 pathspec 0.9.0 pexpect 4.8.0 Pillow 9.2.0 pip 22.2.2 pkginfo 1.8.3 pkgutil_resolve_name 1.3.10 platformdirs 2.5.2 poetry 1.2.0 poetry-core 1.1.0 poetry-plugin-export 1.0.6 proglog 0.1.10 protobuf 4.21.6 psutil 5.9.2 ptyprocess 0.7.0 PyAudio 0.2.12 pycparser 2.20 pycryptodome 3.10.1 pydantic 1.10.2 pydub 0.25.1 Pygments 2.13.0 pylev 1.4.0 PyMatting 1.1.8 PyOpenGL 3.1.6 pyparsing 2.4.7 pyrsistent 0.18.0 PySocks 1.7.1 python-daemon 2.3.0 python-dateutil 2.8.1 python-magic 0.4.24 python-multipart 0.0.5 python-osc 1.8.0 python-slugify 6.1.2 python-socks 1.2.4 PyWavelets 1.1.1 PyYAML 6.0 readme-renderer 37.1 regex 2021.8.3 rembg 2.0.25 requests 2.26.0 requests-toolbelt 0.9.1 rfc3986 2.0.0 rich 12.5.1 rubicon-objc 0.4.2 scikit-image 0.19.3 scipy 1.7.3 setuptools 59.8.0 shellingham 1.5.0 six 1.15.0 smmap 5.0.0 sniffio 1.3.0 SoundCard 0.4.2 sounddevice 0.4.5 SoundFile 0.10.3.post1 soundmeter 0.1.5 soupsieve 2.3.2.post1 starlette 0.19.1 std-nslog 1.0.1 sympy 1.11.1 syphonpy 0.0.2 text-unidecode 1.3 tifffile 2021.3.5 tinycss2 1.1.0 toga 0.2.15 toga-cocoa 0.3.0.dev36 toga-core 0.3.0.dev36 tomli 2.0.1 tomlkit 0.11.4 tqdm 4.64.0 travertino 0.1.3 twine 4.0.1 typing_extensions 4.3.0 unpaddedbase64 2.1.0 urllib3 1.26.6 uvicorn 0.18.3 virtualenv 20.4.2 watchdog 2.1.9 webencodings 0.5.1 wheel 0.37.1 xattr 0.9.9 yarl 1.6.3 youtube-dl 2021.12.17 zipp 3.8.1 ```
sloev commented 1 year ago

is it possible to run madmom DBNBeatTracker using fewer resources?

thanks :-) have a good autumn day

sloev commented 1 year ago

using python 3.9.0 on same system as mentioned above and same packages results in only 38% cpu

superbock commented 1 year ago

Although you can reduce the number of threads with the -j switch, this does not guarantee that only a single CPU core is used since numpy parallelises stuff quite heavily. Please have a look at https://stackoverflow.com/a/31622299.

You can also disable a couple of neural networks. Per default bagging over 8 networks is performed, I do not expect much lower (detection) performance if only 4 or even 2 are used.