Post

Replies

Boosts

Views

Activity

🔇Unable to run audio libraries in tensorflow-metal virtual environment
Hello, I made a post earlier comparing the performance between the latest release of tensorflow with apple silicon support: https://developer.apple.com/forums/thread/687654. In my testing the GitHub alpha greatly outperforms the current release. I provided an installation guide for the GitHub alpha in that post. sounddevice: https://pypi.org/project/sounddevice/ My goal is to get the python library sounddevice working in either of the virtual environments created by the two different tensorflow releases for apple silicon. Preferably the GitHub alpha, since its much faster. The two releases being the current release https://developer.apple.com/metal/tensorflow-plugin/ using a conda virtual environment, or the GitHub alpha release which can be setup using the installer script. GitHub alpha venv errors Installation: First I make an environment following the installation guide I provided in my first post (linked above). I activate the virtual environment I install sounddevice using the following command: $ python3 -m pip install sounddevice When I try to import sounddevice I get the following errors: Traceback (most recent call last): File "/Users/sadedwar/code/fun/ga-synth/venv/lib/python3.8/site-packages/sounddevice.py", line 72, in <module> _lib = _ffi.dlopen(_libname) OSError: cannot load library '/usr/local/lib/libportaudio.dylib': dlopen(/usr/local/lib/libportaudio.dylib, 2): no suitable image found. Did find: /usr/local/lib/libportaudio.dylib: mach-o, but wrong architecture /usr/local/Cellar/portaudio/19.7.0/lib/libportaudio.2.dylib: mach-o, but wrong architecture tensorflow-metal PluggableDevice errors Installation: exactly as described in: https://developer.apple.com/metal/tensorflow-plugin/ I install python-sounddevice from: https://anaconda.org/conda-forge/python-sounddevice importing works fine When I try to run the following code: myrecording = sd.rec(int(duration * samplerate), samplerate=samplerate, channels=channels) it yields this error: Traceback (most recent call last): File "/Users/sadedwar/code/fun/ga-synth/makeDatasets.py", line 41, in <module> render_dataset(make_simple_dataset(100)) File "/Users/sadedwar/code/fun/ga-synth/makeDatasets.py", line 37, in render_dataset data, samplerate = audioRecorder.play_and_rec() File "/Users/sadedwar/code/fun/ga-synth/audioRecorder.py", line 29, in play_and_rec recording, samplerate = rec_mono_16bit_8kHz(duration=0.1) File "/Users/sadedwar/code/fun/ga-synth/audioRecorder.py", line 17, in rec_mono_16bit_8kHz myrecording = sd.rec(int(duration * samplerate), samplerate=samplerate, channels=channels) File "/Users/sadedwar/miniforge3/envs/machinelearning/lib/python3.9/site-packages/sounddevice.py", line 274, in rec ctx.start_stream(InputStream, samplerate, ctx.input_channels, File "/Users/sadedwar/miniforge3/envs/machinelearning/lib/python3.9/site-packages/sounddevice.py", line 2573, in start_stream self.stream = StreamClass(samplerate=samplerate, File "/Users/sadedwar/miniforge3/envs/machinelearning/lib/python3.9/site-packages/sounddevice.py", line 1415, in __init__ _StreamBase.__init__(self, kind='input', wrap_callback='array', File "/Users/sadedwar/miniforge3/envs/machinelearning/lib/python3.9/site-packages/sounddevice.py", line 836, in __init__ def callback_ptr(iptr, optr, frames, time, status, _): MemoryError: Cannot allocate write+execute memory for ffi.callback(). You might be running on a system that prevents this. For more information, see https://cffi.readthedocs.io/en/latest/using.html#callbacks Any help is appreciated, thank you.
0
0
1.2k
Aug ’21
🤔 GitHub tensorflow macOS alpha had better performance on M1?
Hello, I noticed a substantial decrease in performance compared to previous releases of tensorflow for M1 Macs. I previously installed the alpha release of tensorflow for M1 from GitHub, found here: https://github.com/apple/tensorflow_macos and was very impressed by the performance. I used the following script to benchmark my M1 Mac and other systems: https://gist.github.com/tampapath/662aca8cd0ef6790ade1bf3c23fe611a#file-fashin_mnist-py Running the alpha release from GitHub, my M1 Mac handsomely outperformed both google colab's random GPU offerings and an RTX 2070 windows computer. Recently, I went back to the GitHub repository, looking for new updates on tensorflow support for the M1 and was redirected here to the tensorflow-metal PluggableDevices installation guide: https://developer.apple.com/metal/tensorflow-plugin/ After installing the conda environment and running the same benchmark script, I realized my M1 systems's was running much slower. Additionally, the following error messages printed to the console while running the benchmark: 2021-08-12 21:48:16.306946: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:305] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support. 2021-08-12 21:48:16.307209: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:271] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>) 2021-08-12 21:48:16.437942: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:176] None of the MLIR Optimization Passes are enabled (registered 2) 2021-08-12 21:48:16.441196: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz Has anyone else noticed this loss in performance? The results I got are as follow: benchmark script duration tf GitHub alpha 🟢 9.62s new tf-metal 🔴 76.52s google colab 🔴 57.53s RTX 2070 PC 🔴 23.18s both tf GitHub alpha and new tf-metal were ran on the same 13" M1 MacBook Pro. I wrote an installation guide for the GitHub alpha release if anyone wants to compare results, or run a faster version of tensorflow compatible with their M1 Mac: https://github.com/apple/tensorflow_macos/issues/215
7
0
3.8k
Aug ’21