BeatNet icon indicating copy to clipboard operation
BeatNet copied to clipboard

M1 Mac Support?

Open aphillipo opened this issue 2 years ago • 6 comments

I've been wondering if anyone has got this awesome looking package working on M1 - I cannot for the life of me figure out which versions of numba and llvm to use. Brew doesn't let you install a version of llvm compatible with the versions of numba specified.

I wonder if I should checkout the repo, change some of the version requirements and cross my fingers 😂

Alternatively is this possible inside docker - will portaudio work inside a docker container?

aphillipo avatar Dec 08 '22 16:12 aphillipo

Interesting, if I remove the versions from numpy and librosa things seem to work inside docker at least on an M1. Here is the docker so you can see what I'm doing...

FROM ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update -y
RUN apt-get install libasound-dev libportaudio2 libportaudiocpp0 portaudio19-dev -y
RUN apt-get install -y wget 
RUN apt-get install --no-install-recommends -y python3.10 python3.10-dev python3.10-venv build-essential && apt-get clean 
RUN apt-get install software-properties-common git -y
RUN rm -rf /var/lib/apt/lists/*

RUN bash -c 'wget --no-check-certificate -O - https://apt.llvm.org/llvm-snapshot.gpg.key' | apt-key add -
RUN add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main'
RUN apt-get install llvm-11* -y

RUN useradd --create-home myuser

RUN python3 -m venv /home/myuser/venv
ENV PATH="/home/myuser/venv/bin:$PATH"

RUN pip3 install --no-cache-dir numpy
RUN pip3 install --no-cache-dir numba
RUN pip3 install --no-cache-dir Pyaudio
RUN pip3 install --no-cache-dir cython
RUN pip3 install --no-cache-dir git+https://github.com/aphillipo/BeatNet

CMD ["python"]

aphillipo avatar Dec 08 '22 21:12 aphillipo

I'm trying to install it on M1 and I have the same issue. It'd be great to support it!

mcherep avatar Dec 09 '22 04:12 mcherep

I'm sort of there inside docker at least, using my own repo that just removes the version numbers on librosa and numba...

Here is the current docker:

FROM ubuntu:22.04
# avoid stuck build due to user prompt
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update -y
RUN apt-get install libasound-dev libportaudio2 libportaudiocpp0 portaudio19-dev libsndfile1 -y
RUN apt-get install -y wget 
RUN apt-get install software-properties-common git -y
RUN add-apt-repository ppa:deadsnakes/ppa -y
RUN apt update
RUN apt-get install -y python3.8 python3.8-dev python3.8-venv build-essential 
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

RUN bash -c 'wget --no-check-certificate -O - https://apt.llvm.org/llvm-snapshot.gpg.key' | apt-key add -
RUN add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy main'
RUN apt-get install llvm-11* -y

RUN python3.8 -m venv /venv
ENV PATH=/venv/bin:$PATH

RUN pip3 install --no-cache-dir soundfile
RUN pip3 install --no-cache-dir numpy
RUN pip3 install --no-cache-dir numba
RUN pip3 install --no-cache-dir Pyaudio
RUN pip3 install --no-cache-dir cython
RUN pip3 install --no-cache-dir git+https://github.com/aphillipo/BeatNet

CMD ["python"]

To run it add the above to a directory in a file called Dockerfile and then run the following:

docker build -t beatnet-dockerised .
docker run --rm --device /dev/null:/dev/snd -it beatnet-dockerised

This will drop you into a python shell that might be able to run the offline models - the streaming ones seem to have an ASLA crash that I don't understand.

Anyway this is at least a start, it would be good for the author to consider checking if the packages he depends on specific versions for have been fixed because they cause incompatibility on MacOS and make things very hard to build. I'll leave mounting a volume for music to read from as an exercise for the reader...

aphillipo avatar Dec 09 '22 12:12 aphillipo

This seems to work on my computer:

LLVM_CONFIG="/opt/homebrew/Cellar/llvm@11/11.1.0_4/bin/llvm-config" arch -arm64 pip install BeatNet

Source: https://stackoverflow.com/questions/67567987/m1-mac-how-to-install-llvm

danigb avatar Dec 21 '22 17:12 danigb

I've managed to compile on my M2 running Ventura installing llvm-11 with MacPorts and using:

LLVM_CONFIG="/opt/local/libexec/llvm-11/bin/llvm-config" arch -arm64 pip install BeatNet

but

from BeatNet.BeatNet import BeatNet

fails with this error:

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Users/teo/Library/Python/3.9/lib/python/site-packages/BeatNet/BeatNet.py", line 8, in <module> from madmom.features import DBNDownBeatTrackingProcessor File "/Users/teo/Library/Python/3.9/lib/python/site-packages/madmom/__init__.py", line 24, in <module> from . import audio, evaluation, features, io, ml, models, processors, utils File "/Users/teo/Library/Python/3.9/lib/python/site-packages/madmom/audio/__init__.py", line 27, in <module> from . import comb_filters, filters, signal, spectrogram, stft File "madmom/audio/comb_filters.pyx", line 1, in init madmom.audio.comb_filters ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

?

llemtt avatar May 09 '23 10:05 llemtt

Opened a PR here: https://github.com/mjhydri/BeatNet/pull/39

yocontra avatar Apr 01 '24 06:04 yocontra