shorepine / amy

AMY - A high-performance fixed-point Music synthesizer librarY for microcontrollers
https://shorepine.github.io/amy/
MIT License
188 stars 11 forks source link

Installing AMY on Raspberry Pi Zero (32bits) #145

Closed Olifiers closed 1 month ago

Olifiers commented 1 month ago

Hi there!

Apologies if I'm missing something, but I'm unable to run 'make test' as it requires llvm, which in turn, requires conda, which doesn't seem to support 32 bits anymore. How can one install AMY on a Raspberry Pi Zero 2 running a 32 bits OS?

Thanks for the help!

bwhitman commented 1 month ago

Hm, that's weird. make test shouldn't require llvm. I don't see that in the Makefile, at least. Does just make work? Maybe it's something wrong with the Python module? Can you share your full terminal log?

znmeb commented 1 month ago

Which OS are you running? I have a few Raspberry Pi Zero 2 Ws and they run both 64 bit Ubuntu 22.04 Server and PiOS legacy 64 bit "lite", They won't run the latest Ubuntu 24.04 Server - that requires 1 GB of RAM - and I haven't been able to get either 32 or 64 bit current PiOS to run - dpkg hangs up unpacking some packages.

bwhitman commented 1 month ago

@Olifiers I think we fixed this by making resampy optional, only needed if you want to generate your own PCM headers into the AMY binary. I'm sure there's a way to get resampy to work on a pi0, but since only very few people will want to generate their own PCM headers I think it's fine to make this optional in the build.

I will note on my rpi0 (1st version) I had to also run sudo apt install libopenblas0 to get numpy to work, but then make test works just fine on the latest main version here.

Olifiers commented 1 month ago

I'm running on Raspbian bookworm. Because its the RPi Zero, it's 32bits.

I can install libamy (see below). But if I try to make (or make test), I run into the requirement for llmv for resampy (sf2utils I can install via pip). Also, without make, I can't seem to be able to use amy at all, since none of the functions of libamy seem to work in python.

  1. Install the library (env) pi@morgana:~/amy $ cd src (env) pi@morgana:~/amy/src $ pip install . Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Processing /home/pi/amy/src Preparing metadata (setup.py) ... done Building wheels for collected packages: libamy Building wheel for libamy (setup.py) ... done Created wheel for libamy: filename=libamy-0.0.0-cp311-cp311-linux_armv7l.whl size=1486307 sha256=c3edb4a385bc113e90e754bdca9aeb220120994e0bb48d9566dc571f51dbac24 Stored in directory: /tmp/pip-ephem-wheel-cache-ej31n5a8/wheels/82/87/ab/5c94b71582cdfdeadc2a9d1603d97acfbe2410aaee97292d74 Successfully built libamy Installing collected packages: libamy Successfully installed libamy-0.0.0 (env) pi@morgana:~/amy/src $

  2. Trying (and failing) to make: `(env) pi@morgana:~/amy $ pip install resampy Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting resampy Downloading https://www.piwheels.org/simple/resampy/resampy-0.4.3-py3-none-any.whl (3.1 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.1/3.1 MB 1.9 MB/s eta 0:00:00 Requirement already satisfied: numpy>=1.17 in /usr/lib/python3/dist-packages (from resampy) (1.24.2) Collecting numba>=0.53 Downloading https://www.piwheels.org/simple/numba/numba-0.60.0-cp311-cp311-linux_armv7l.whl (3.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.3/3.3 MB 2.0 MB/s eta 0:00:00 WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))': /simple/llvmlite/ Collecting llvmlite<0.44,>=0.43.0dev0 Downloading llvmlite-0.43.0.tar.gz (157 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 157.1/157.1 kB 1.1 MB/s eta 0:00:00 Preparing metadata (setup.py) ... done Building wheels for collected packages: llvmlite Building wheel for llvmlite (setup.py) ... error error: subprocess-exited-with-error

    × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [11 lines of output] running bdist_wheel /home/pi/env/bin/python3 /tmp/pip-install-1ht3_a40/llvmlite_16c7899cece5474ab1debff1f3558e9d/ffi/build.py LLVM version... Traceback (most recent call last): File "/tmp/pip-install-1ht3_a40/llvmlite_16c7899cece5474ab1debff1f3558e9d/ffi/build.py", line 235, in main() File "/tmp/pip-install-1ht3_a40/llvmlite_16c7899cece5474ab1debff1f3558e9d/ffi/build.py", line 225, in main main_posix('linux', '.so') File "/tmp/pip-install-1ht3_a40/llvmlite_16c7899cece5474ab1debff1f3558e9d/ffi/build.py", line 142, in main_posix raise RuntimeError(msg) from None RuntimeError: Could not find a llvm-config binary. There are a number of reasons this could occur, please see: https://llvmlite.readthedocs.io/en/latest/admin-guide/install.html#using-pip for help. error: command '/home/pi/env/bin/python3' failed with exit code 1 [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for llvmlite Running setup.py clean for llvmlite Failed to build llvmlite Installing collected packages: llvmlite, numba, resampy Running setup.py install for llvmlite ... error error: subprocess-exited-with-error

    × Running setup.py install for llvmlite did not run successfully. │ exit code: 1 ╰─> [16 lines of output] running install /home/pi/env/lib/python3.11/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build got version from file /tmp/pip-install-1ht3_a40/llvmlite_16c7899cece5474ab1debff1f3558e9d/llvmlite/_version.py {'version': '0.43.0', 'full': '6c786059354260a0ae93f9d0144d4016ab3d63b4'} running build_ext /home/pi/env/bin/python3 /tmp/pip-install-1ht3_a40/llvmlite_16c7899cece5474ab1debff1f3558e9d/ffi/build.py LLVM version... Traceback (most recent call last): File "/tmp/pip-install-1ht3_a40/llvmlite_16c7899cece5474ab1debff1f3558e9d/ffi/build.py", line 235, in main() File "/tmp/pip-install-1ht3_a40/llvmlite_16c7899cece5474ab1debff1f3558e9d/ffi/build.py", line 225, in main main_posix('linux', '.so') File "/tmp/pip-install-1ht3_a40/llvmlite_16c7899cece5474ab1debff1f3558e9d/ffi/build.py", line 142, in main_posix raise RuntimeError(msg) from None RuntimeError: Could not find a llvm-config binary. There are a number of reasons this could occur, please see: https://llvmlite.readthedocs.io/en/latest/admin-guide/install.html#using-pip for help. error: command '/home/pi/env/bin/python3' failed with exit code 1 [end of output]

    note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure

× Encountered error while trying to install package. ╰─> llvmlite

note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure. (env) pi@morgana:~/amy $ `

Olifiers commented 1 month ago

With the never version, I was able to run 'make'. But 'make test' fails, with the following:

$ make python3 amy_headers.py Generating all headers needed for AMY (except for partials patches, see partials.py if you want to DIY... wrote src/saw_lutset_fxpt.h wrote src/triangle_lutset_fxpt.h wrote src/sine_lutset_fxpt.h wrote src/log2_exp2_fxpt_lutable.h wrote src/clipping_lookup_table.h If you want to regenerate the PCM headers (not required!) you need to pip install resampy sf2utils. Done. gcc -g -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations -DAMY_DEBUG -c src/algorithms.c -o src/algorithms.o gcc -g -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations -DAMY_DEBUG -c src/amy.c -o src/amy.o gcc -g -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations -DAMY_DEBUG -c src/envelope.c -o src/envelope.o gcc -g -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations -DAMY_DEBUG -c src/delay.c -o src/delay.o gcc -g -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations -DAMY_DEBUG -c src/partials.c -o src/partials.o gcc -g -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations -DAMY_DEBUG -c src/custom.c -o src/custom.o gcc -g -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations -DAMY_DEBUG -c src/patches.c -o src/patches.o gcc -g -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations -DAMY_DEBUG -c src/examples.c -o src/examples.o gcc -g -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations -DAMY_DEBUG -c src/filters.c -o src/filters.o src/filters.c:588:1: warning: ‘inline’ is not at beginning of declaration [-Wold-style-declaration] 588 | static SAMPLE inline MAXABS2(SAMPLE a, SAMPLE b) { | ^~ gcc -g -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations -DAMY_DEBUG -c src/oscillators.c -o src/oscillators.o gcc -g -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations -DAMY_DEBUG -c src/pcm.c -o src/pcm.o gcc -g -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations -DAMY_DEBUG -c src/log2_exp2.c -o src/log2_exp2.o gcc -g -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations -DAMY_DEBUG -c src/libminiaudio-audio.c -o src/libminiaudio-audio.o gcc -g -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations -DAMY_DEBUG -c src/amy-example.c -o src/amy-example.o gcc src/algorithms.o src/amy.o src/envelope.o src/delay.o src/partials.o src/custom.o src/patches.o src/examples.o src/filters.o src/oscillators.o src/pcm.o src/log2_exp2.o src/libminiaudio-audio.o src/amy-example.o -Wall -lpthread -lm -ldl -latomic -o amy-example gcc -g -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wpointer-arith -Wno-float-conversion -Wno-missing-declarations -DAMY_DEBUG -c src/amy-message.c -o src/amy-message.o gcc src/algorithms.o src/amy.o src/envelope.o src/delay.o src/partials.o src/custom.o src/patches.o src/examples.o src/filters.o src/oscillators.o src/pcm.o src/log2_exp2.o src/libminiaudio-audio.o src/amy-message.o -Wall -lpthread -lm -ldl -latomic -o amy-message

$ make test python3 -m pip install -r requirements.txt; touch src/amy.c; cd src; python3 -m pip install . --force-reinstall; cd .. Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Requirement already satisfied: numpy in /usr/lib/python3/dist-packages (from -r requirements.txt (line 1)) (1.24.2) Collecting scipy Downloading https://www.piwheels.org/simple/scipy/scipy-1.14.0-cp311-cp311-linux_armv7l.whl (25.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 25.2/25.2 MB 1.2 MB/s eta 0:00:00 Installing collected packages: scipy Successfully installed scipy-1.14.0 Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Processing /home/pi/amy/src Preparing metadata (setup.py) ... done Building wheels for collected packages: libamy Building wheel for libamy (setup.py) ... done Created wheel for libamy: filename=libamy-0.0.0-cp311-cp311-linux_armv7l.whl size=1486396 sha256=8dc8bb734302ef61616800d518bf05b17a8e04db1be3834ff6d7bc6872f791ff Stored in directory: /tmp/pip-ephem-wheel-cache-j39mr4gl/wheels/82/87/ab/5c94b71582cdfdeadc2a9d1603d97acfbe2410aaee97292d74 Successfully built libamy Installing collected packages: libamy Attempting uninstall: libamy Found existing installation: libamy 0.0.0 Uninstalling libamy-0.0.0: Successfully uninstalled libamy-0.0.0 Successfully installed libamy-0.0.0 python3 test.py Traceback (most recent call last): File "/home/pi/amy/test.py", line 5, in import scipy.io.wavfile as wav File "/home/pi/env/lib/python3.11/site-packages/scipy/io/init.py", line 97, in from .matlab import loadmat, savemat, whosmat File "/home/pi/env/lib/python3.11/site-packages/scipy/io/matlab/init.py", line 45, in from ._mio import loadmat, savemat, whosmat File "/home/pi/env/lib/python3.11/site-packages/scipy/io/matlab/_mio.py", line 9, in from ._mio4 import MatFile4Reader, MatFile4Writer File "/home/pi/env/lib/python3.11/site-packages/scipy/io/matlab/_mio4.py", line 9, in import scipy.sparse File "/home/pi/env/lib/python3.11/site-packages/scipy/sparse/init.py", line 307, in from . import csgraph File "/home/pi/env/lib/python3.11/site-packages/scipy/sparse/csgraph/init.py", line 187, in from ._laplacian import laplacian File "/home/pi/env/lib/python3.11/site-packages/scipy/sparse/csgraph/_laplacian.py", line 7, in from scipy.sparse.linalg import LinearOperator File "/home/pi/env/lib/python3.11/site-packages/scipy/sparse/linalg/init.py", line 129, in from ._isolve import File "/home/pi/env/lib/python3.11/site-packages/scipy/sparse/linalg/_isolve/init.py", line 4, in from .iterative import File "/home/pi/env/lib/python3.11/site-packages/scipy/sparse/linalg/_isolve/iterative.py", line 5, in from scipy.linalg import get_lapack_funcs File "/home/pi/env/lib/python3.11/site-packages/scipy/linalg/init.py", line 203, in from ._misc import * File "/home/pi/env/lib/python3.11/site-packages/scipy/linalg/_misc.py", line 3, in from .blas import get_blas_funcs File "/home/pi/env/lib/python3.11/site-packages/scipy/linalg/blas.py", line 213, in from scipy.linalg import _fblas ImportError: libopenblas.so.0: cannot open shared object file: No such file or directory make: *** [Makefile:72: test] Error 1 (env) pi@morgana:~/amy $

bwhitman commented 1 month ago

Yep, did you do the sudo apt install libopenblas0 ?

Olifiers commented 1 month ago

Works now, thanks!

bwhitman commented 1 month ago

Great, thanks!