Skip to content
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

M1 Mac Support? #14

Open
aphillipo opened this issue Dec 8, 2022 · 6 comments
Open

M1 Mac Support? #14

aphillipo opened this issue Dec 8, 2022 · 6 comments

Comments

@aphillipo
Copy link

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
Copy link
Author

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"]

@mcherep
Copy link

mcherep commented Dec 9, 2022

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

@aphillipo
Copy link
Author

aphillipo commented Dec 9, 2022

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...

@danigb
Copy link

danigb commented Dec 21, 2022

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

@llemtt
Copy link

llemtt commented May 9, 2023

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

?

@yocontra
Copy link

yocontra commented Apr 1, 2024

Opened a PR here: #39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants