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

Trouble with M1 install, did not manage to locate a library called 'sndfile' #27

Closed
heuermh opened this issue Feb 16, 2023 · 7 comments
Closed

Comments

@heuermh
Copy link

heuermh commented Feb 16, 2023

Following install instructions on M1 MacBook Air via README and adapted from https://developer.apple.com/metal/tensorflow-plugin/

$ uname -a
Darwin [hostname] 21.6.0 Darwin Kernel Version 21.6.0: Mon Dec 19 20:46:01 PST 2022;
root:xnu-8020.240.18~2/RELEASE_ARM64_T8101 arm64

$ git clone https://github.com/samim23/polymath
$ cd polymath
$ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-arm64.sh
$ bash Miniconda3-latest-MacOSX-arm64.sh -b -p `pwd`/miniconda
$ source miniconda/bin/activate
$ conda install -c apple tensorflow-deps
$ python -m pip install -U pip
$ python -m pip install tensorflow-macos
$ python -m pip install tensorflow-metal
$ pip install -r requirements.txt
$ python polymath.py -a m98qb8ecQf0
...
OSError: ctypes.util.find_library() did not manage to locate a library called 'sndfile'

$ pip install soundfile
Requirement already satisfied: soundfile in ./miniconda/lib/python3.10/site-packages (0.11.0)
Requirement already satisfied: cffi>=1.0 in ./miniconda/lib/python3.10/site-packages (from soundfile) (1.15.1)
Requirement already satisfied: pycparser in ./miniconda/lib/python3.10/site-packages (from cffi>=1.0->soundfile) (2.21)

$ brew install libsndfile
Warning: libsndfile 1.2.0 is already installed and up-to-date.

Please let me know if I'm missing something!

@faradox
Copy link

faradox commented Feb 17, 2023

As per this related issue can you please try calling try calling it like this:

env DYLD_LIBRARY_PATH="/opt/homebrew/lib:$DYLD_LIBRARY_PATH" python polymath.py -a m98qb8ecQf0 

@heuermh
Copy link
Author

heuermh commented Feb 18, 2023

Thank you! Got a bit farther this time

$ env DYLD_LIBRARY_PATH="/opt/homebrew/lib:$DYLD_LIBRARY_PATH" python polymath.py -a m98qb8ecQf0
...
2/8 pitch tracking
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf
ImportError: numpy.core._multiarray_umath failed to import
ImportError: numpy.core.umath failed to import
Traceback (most recent call last):
  File "/working/polymath/polymath.py", line 692, in <module>
    main()
  File "/working/polymath/polymath.py", line 624, in main
    audio_features = get_audio_features(file=file,file_id=vid.id)
  File "/working/polymath/polymath.py", line 426, in get_audio_features
    frequency_frames = get_pitch_dnn(file)
  File "/working/polymath/polymath.py", line 317, in get_pitch_dnn
    time, frequency, confidence, activation = crepe.predict(audio, sr, model_capacity="tiny", viterbi=True, center=True, step_size=10, verbose=1) # tiny|small|medium|large|full
  File "/working/polymath/miniconda/lib/python3.10/site-packages/crepe/core.py", line 255, in predict
    activation = get_activation(audio, sr, model_capacity=model_capacity,
  File "/working/polymath/miniconda/lib/python3.10/site-packages/crepe/core.py", line 185, in get_activation
    model = build_and_load_model(model_capacity)
  File "/working/polymath/miniconda/lib/python3.10/site-packages/crepe/core.py", line 44, in build_and_load_model
    from tensorflow.keras.layers import Input, Reshape, Conv2D, BatchNormalization
  File "/working/polymath/miniconda/lib/python3.10/site-packages/tensorflow/__init__.py", line 37, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "/working/polymath/miniconda/lib/python3.10/site-packages/tensorflow/python/__init__.py", line 42, in <module>
    from tensorflow.python import data
  File "/working/polymath/miniconda/lib/python3.10/site-packages/tensorflow/python/data/__init__.py", line 21, in <module>
    from tensorflow.python.data import experimental
  File "/working/polymath/miniconda/lib/python3.10/site-packages/tensorflow/python/data/experimental/__init__.py", line 96, in <module>
    from tensorflow.python.data.experimental import service
  File "/working/polymath/miniconda/lib/python3.10/site-packages/tensorflow/python/data/experimental/service/__init__.py", line 419, in <module>
    from tensorflow.python.data.experimental.ops.data_service_ops import distribute
  File "/working/polymath/miniconda/lib/python3.10/site-packages/tensorflow/python/data/experimental/ops/data_service_ops.py", line 22, in <module>
    from tensorflow.python.data.experimental.ops import compression_ops
  File "/working/polymath/miniconda/lib/python3.10/site-packages/tensorflow/python/data/experimental/ops/compression_ops.py", line 16, in <module>
    from tensorflow.python.data.util import structure
  File "/working/polymath/miniconda/lib/python3.10/site-packages/tensorflow/python/data/util/structure.py", line 22, in <module>
    from tensorflow.python.data.util import nest
  File "/working/polymath/miniconda/lib/python3.10/site-packages/tensorflow/python/data/util/nest.py", line 34, in <module>
    from tensorflow.python.framework import sparse_tensor as _sparse_tensor
  File "/working/polymath/miniconda/lib/python3.10/site-packages/tensorflow/python/framework/sparse_tensor.py", line 24, in <module>
    from tensorflow.python.framework import constant_op
  File "/working/polymath/miniconda/lib/python3.10/site-packages/tensorflow/python/framework/constant_op.py", line 25, in <module>
    from tensorflow.python.eager import execute
  File "/working/polymath/miniconda/lib/python3.10/site-packages/tensorflow/python/eager/execute.py", line 21, in <module>
    from tensorflow.python.framework import dtypes
  File "/working/polymath/miniconda/lib/python3.10/site-packages/tensorflow/python/framework/dtypes.py", line 34, in <module>
    _np_bfloat16 = _pywrap_bfloat16.TF_bfloat16_type()
TypeError: Unable to convert function return value to a Python type! The signature was
	() -> handle

@samim23
Copy link
Owner

samim23 commented Feb 18, 2023

Seems like your numpy is outdated. Try updating that
pip install numpy --upgrade or pip install numpy --upgrade --ignore-installed

@heuermh
Copy link
Author

heuermh commented Feb 18, 2023

Thank you, that and an update to numba did the trick!

$ pip install numpy --upgrade
Requirement already satisfied: numpy in ./miniconda/lib/python3.10/site-packages (1.22.3)
Collecting numpy
  Downloading numpy-1.24.2-cp310-cp310-macosx_11_0_arm64.whl (13.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.9/13.9 MB 17.5 MB/s eta 0:00:00
Installing collected packages: numpy
  Attempting uninstall: numpy
    Found existing installation: numpy 1.22.3
    Uninstalling numpy-1.22.3:
      Successfully uninstalled numpy-1.22.3
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
numba 0.56.4 requires numpy<1.24,>=1.18, but you have numpy 1.24.2 which is incompatible.
Successfully installed numpy-1.24.2

$ pip install numba --upgrade
Requirement already satisfied: numba in ./miniconda/lib/python3.10/site-packages (0.56.4)
Collecting numpy<1.24,>=1.18
  Downloading numpy-1.23.5-cp310-cp310-macosx_11_0_arm64.whl (13.4 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.4/13.4 MB 20.2 MB/s eta 0:00:00
Requirement already satisfied: llvmlite<0.40,>=0.39.0dev0 in ./miniconda/lib/python3.10/site-packages (from numba) (0.39.1)
Requirement already satisfied: setuptools in ./miniconda/lib/python3.10/site-packages (from numba) (65.6.3)
Installing collected packages: numpy
  Attempting uninstall: numpy
    Found existing installation: numpy 1.24.2
    Uninstalling numpy-1.24.2:
      Successfully uninstalled numpy-1.24.2
Successfully installed numpy-1.23.5

$ env DYLD_LIBRARY_PATH="/opt/homebrew/lib:$DYLD_LIBRARY_PATH" python polymath.py -a m98qb8ecQf0
...
m98qb8ecQf0 tempo 92.29 duration 207.82 timbre -8.68 pitch 0.5 intensity -48.38 segments 24 frequency 241.16 key B3 name A to the K
--------------------------------------------------------------------------

Feel free to close this issue.

@samim23 samim23 closed this as completed Feb 18, 2023
@qwertykeith
Copy link
Contributor

Hi! Looking forward to getting this going, it looks like a great project

I've tried everything above and can only get this

Traceback (most recent call last):
  File "/root/temp/blaaa/polymath/polymath.py", line 15, in <module>
    import librosa
  File "/usr/local/lib/python3.10/dist-packages/librosa/__init__.py", line 209, in <module>
    from . import core
  File "/usr/local/lib/python3.10/dist-packages/librosa/core/__init__.py", line 6, in <module>
    from .audio import *  # pylint: disable=wildcard-import
  File "/usr/local/lib/python3.10/dist-packages/librosa/core/audio.py", line 8, in <module>
    import soundfile as sf
  File "/usr/local/lib/python3.10/dist-packages/soundfile.py", line 267, in <module>
    _snd = _ffi.dlopen('sndfile')
  File "/usr/local/lib/python3.10/dist-packages/cffi/api.py", line 150, in dlopen
    lib, function_cache = _make_ffi_library(self, name, flags)
  File "/usr/local/lib/python3.10/dist-packages/cffi/api.py", line 832, in _make_ffi_library
    backendlib = _load_backend_lib(backend, libname, flags)
  File "/usr/local/lib/python3.10/dist-packages/cffi/api.py", line 827, in _load_backend_lib
    raise OSError(msg)
OSError: ctypes.util.find_library() did not manage to locate a library called 'sndfile'

Running sudo python3 polymath.py -a n6DAqMFe97E

I'm on WSL (Windows) on Ubuntu and in no way a python expert, so any ideas would be appreciated.. ta! :)

@samim23
Copy link
Owner

samim23 commented Feb 19, 2023

You are missing the sndfile library. No entirely sure what is causing your issues, as your setup (windows WSL > ubuntu) is new to me. This post https://stackoverflow.com/questions/59834551/cant-import-librosa-lib-on-windows-sndfile-not-found suggest running apt install libsndfile1. Please try that and report back if it worked. Thanks!

@qwertykeith
Copy link
Contributor

That did the trick, thankyou!

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

4 participants