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

[Bug] Illegal hardware instruction #607

Closed
e16m opened this issue Apr 8, 2021 · 28 comments
Closed

[Bug] Illegal hardware instruction #607

e16m opened this issue Apr 8, 2021 · 28 comments
Labels
bug Something isn't working invalid This doesn't seem right

Comments

@e16m
Copy link

e16m commented Apr 8, 2021

  • [O ] I didn't find a similar issue already open.
  • [O] I read the documentation (README AND Wiki)
  • [O] I have installed FFMpeg
  • [O] My problem is related to Spleeter only, not a derivative product (such as Webapplication, or GUI provided by others)

Description

On a windows PC, I was able to successfully run a command using 'spleeter separator test.mp3'. However, on my mac which runs macOS Big Sur with Apple M1, I get the following error when running the same command: zsh: illegal hardware instruction

My question is, is spleeter incompatible with Big Sur or Apple M1? I found that this was the case for tensorflow, and I'm curious if there is any way around this to run spleeter on my mac. Thanks.

Step to reproduce

  1. Installed using pip with python 3.8
  2. Ran as 'spleeter separator test.mp3' on terminal
  3. Got 'illegal hardware instruction' error

Output

When I run the script I get the following error: zsh: illegal hardware instruction
My expectation was that it would run the same as on my PC, with a success message.

Environment

OS macOS Big Sur Version 11.1
Installation type pip
RAM available 16 GB
Hardware spec -

Additional context

@e16m e16m added bug Something isn't working invalid This doesn't seem right labels Apr 8, 2021
@romi1502
Copy link
Member

Hi @rappercodes,
we have not tested spleeter on Apple M1 yet, and it is very likely that the issue comes from an incompatibility issue.
We have no M1 available at the moment to investigate on this issue, but if you find any hints about what could fix the issue, let us know.

@e16m
Copy link
Author

e16m commented Apr 15, 2021

Thanks @romi1502. It does seem like an incompatibility issue. If I do come across anything I will share here.

@e16m e16m closed this as completed Apr 15, 2021
@Faylixe
Copy link
Collaborator

Faylixe commented Apr 15, 2021

I confirm that Tensorflow compatibility with Apple M1 chip is not available at the moment, you can find some workaround based on Rosetta 2 here.

Do not hesitate to tell us if you manage to make it work with Rosetta, otherwise we will just wait a TF release that is compatible with M1 :)

@d-dawg78
Copy link
Collaborator

d-dawg78 commented Apr 28, 2021

For those of you who want to run Spleeter on a Mac with M1 chips, you may find a guide for installing TF here:

https://drive.google.com/drive/folders/1oSipZLnoeQB0Awz8U68KYeCPsULy_dQ7?usp=sharing

And a guide for building and installing Spleeter here:

https://drive.google.com/drive/folders/1ioRr6-xRNizoR7xqWxXUdgjoijFOd2SC?usp=sharing

Note that this is a temporary fix, until TF is updated to run on these new chips. Enjoy!

@kode54
Copy link

kode54 commented Oct 4, 2021

Any updates?

@konglong87
Copy link

@dezerving
Copy link

dezerving commented Nov 14, 2021

Anyone able to build a whl file for an M1 Pro running python 3.9? I can't seem to get it to build with bazel. Keeps erroring out. Super annoying. Not sure why this issue is closed. It should remain OPEN until there is an easier way to get this to run on M1...

Edit:

The error has to do with numpy (Executing genrule @local_config_python//:numpy_include failed (Exit 1)).

Trying some workarounds I saw but so far its been rough trying to get this to build through bazel.

@vumaasha
Copy link

is it possible to use dockerized images to workaround M1 specific issue?

@tartale
Copy link

tartale commented Dec 11, 2021

FWIW, I found this guide for tensorflow:
https://betterprogramming.pub/installing-tensorflow-on-apple-m1-with-new-metal-plugin-6d3cb9cb00ca

I'm going to still follow the workaround for spleeter, but if having a native M1 tensorflow install was a blocker, it may no longer be.

@overdub60
Copy link

Unfortunately, none of the suggested solutions have been working for me. Would really like this to work in my M1.

@sslupsky
Copy link

I am attempting to install Spleeter on a MBP with M1 Max.

Apple published details of how to install Tensorflow on Apple Silicon Macs with Tensorflow Pluggable Device support for Metal here:

https://developer.apple.com/metal/tensorflow-plugin/

That installed Tensorflow 2.7.0

Name: tensorflow-macos
Version: 2.7.0
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/stevenslupsky/miniforge3/lib/python3.9/site-packages
Requires: absl-py, astunparse, flatbuffers, gast, google-pasta, grpcio, h5py, keras, keras-preprocessing, libclang, numpy, opt-einsum, protobuf, six, tensorboard, tensorflow-estimator, termcolor, typing-extensions, wheel, wrapt
Required-by: 

I installed ffmpeg and libsndfile successfully. When installing spleeter, I see an enormous number of error messages. At the end is the following:

ERROR: Cannot install spleeter==2.1.0 and spleeter==2.3.0 because these package versions have conflicting dependencies.

The conflict is caused by:
    spleeter 2.3.0 depends on tensorflow==2.5.0
    spleeter 2.1.0 depends on pandas==1.1.2

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies

@d-dawg78
Copy link
Collaborator

d-dawg78 commented Jan 25, 2022

Hi all,

We, at Deezer, managed to use Spleeter on Mac M1 using Tensorflow Metal. Here are the instructions you must follow in order to complete the installation.

  1. Upgrade your mac OS to Monterey (12.0.0+).
  2. Switch to a Rosetta terminal.
  3. Install Python 3.8. For now, we have not managed to run Metal on Python 3.9+, and Metal does not work for versions pre-3.8.
  4. Download the .whl file that can be found here, and run the following command:
    python -m pip install --upgrade spleeter-2.3.0b0-cp38-cp38-macosx_11_0_x86_64.whl
    Note that python refers to your local python3 installation. We recommend uninstalling the packages you have installed locally to avoid potential conflicting dependencies. Run the following a few times:
python -m pip freeze > requirements.txt
python -m pip uninstall -r requirements.txt -y
  1. Test your new Spleeter installation using:
    python -m spleeter separate -p spleeter:2stems -o output audio_example.mp3
    You can check your Activity Monitor to see the GPU being used.

We have also created branch for local development using Metal. Please run the following:

git clone https://github.com/Deezer/spleeter && cd spleeter
git fetch --all
git checkout tf_metal

You are free to edit and update the dependencies in pyproject.toml and build your own .whl files using poetry install and poetry build (poetry tutorial).

Finally, please send us your feedback in the comments below. A more substantial release may follow if this fix ends up working for you!

@tartale
Copy link

tartale commented Jan 26, 2022

Finally, please send us your feedback in the comments below. A more substantial release may follow if this fix ends up working for you!

Worked great! thank you

@sslupsky
Copy link

@d-dawg78 Thank you for the update. I followed the instructions @argsnd provided in issue #696 which I think installed the developer version of spleeter with the poetry dependency manager. I installed TensorFlow Metal according to the Apple Developer link I provided above. I successfully achieved my goal of installing and running spleeter and it appears to be running for me with python 3.9.7.

@MasayukiNagase
Copy link

@sslupsky that is awesome to hear! I have been trying to get Spleeter up and running on python 3.9.7 as well and I would love if you could give like a step by step (if I should follow #696 first or installing TensorFlow Metal from the Apple dev link because it seems that both #696 and the link download metal in their steps). I am still struggling on getting it to work together, and Im not sure if everything should be done with Rosetta etc. Thank you so much in advance! I really appreciate it

@sslupsky
Copy link

sslupsky commented Jan 26, 2022

@MasayukiNagase I installed TensorFlow Metal first using the Apple Developer instructions. After that I checked the version info for tensorflow-macos and confirmed I had version 2.7.0 installed.

I then followed #696 instructions 3, 5, 6

Then edited pyproject.toml and removed dependencies for tensorflow/numpy/scipy/llvmlite/librosa/pandas. As I recall, there doesn't appear to be a dependency for llvmlite in the pyproject.toml file I edited.

Then steps 8, 9 and 10.

After this, spleeter ran for me.

I have to source ~/miniforge3/bin/activate per the Apple Developer instructions to activate the correct python environment if I close the terminal or logout.

I took a screen shot of activity monitor and attached here.

Screen.Recording.2022-01-26.at.4.33.08.PM.mp4

@daslicht
Copy link

When I try to install python 3.8 I get:

% brew install [email protected]
Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!
To rerun under ARM use:
    arch -arm64 brew install ...
To install under x86_64, install Homebrew into /usr/local.
ansolas@Marcs-Mac-mini Downloads %  

@gormster
Copy link

gormster commented Jun 6, 2022

For what it's worth, I've got spleeter working perfectly without Rosetta. I had to do a bit of massaging:

  1. In pyproject.toml, under [tool.poetry.dependencies]:
    • change llvmlite to ^0.37.0
    • add protobuf = ">3.19.0,<3.21.0"
  2. Create a new conda environment: conda create -n spleeter python=3.9. Activate it with conda activate spleeter.
  3. Run poetry update --lock
  4. Install some dependencies through conda-forge: conda install -c conda-forge numpy==1.19.5 numba==0.54.1 grpcio==1.46.3 cffi==1.15.0 typed-ast==1.4.3 h5py==3.1.0 librosa==0.8.0 (Note that I grabbed the version numbers from the poetry.lock file, so if you're using a newer version of spleeter you'd need to change them. Poetry doesn't currently have a way to install dependencies using conda, sadly.)
  5. Run poetry install
  6. Test the install with spleeter separate -p spleeter:2stems -o output audio_example.mp3

Running pytest, everything passes except:

  • test_evaluate[librosa]
  • test_separate_to_file[audio_example_mono.mp3-spleeter:5stems-librosa]
  • test_filename_conflict[audio_example.mp3-spleeter:5stems]

Not sure why those three specifically.

@acronomic
Copy link

Hi, I've been trying to follow all of the above guides, and none seem to work. I am running macOS Monterey 12.6, on a Macbook Pro 2021 Apple M1 Max. When trying to install the wheel (python -m pip install --upgrade spleeter-2.3.0b0-cp38-cp38-macosx_11_0_x86_64.whl) as mentioned in d_dawgs comment (with the arch -x86_64 prefix), I get error "arch: posix_spawnp: pip: Bad CPU type in executable". Without that command: it just says "ERROR: spleeter-2.3.0b0-cp38-cp38-macosx_10_9_x86_64.whl is not a supported wheel on this platform."

I am running this inside a rosetta terminal, and when I type arch, I get "i386". Is there something I'm doing wrong to get the wheel to work?

I've also tried installing tensor flow 2.6 and python3.8 separately then using poetry install but I keep getting all different poetry errors. Not really sure what approach at this point I should take to get this to work. Any guidance would be greatly appreciated.

@devcooch
Copy link

I tried as per instruction here, unfortunately getting this error in output:

> python3.8 -m spleeter separate -p spleeter:2stems -o spleeter ~/My.mp3

2022-11-23 11:55:30.302187: F tensorflow/c/experimental/stream_executor/stream_executor.cc:823] Non-OK-status: stream_executor::MultiPlatformManager::RegisterPlatform( std::move(cplatform)) status: Internal: platform is already registered with name: "METAL"
[1]    87357 abort      python3.8 -m spleeter separate -p spleeter:2stems -o spleeter

@andrade0
Copy link

Did anywone already managed to make work ? i tryed everything on my M2 and there no way, even with docker

@sslupsky
Copy link

sslupsky commented Jan 18, 2023

@andrade0 I have it working. See the instructions I posted earlier in this thread and issue #696.

@daslicht
Copy link

daslicht commented Jan 18, 2023

Here is an alternative, there is even a GUI available:
https://github.com/facebookresearch/demucs

@adude007
Copy link

adude007 commented Jul 2, 2023

Hi all,

We, at Deezer, managed to use Spleeter on Mac M1 using Tensorflow Metal. Here are the instructions you must follow in order to complete the installation.

  1. Upgrade your mac OS to Monterey (12.0.0+).
  2. Switch to a Rosetta terminal.
  3. Install Python 3.8. For now, we have not managed to run Metal on Python 3.9+, and Metal does not work for versions pre-3.8.
  4. Download the .whl file that can be found here, and run the following command:
    python -m pip install --upgrade spleeter-2.3.0b0-cp38-cp38-macosx_11_0_x86_64.whl
    Note that python refers to your local python3 installation. We recommend uninstalling the packages you have installed locally to avoid potential conflicting dependencies. Run the following a few times:
python -m pip freeze > requirements.txt
python -m pip uninstall -r requirements.txt -y
  1. Test your new Spleeter installation using:
    python -m spleeter separate -p spleeter:2stems -o output audio_example.mp3
    You can check your Activity Monitor to see the GPU being used.

We have also created branch for local development using Metal. Please run the following:

git clone https://github.com/Deezer/spleeter && cd spleeter
git fetch --all
git checkout tf_metal

You are free to edit and update the dependencies in pyproject.toml and build your own .whl files using poetry install and poetry build (poetry tutorial).

Finally, please send us your feedback in the comments below. A more substantial release may follow if this fix ends up working for you!

For all those that followed these instructions and had some troubles here is what I did that got this working on my 2020 M1 Mac Mini on 13.4.1.

To get a rosetta terminal: First, open a terminal and then use command

arch -x86_64 zsh

check with arch and the response should be i386 if you are now in a rosetta terminal.

Follow the instructions quoted above to run the command to install Spleeter to your python install

Don't bother running these two commands. They just uninstall everything installed to your python install.

python -m pip freeze > requirements.txt
python -m pip uninstall -r requirements.txt -y

On my first run of the spleeter tool I had an issue where the version of protobuf that came with the whl command step was too new. So I downgraded that to 3.20.1 but you could use any stable 3.20.* version

python -m pip install protobuf==3.20.*

Then I was getting an error that ffmpeg binary not installed.

I installed homebrew from brew.sh in an arm64 terminal

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Use homebrew to Install ffmpeg with command

brew install ffmpeg

Then back in a rosetta terminal I was able to run the spleeter command successfully

python -m spleeter separate -p spleeter:2stems -o output audio_example.mp3

@BeatBoxerLrd
Copy link

BeatBoxerLrd commented Dec 27, 2023

Hi all,

We, at Deezer, managed to use Spleeter on Mac M1 using Tensorflow Metal. Here are the instructions you must follow in order to complete the installation.

  1. Upgrade your mac OS to Monterey (12.0.0+).
  2. Switch to a Rosetta terminal.
  3. Install Python 3.8. For now, we have not managed to run Metal on Python 3.9+, and Metal does not work for versions pre-3.8.
  4. Download the .whl file that can be found here, and run the following command:
    python -m pip install --upgrade spleeter-2.3.0b0-cp38-cp38-macosx_11_0_x86_64.whl
    Note that python refers to your local python3 installation. We recommend uninstalling the packages you have installed locally to avoid potential conflicting dependencies. Run the following a few times:
python -m pip freeze > requirements.txt
python -m pip uninstall -r requirements.txt -y
  1. Test your new Spleeter installation using:
    python -m spleeter separate -p spleeter:2stems -o output audio_example.mp3
    You can check your Activity Monitor to see the GPU being used.

We have also created branch for local development using Metal. Please run the following:

git clone https://github.com/Deezer/spleeter && cd spleeter
git fetch --all
git checkout tf_metal

You are free to edit and update the dependencies in pyproject.toml and build your own .whl files using poetry install and poetry build (poetry tutorial).

Finally, please send us your feedback in the comments below. A more substantial release may follow if this fix ends up working for you!

hi
mac info:
Apple M1 Pro
macOs ventura 13.0
python version:3.8.18

I cannot install this whl.

python m pip install --upgrade spleeter-2.3.0b0-cp38-cp38-macosx_11_0_x86_64.whl
ERROR: spleeter-2.3.0b0-cp38-cp38-macosx_11_0_x86_64.whl is not a supported wheel on this platform.

run arch -x86_64 zsh
No display

thank you!!!

@nihavend
Copy link

nihavend commented May 26, 2024

I made it work on M1 Pro Max with 3.8.10 but had to downgrade protobuf to 3.20.3
thanks

@iserdmi
Copy link

iserdmi commented Dec 6, 2024

M1. In my case this commands was successful:

conda create -n py38 python=3.8 -y
conda activate py38
conda install -c conda-forge ffmpeg libsndfile
pip install spleeter

@bhkangw
Copy link

bhkangw commented Dec 10, 2024

M1. In my case this commands was successful:

conda create -n py38 python=3.8 -y
conda activate py38
conda install -c conda-forge ffmpeg libsndfile
pip install spleeter

THIS WORKED THANK YOU. CLAUDE PLS INDEX THIS FIX 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests