basic-pitch icon indicating copy to clipboard operation
basic-pitch copied to clipboard

Mac M1 illegal hardware instruction

Open briansorahan opened this issue 2 years ago • 18 comments

I'm on Mac OS Monterey version 12.6 Just pip installed this tool and tried to run it against a wav file and got this error

basic-pitch ~/basic-pitch-output kay_laughing.wav

✨✨✨✨✨✨✨✨✨
✨ Basic Pitch  ✨
✨✨✨✨✨✨✨✨✨

Importing Tensorflow (this may take a few seconds)...
[1]    41863 illegal hardware instruction  basic-pitch ~/basic-pitch-output kay_laughing.wav

I tried adding the --debug-file option to the above command to see if I could get any more info to share but the file was never even created.

Pls let me know what other info would be useful!

Here is the output of pip show

pip show basic-pitch
Name: basic-pitch
Version: 0.2.0
Summary: Basic Pitch, a lightweight yet powerful audio-to-MIDI converter with pitch bend detection.
Home-page: https://github.com/spotify/basic-pitch
Author: Spotify
Author-email: [email protected]
License: Apache 2.0
Location: /Users/brian.soraham/miniconda3/lib/python3.9/site-packages
Requires: librosa, resampy, typing-extensions, mir-eval, tensorflow, pretty-midi, scipy
Required-by:

and I'm on python 3.9.7

briansorahan avatar Jan 23 '23 15:01 briansorahan

x86_64 tensorflow has this bug, you can use arm64 tensorflow

zhouyijian avatar Feb 20 '23 10:02 zhouyijian

Also having trouble with this!

jonch070 avatar Apr 02 '23 07:04 jonch070

Hi @briansorahan, thank you for flagging this! Are you able to upgrade to python 3.10? We are currently unable to support M1 hardware using older versions of python. Let me know if you run into issues with python 3.10.

You can also use a virtual machine for Windows or Mac with Intel hardware. I am working on documentation on how to do that now.

dohertyguirand avatar May 05 '23 11:05 dohertyguirand

Hi @jonch070, which version of python are you using? If you using a version less than 3.10 and have M1 hardware, try upgrading to python 3.10. We are currently unable to support M1 hardware using older versions of python.

dohertyguirand avatar May 05 '23 11:05 dohertyguirand

I'll give 3.10 a try today

briansorahan avatar May 05 '23 15:05 briansorahan

Hello, I'm also having the same 'illegal hardware instruction' error. I'm using: Macbook Pro M1 MacOS 13.1 created a venv with Python 3.10

I also tried switching between the x86_64 and the arm64, but haven't been able to get this to run. Let me know what I can do to help.

Thank you in advance for your help as I'm really looking forward to trying out this package!

burcellf avatar May 05 '23 15:05 burcellf

Hey @burcellf, thanks for your message. What command did you run to install basic-pitch? Also which version of basic-pitch do you have?

dohertyguirand avatar May 05 '23 15:05 dohertyguirand

Hey @dohertyguirand, thank you for your prompt reply.

I installed basic-pitch using the following command:

conda create -c conda-forge  -n basic_pitch python=3.10

the .__version__ command says I'm running version: 0.2.4

burcellf avatar May 05 '23 16:05 burcellf

@burcellf Try installing with pip as we haven't made a proper conda installation.

dohertyguirand avatar May 05 '23 16:05 dohertyguirand

Here are the changes in my environment

python

python --version
Python 3.10.11

basic-pitch

Name: basic-pitch
Version: 0.2.4
Summary: Basic Pitch, a lightweight yet powerful audio-to-MIDI converter with pitch bend detection.
Home-page: https://github.com/spotify/basic-pitch
Author: Spotify
Author-email: [email protected]
License: Apache 2.0
Location: /Users/brian.soraham/miniconda3/lib/python3.10/site-packages
Requires: librosa, mir-eval, numpy, pretty-midi, resampy, scipy, tensorflow, typing-extensions
Required-by:

tensorflow (don't think I shared this before, but including it here since maybe it's relevant)

pip show tensorflow
Name: tensorflow
Version: 2.11.1
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: [email protected]
License: Apache 2.0
Location: /Users/brian.soraham/miniconda3/lib/python3.10/site-packages
Requires: absl-py, astunparse, flatbuffers, gast, google-pasta, grpcio, h5py, keras, libclang, numpy, opt-einsum, packaging, protobuf, setuptools, six, tensorboard, tensorflow-estimator, tensorflow-io-gcs-filesystem, termcolor, typing-extensions, wrapt
Required-by: basic-pitch

Still getting the illegal hardware instruction error.

FWIW, I also tried the same command in a miniconda3:4.12.0 container and got this

✨✨✨✨✨✨✨✨✨
✨ Basic Pitch  ✨
✨✨✨✨✨✨✨✨✨

Importing Tensorflow (this may take a few seconds)...
The TensorFlow library was compiled to use AVX instructions, but these aren't available on your machine.
qemu: uncaught target signal 6 (Aborted) - core dumped
Aborted

This was with python 3.10.11 too. I guess it's prob an issue with the virtual CPU in the VM that is running the container

briansorahan avatar May 05 '23 18:05 briansorahan

@briansorahan what command did you use to install basic-pitch? M1 hardware should be using tensorflow-macos instead of tensorflow. Let me know what you used and I will try to replicate.

dohertyguirand avatar May 05 '23 19:05 dohertyguirand

I used pip install basic-pitch but I am running my terminal (and tmux, which actually spawns my shell) with rosetta. I've had too many build failures with arm64, e.g. grpcio I should revisit this at some point though...

briansorahan avatar May 05 '23 19:05 briansorahan

@briansorahan Oh I see. We currently do not support rosetta. I've tried it myself in the past with basic-pitch and haven't gotten the entire installation workflow to succeed. I would recommend using arm64 architecture.

dohertyguirand avatar May 05 '23 19:05 dohertyguirand

@dohertyguirand Thanks! I'll give that a shot and circle back here with the results

briansorahan avatar May 05 '23 20:05 briansorahan

I forked the repo and added a dockerfile locally since docker is oftentimes my goto solution when I have trouble installing/running things on my macbook

FROM tensorflow/tensorflow:2.13.0
RUN  pip install basic-pitch
ENTRYPOINT ["basic-pitch"]

I built the image with

docker build -t basic-pitch .

I no longer see the illegal hardware instruction error, but the command takes a really long time (I've never actually seen it complete). I'm trying to get a MIDI file output from one of the audio files in this repo

mkdir output
docker run --rm -v $(pwd):/cwd -w /cwd basic-pitch output tests/resources/vocadito_10.wav

briansorahan avatar Jul 11 '23 19:07 briansorahan

How long are you experiencing? Tensorflow can take 5-10 seconds to import when running Python so it could be the overhead of the import.

drubinstein avatar Jul 27 '23 19:07 drubinstein

I let it run for at least 30 minutes just to see if it would ever complete, figuring maybe the audio file I used was weird somehow and triggered an edge case

briansorahan avatar Aug 04 '23 12:08 briansorahan

vocadito should be fine to work with. I'm wondering if it's a docker issue (are you using an x86 image instead of an ARM one). Regardless, I've been able to install basic-pitch on my M1 laptop and run audio through it without a problem. With tensorflow 2.13, basic-pitch 0.2.6 ran in < 10 seconds for vocadito_10.wav.

time basic-pitch /tmp  ~/git/basic-pitch/tests/resources/vocadito_10.wav
...
basic-pitch /tmp ~/git/basic-pitch/tests/resources/vocadito_10.wav  8.37s user 3.72s system 43% cpu 27.620 total

I'm curious what would happen if you tried to import tensorflow in a vanilla python shell on your machine. Otherwise, it could be helpful if you could try to pinpoint when the illegal instruction error is raised. You could try print-debugging, or the faulthandler / prepending PYTHONFAULTHANDLER=1 to your command.

drubinstein avatar Aug 04 '23 17:08 drubinstein

Closing due to inactivity - feel free to reopen if this issue is still persisting.

rabitt avatar Apr 12 '24 14:04 rabitt