Torchaudio on M1 Mac

The nightly builds for torchaudio doesn’t include an apple silicon version. Is there some way to get it working with the accelerated versions of torch?

Official install instructions for the nightly build results in a broken install:

conda install pytorch torchvision torchaudio -c pytorch-nightly
PackagesNotFoundError: The following packages are not available from current channels:

  - torchaudio

Installing with pip works for torch but results in an old and nonfunctional torchaudio install

$ conda create --prefix ./env python=3.8
$ pip install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cpu
$ python
Python 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:05:16)
[Clang 12.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> t = torch.rand((5000, 5000))
>>> t.to("mps")
/Users/jnordberg/Development/ai-test/env/lib/python3.8/site-packages/torch/_tensor_str.py:103: UserWarning: The operator 'aten::bitwise_and.Tensor_out' is not currently supported on the MPS backend and will fall back to run on the CPU. This may have performance implications. (Triggered internally at  /Users/runner/work/pytorch/pytorch/pytorch/aten/src/ATen/mps/MPSFallback.mm:11.)
  nonzero_finite_vals = torch.masked_select(tensor_view, torch.isfinite(tensor_view) & tensor_view.ne(0))
tensor([[0.0358, 0.0252, 0.4214,  ..., 0.3951, 0.4220, 0.6450],
        [0.1549, 0.2162, 0.4747,  ..., 0.0031, 0.3685, 0.0765],
        [0.4907, 0.2168, 0.1521,  ..., 0.9504, 0.2354, 0.0886],
        ...,
        [0.0660, 0.9352, 0.7378,  ..., 0.4013, 0.7652, 0.5129],
        [0.6175, 0.1057, 0.8243,  ..., 0.2603, 0.3197, 0.2865],
        [0.3469, 0.0792, 0.8062,  ..., 0.4482, 0.5842, 0.5278]],
       device='mps:0')
>>> import torchaudio
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jnordberg/Development/ai-test/env/lib/python3.8/site-packages/torchaudio/__init__.py", line 1, in <module>
    from torchaudio import _extension  # noqa: F401
  File "/Users/jnordberg/Development/ai-test/env/lib/python3.8/site-packages/torchaudio/_extension.py", line 67, in <module>
    _init_extension()
  File "/Users/jnordberg/Development/ai-test/env/lib/python3.8/site-packages/torchaudio/_extension.py", line 61, in _init_extension
    _load_lib("libtorchaudio")
  File "/Users/jnordberg/Development/ai-test/env/lib/python3.8/site-packages/torchaudio/_extension.py", line 51, in _load_lib
    torch.ops.load_library(path)
  File "/Users/jnordberg/Development/ai-test/env/lib/python3.8/site-packages/torch/_ops.py", line 255, in load_library
    ctypes.CDLL(path)
  File "/Users/jnordberg/Development/ai-test/env/lib/python3.8/ctypes/__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Users/jnordberg/Development/ai-test/env/lib/python3.8/site-packages/torchaudio/lib/libtorchaudio.so, 0x0006): Symbol not found: __ZN2at14RecordFunctionC1ENS_11RecordScopeEb
  Referenced from: /Users/jnordberg/Development/ai-test/env/lib/python3.8/site-packages/torchaudio/lib/libtorchaudio.so
  Expected in: /Users/jnordberg/Development/ai-test/env/lib/python3.8/site-packages/torch/lib/libtorch_cpu.dylib

Hi,

Right now, you will have to install torchaudio from source to get it to work with nightly pytorch on arm.
We are working towards adding these right now, see the PR for vision here: Add TorchVision wheel builds for M1 by malfet · Pull Request #5948 · pytorch/vision · GitHub