Errors building torchaudio with Pytorch 2.13.0, CUDA 13.3.1, GCC 15.3.0

With Pytorch 2.13.0, CUDA 13.3.1, GCC 15.3.0; I’m getting many build errors.
pip install -e . --no-deps --no-build-isolation:

Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///tmp/audio
  Checking if build backend supports build_editable: started
  Checking if build backend supports build_editable: finished with status 'done'
  Preparing editable metadata (pyproject.toml): started
  Preparing editable metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: torchaudio
  Building editable for torchaudio (pyproject.toml): started
  Building editable for torchaudio (pyproject.toml): finished with status 'error'
  error: subprocess-exited-with-error
  
  × Building editable for torchaudio (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [8973 lines of output]
      /home/geremia/.local/lib/python3.12/site-packages/setuptools/dist.py:765: SetuptoolsDeprecationWarning: License classifiers are deprecated.
      !!
      
              ********************************************************************************
              Please consider removing the following classifiers in favor of a SPDX license expression:
      
              License :: OSI Approved :: BSD License
      
              See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
              ********************************************************************************
      
      !!
        self._finalize_license_expression()
      -- Git branch: main
      -- Git SHA: 4e3e282b0e23a0b9133abc8f719e2fa39be2a6e3
      -- Git tag: None
      -- Building version 2.11.0a0+4e3e282
      running editable_wheel
      creating /tmp/pip-ephem-wheel-cache-locw9zdq/wheels/79/c4/93/eeda50fa794d74362aa169fae3586975eb9bf1eb372a512457/tmpbod3ti1e/.tmp-a3_g3sr0/torchaudio.egg-info
      writing /tmp/pip-ephem-wheel-cache-locw9zdq/wheels/79/c4/93/eeda50fa794d74362aa169fae3586975eb9bf1eb372a512457/tmpbod3ti1e/.tmp-a3_g3sr0/torchaudio.egg-info/PKG-INFO
      writing dependency_links to /tmp/pip-ephem-wheel-cache-locw9zdq/wheels/79/c4/93/eeda50fa794d74362aa169fae3586975eb9bf1eb372a512457/tmpbod3ti1e/.tmp-a3_g3sr0/torchaudio.egg-info/dependency_links.txt
      writing top-level names to /tmp/pip-ephem-wheel-cache-locw9zdq/wheels/79/c4/93/eeda50fa794d74362aa169fae3586975eb9bf1eb372a512457/tmpbod3ti1e/.tmp-a3_g3sr0/torchaudio.egg-info/top_level.txt
      writing manifest file '/tmp/pip-ephem-wheel-cache-locw9zdq/wheels/79/c4/93/eeda50fa794d74362aa169fae3586975eb9bf1eb372a512457/tmpbod3ti1e/.tmp-a3_g3sr0/torchaudio.egg-info/SOURCES.txt'
      adding license file 'LICENSE'
      writing manifest file '/tmp/pip-ephem-wheel-cache-locw9zdq/wheels/79/c4/93/eeda50fa794d74362aa169fae3586975eb9bf1eb372a512457/tmpbod3ti1e/.tmp-a3_g3sr0/torchaudio.egg-info/SOURCES.txt'
      creating '/tmp/pip-ephem-wheel-cache-locw9zdq/wheels/79/c4/93/eeda50fa794d74362aa169fae3586975eb9bf1eb372a512457/tmpbod3ti1e/.tmp-a3_g3sr0/torchaudio-2.11.0a0+4e3e282.dist-info'
      creating /tmp/pip-ephem-wheel-cache-locw9zdq/wheels/79/c4/93/eeda50fa794d74362aa169fae3586975eb9bf1eb372a512457/tmpbod3ti1e/.tmp-a3_g3sr0/torchaudio-2.11.0a0+4e3e282.dist-info/WHEEL
      running build_py
      running build_ext
      W0830 20:31:43.116000 16450 site-packages/torch/utils/cpp_extension.py:657] There are no g++ version bounds defined for CUDA version 13.3
      building 'torchaudio.lib._torchaudio' extension
      [1/2] ccache c++ -MMD -MF '/tmp/tmpgvfi885p.build-temp/tmp/audio/src/libtorchaudio/_torchaudio.o'.d -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC '-I/tmp/audio/src' -I/usr/lib64/python3.12/site-packages/torch/include -I/usr/lib64/python3.12/site-packages/torch/include/torch/csrc/api/include -I/opt/cuda-13.3/include -I/usr/include/python3.12 -c -c '/tmp/audio/src/libtorchaudio/_torchaudio.cpp' -o '/tmp/tmpgvfi885p.build-temp/tmp/audio/src/libtorchaudio/_torchaudio.o' -DTORCH_TARGET_VERSION=0x020a000000000000 -fdiagnostics-color=always -DUSE_CUDA -DINCLUDE_ALIGN -DTORCH_API_INCLUDE_EXTENSION_H -DPy_LIMITED_API=0x030A0000 -DTORCH_EXTENSION_NAME=_torchaudio -std=c++20
      FAILED: [code=1] /tmp/tmpgvfi885p.build-temp/tmp/audio/src/libtorchaudio/_torchaudio.o
      ccache c++ -MMD -MF '/tmp/tmpgvfi885p.build-temp/tmp/audio/src/libtorchaudio/_torchaudio.o'.d -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC '-I/tmp/audio/src' -I/usr/lib64/python3.12/site-packages/torch/include -I/usr/lib64/python3.12/site-packages/torch/include/torch/csrc/api/include -I/opt/cuda-13.3/include -I/usr/include/python3.12 -c -c '/tmp/audio/src/libtorchaudio/_torchaudio.cpp' -o '/tmp/tmpgvfi885p.build-temp/tmp/audio/src/libtorchaudio/_torchaudio.o' -DTORCH_TARGET_VERSION=0x020a000000000000 -fdiagnostics-color=always -DUSE_CUDA -DINCLUDE_ALIGN -DTORCH_API_INCLUDE_EXTENSION_H -DPy_LIMITED_API=0x030A0000 -DTORCH_EXTENSION_NAME=_torchaudio -std=c++20
      In file included from <command-line>:
      /usr/include/stdc-predef.h:68:2: error: #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
         68 | #error "This file should not be included when either TORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."
            |  ^~~~~
      In file included from /usr/lib64/gcc/x86_64-slackware-linux/15.3.0/include/stdint.h:11,
                       from /usr/include/torch/csrc/inductor/aoti_torch/c/macros.h:5,
                       from /usr/include/torch/csrc/inductor/aoti_torch/c/shim.h:4,
                       from /usr/include/torch/csrc/stable/c/shim.h:4,
                       from /usr/include/torch/csrc/stable/device_inl.h:8,
                       from /usr/include/torch/csrc/stable/device.h:3,
                       from /tmp/audio/src/libtorchaudio/utils.h:3,
                       from /tmp/audio/src/libtorchaudio/_torchaudio.cpp:1:
      /usr/include/stdint.h:318:2: error: #error "This file should not be included when either ORCH_STABLE_ONLY or TORCH_TARGET_VERSION is defined."

⋮

[⋮]

⋮
nsor_inl.h:73:1: error: no matching function for call to ‘stdTorchCheckMsgImpl(const char [181], const char [31], const char [3], const char [44], const char [2], int, const char [3], const char [39], const char*)’
         73 | DEFINE_CAST(uint32_t, UInt32)
            | ^~~~~~~~~~~
      /usr/include/torch/csrc/stable/tensor_inl.h:73:1: note: there are 2 candidates
      /usr/include/torch/headeronly/util/Exception.h:53:20: note: candidate 1: ‘const char* torch::headeronly::detail::stdTorchCheckMsgImpl(const char*)’
         53 | inline const char* stdTorchCheckMsgImpl(const char* msg) {
            |                    ^~~~~~~~~~~~~~~~~~~~
      /usr/include/torch/headeronly/util/Exception.h:53:20: note: candidate expects 1 argument, 9 provided
      /usr/include/torch/headeronly/util/Exception.h:57:20: note: candidate 2: ‘const char* torch::headeronly::detail::stdTorchCheckMsgImpl(const char*, const char*)’
         57 | inline const char* stdTorchCheckMsgImpl(const char* /*msg*/, const char* args) {
            |                    ^~~~~~~~~~~~~~~~~~~~
      /usr/include/torch/headeronly/util/Exception.h:57:20: note: candidate expects 2 arguments, 9 provided
      /usr/include/torch/csrc/stable/tensor_inl.h: At global scope:
      /usr/include/torch/csrc/stable/tensor_inl.h:73:1: error: template-id ‘const_data_ptr<>’ for ‘const uint32_t* torch::stable::Tensor::const_data_ptr() const’ does not match any template declaration
         73 | DEFINE_CAST(uint32_t, UInt32)
            | ^~~~~~~~~~~
      /usr/include/torch/csrc/stable/tensor_struct.h:184:12: note: candidates are: ‘template<class T, <typeprefixerror><anonymous> > const T* torch::stable::Tensor::const_data_ptr() const’
        184 |   const T* const_data_ptr() const;
            |            ^~~~~~~~~~~~~~
      /usr/include/torch/csrc/stable/tensor_struct.h:156:15: note:                 ‘const void* torch::stable::Tensor::const_data_ptr() const’
        156 |   const void* const_data_ptr() const {
            |               ^~~~~~~~~~~~~~
      /usr/include/torch/csrc/stable/tensor_inl.h: In member function ‘T* torch::stable::Tensor::mutable_data_ptr() const [with T = long unsigned int]’:
      /usr/include/torch/csrc/stable/tensor_inl.h:74:1: error: ‘runtime_error’ is not a member of ‘std’
         74 | DEFINE_CAST(uint64_t, UInt64)
            | ^~~~~~~~~~~
      /usr/include/torch/csrc/stable/tensor_inl.h:74:1: note: ‘std::runtime_error’ is defined in header ‘<stdexcept>’; this is probably fixable by adding ‘#include <stdexcept>’
      /usr/include/torch/csrc/stable/tensor_inl.h:74:1: error: no matching function for call to ‘stdTorchCheckMsgImpl(const char [181], const char [36], const char [3], const char [44], const char [2], int, const char [3], const char [39], const char*)’
         74 | DEFINE_CAST(uint64_t, UInt64)
            | ^~~~~~~~~~~
      /usr/include/torch/csrc/stable/tensor_inl.h:74:1: note: there are 2 candidates
      /usr/include/torch/headeronly/util/Exception.h:53:20: note: candidate 1: ‘const char* torch::headeronly::detail::stdTorchCheckMsgImpl(const char*)’
         53 | inline const char* stdTorchCheckMsgImpl(const char* msg) {
            |                    ^~~~~~~~~~~~~~~~~~~~
      /usr/include/torch/headeronly/util/Exception.h:53:20: note: candidate expects 1 argument, 9 provided
      /usr/include/torch/headeronly/util/Exception.h:57:20: note: candidate 2: ‘const char* torch::headeronly::detail::stdTorchCheckMsgImpl(const char*, const char*)’
         57 | inline const char* stdTorchCheckMsgImpl(const char* /*msg*/, const char* args) {
            |                    ^~~~~~~~~~~~~~~~~~~~
      /usr/include/torch/headeronly/util/Exception.h:57:20: note: candidate expects 2 arguments, 9 provided
      /usr/include/torch/csrc/stable/tensor_inl.h: At global scope:
      /usr/include/torch/csrc/stable/tensor_inl.h:74:1: error: template-id ‘const_data_ptr<>’ for ‘const uint64_t* torch::stable::Tensor::const_data_ptr() const’ does not match any template declaration
         74 | DEFINE_CAST(uint64_t, UInt64)
            | ^~~~~~~~~~~
      /usr/include/torch/csrc/stable/tensor_struct.h:184:12: note: candidates are: ‘template<class T, <typeprefixerror><anonymous> > const T* torch::stable::Tensor::const_data_ptr() const’
        184 |   const T* const_data_ptr() const;
            |            ^~~~~~~~~~~~~~
      /usr/include/torch/csrc/stable/tensor_struct.h:156:15: note:                 ‘const void* torch::stable::Tensor::const_data_ptr() const’
        156 |   const void* const_data_ptr() const {
            |               ^~~~~~~~~~~~~~
      In file included from /tmp/audio/src/libtorchaudio/utils.h:6:
      /usr/include/torch/headeronly/core/TensorAccessor.h:187:20: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type [-Wtemplate-body]
        187 |       class = std::enable_if_t<std::is_same_v<source_index_t, int64_t>>>
            |                    ^~~~~~~~~~~
      /usr/include/torch/headeronly/core/TensorAccessor.h:1:1: note: ‘std::enable_if_t’ is defined in header ‘<type_traits>’; this is probably fixable by adding ‘#include <type_traits>’
        +++ |+#include <type_traits>
          1 | #pragma once
      /usr/include/torch/headeronly/core/TensorAccessor.h:187:31: error: expected ‘>’ before ‘<’ token [-Wtemplate-body]
        187 |       class = std::enable_if_t<std::is_same_v<source_index_t, int64_t>>>
            |                               ^
      /usr/include/torch/headeronly/core/TensorAccessor.h: In constructor ‘torch::headeronly::detail::GenericPackedTensorAccessorBase<IndexBoundsCheck, T, N, PtrTraits, index_t>::GenericPackedTensorAccessorBase(PtrType, const index_t*, const index_t*)’:
      /usr/include/torch/headeronly/core/TensorAccessor.h:180:10: error: ‘copy’ is not a member of ‘std’ [-Wtemplate-body]
        180 |     std::copy(sizes_, sizes_ + N, std::begin(this->sizes_));
            |          ^~~~
      /usr/include/torch/headeronly/core/TensorAccessor.h:180:40: error: ‘begin’ is not a member of ‘std’ [-Wtemplate-body]
        180 |     std::copy(sizes_, sizes_ + N, std::begin(this->sizes_));
            |                                        ^~~~~
      /usr/include/torch/headeronly/core/TensorAccessor.h:1:1: note: ‘std::begin’ is defined in header ‘<iterator>’; this is probably fixable by adding ‘#include <iterator>’
        +++ |+#include <iterator>
          1 | #pragma once
      /usr/include/torch/headeronly/core/TensorAccessor.h:181:10: error: ‘copy’ is not a member of ‘std’ [-Wtemplate-body]
        181 |     std::copy(strides_, strides_ + N, std::begin(this->strides_));
            |          ^~~~
      /usr/include/torch/headeronly/core/TensorAccessor.h:181:44: error: ‘begin’ is not a member of ‘std’ [-Wtemplate-body]
        181 |     std::copy(strides_, strides_ + N, std::begin(this->strides_));
            |                                            ^~~~~
      /usr/include/torch/headeronly/core/TensorAccessor.h:181:44: note: ‘std::begin’ is defined in header ‘<iterator>’; this is probably fixable by adding ‘#include <iterator>’
      /usr/include/torch/headeronly/core/TensorAccessor.h: At global scope:
      /usr/include/torch/headeronly/core/TensorAccessor.h:253:20: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type [-Wtemplate-body]
        253 |       class = std::enable_if_t<std::is_same_v<source_index_t, int64_t>>>
            |                    ^~~~~~~~~~~
      /usr/include/torch/headeronly/core/TensorAccessor.h:253:15: note: ‘std::enable_if_t’ is defined in header ‘<type_traits>’; this is probably fixable by adding ‘#include <type_traits>’
        253 |       class = std::enable_if_t<std::is_same_v<source_index_t, int64_t>>>
            |               ^~~
      /usr/include/torch/headeronly/core/TensorAccessor.h:253:31: error: expected ‘>’ before ‘<’ token [-Wtemplate-body]
        253 |       class = std::enable_if_t<std::is_same_v<source_index_t, int64_t>>>
            |                               ^
      /usr/include/torch/headeronly/core/TensorAccessor.h: In member function ‘torch::headeronly::detail::GenericPackedTensorAccessor<ItemAccessor, IndexBoundsCheck, T, N, PtrTraits, index_t> torch::headeronly::detail::GenericPackedTensorAccessor<ItemAccessor, IndexBoundsCheck, T, N, PtrTraits, index_t>::transpose(index_t, index_t) const’:
      /usr/include/torch/headeronly/core/TensorAccessor.h:301:10: error: ‘swap’ is not a member of ‘std’ [-Wtemplate-body]
        301 |     std::swap(result.strides_[dim1], result.strides_[dim2]);
            |          ^~~~
      /usr/include/torch/headeronly/core/TensorAccessor.h:302:10: error: ‘swap’ is not a member of ‘std’ [-Wtemplate-body]
        302 |     std::swap(result.sizes_[dim1], result.sizes_[dim2]);
            |          ^~~~
      /usr/include/torch/headeronly/core/TensorAccessor.h: At global scope:
      /usr/include/torch/headeronly/core/TensorAccessor.h:342:20: error: ‘enable_if_t’ in namespace ‘std’ does not name a template type [-Wtemplate-body]
        342 |       class = std::enable_if_t<std::is_same_v<source_index_t, int64_t>>>
            |                    ^~~~~~~~~~~
      /usr/include/torch/headeronly/core/TensorAccessor.h:342:15: note: ‘std::enable_if_t’ is defined in header ‘<type_traits>’; this is probably fixable by adding ‘#include <type_traits>’
        342 |       class = std::enable_if_t<std::is_same_v<source_index_t, int64_t>>>
            |               ^~~
      /usr/include/torch/headeronly/core/TensorAccessor.h:342:31: error: expected ‘>’ before ‘<’ token [-Wtemplate-body]
        342 |       class = std::enable_if_t<std::is_same_v<source_index_t, int64_t>>>
            |                               ^
      /usr/include/torch/headeronly/core/TensorAccessor.h: In constructor ‘torch::headeronly::detail::HeaderOnlyIndexBoundsCheck<N, index_t>::HeaderOnlyIndexBoundsCheck(index_t)’:
      /usr/include/torch/headeronly/core/TensorAccessor.h:387:5: error: ‘runtime_error’ is not a member of ‘std’ [-Wtemplate-body]
        387 |     STD_TORCH_CHECK(
            |     ^~~~~~~~~~~~~~~
      /usr/include/torch/headeronly/core/TensorAccessor.h:1:1: note: ‘std::runtime_error’ is defined in header ‘<stdexcept>’; this is probably fixable by adding ‘#include <stdexcept>’
        +++ |+#include <stdexcept>
          1 | #pragma once
      /tmp/audio/src/libtorchaudio/utils.h: In function ‘T torchaudio::util::max(const torch::stable::Tensor&)’:
      /tmp/audio/src/libtorchaudio/utils.h:16:12: error: ‘nullopt’ is not a member of ‘std’ [-Wtemplate-body]
         16 |       std::nullopt,
            |            ^~~~~~~
      /tmp/audio/src/libtorchaudio/utils.h:7:1: note: ‘std::nullopt’ is defined in header ‘<optional>’; this is probably fixable by adding ‘#include <optional>’
          6 | #include <torch/headeronly/core/TensorAccessor.h>
        +++ |+#include <optional>
          7 |
      /tmp/audio/src/libtorchaudio/utils.h: At global scope:
      /tmp/audio/src/libtorchaudio/utils.h:23:6: error: ‘optional’ in namespace ‘std’ does not name a template type
         23 | std::optional<int64_t> cuda_version();
            |      ^~~~~~~~
      /tmp/audio/src/libtorchaudio/utils.h:23:1: note: ‘std::optional’ is defined in header ‘<optional>’; this is probably fixable by adding ‘#include <optional>’
         23 | std::optional<int64_t> cuda_version();
            | ^~~
      /tmp/audio/src/libtorchaudio/utils.cpp:17:6: error: ‘optional’ in namespace ‘std’ does not name a template type
         17 | std::optional<int64_t> cuda_version() {
            |      ^~~~~~~~
      /tmp/audio/src/libtorchaudio/utils.cpp:5:1: note: ‘std::optional’ is defined in header ‘<optional>’; this is probably fixable by adding ‘#include <optional>’
          4 | #include <cuda.h>
        +++ |+#include <optional>
          5 | #endif
      ninja: build stopped: subcommand failed.
      Traceback (most recent call last):
        File "/usr/lib64/python3.12/site-packages/torch/utils/cpp_extension.py", line 2893, in _run_ninja_build
          subprocess.run(
        File "/usr/lib64/python3.12/subprocess.py", line 571, in run
          raise CalledProcessError(retcode, process.args,
      subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.
      
      The above exception was the direct cause of the following exception:
      
      Traceback (most recent call last):
        File "/usr/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
          main()
        File "/usr/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
          json_out["return_val"] = hook(**hook_input["kwargs"])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 303, in build_editable
          return hook(wheel_directory, config_settings, metadata_directory)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/build_meta.py", line 474, in build_editable
          return self._build_with_temp_dir(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/build_meta.py", line 410, in _build_with_temp_dir
          self.run_setup()
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/build_meta.py", line 520, in run_setup
          super().run_setup(setup_script=setup_script)
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/build_meta.py", line 317, in run_setup
          exec(code, locals())  # noqa: S102 # exec is intentional here
          ^^^^^^^^^^^^^^^^^^^^
        File "<string>", line 148, in <module>
        File "<string>", line 103, in _main
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/__init__.py", line 117, in setup
          return distutils.core.setup(**attrs)  # type: ignore[return-value]
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 168, in setup
          return run_commands(dist)
                 ^^^^^^^^^^^^^^^^^^
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 184, in run_commands
          dist.run_commands()
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 1028, in run_commands
          self.run_command(cmd)
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/dist.py", line 1106, in run_command
          super().run_command(command)
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 1047, in run_command
          cmd_obj.run()
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/command/editable_wheel.py", line 142, in run
          self._create_wheel_file(bdist_wheel)
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/command/editable_wheel.py", line 352, in _create_wheel_file
          files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/command/editable_wheel.py", line 275, in _run_build_commands
          self._run_build_subcommands()
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/command/editable_wheel.py", line 302, in _run_build_subcommands
          self.run_command(name)
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/_distutils/cmd.py", line 342, in run_command
          self.distribution.run_command(command)
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/dist.py", line 1106, in run_command
          super().run_command(command)
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 1047, in run_command
          cmd_obj.run()
        File "/usr/lib/python3.12/site-packages/scikit_build_core/setuptools/build_cmake.py", line 870, in run
          super().run()
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/command/build_ext.py", line 95, in run
          _build_ext.run(self)
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 382, in run
          self.build_extensions()
        File "/usr/lib64/python3.12/site-packages/torch/utils/cpp_extension.py", line 1289, in build_extensions
          super().build_extensions()
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 498, in build_extensions
          self._build_extensions_serial()
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 524, in _build_extensions_serial
          self.build_extension(ext)
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/command/build_ext.py", line 260, in build_extension
          _build_ext.build_extension(self, ext)
        File "/usr/lib64/python3.12/site-packages/Cython/Distutils/build_ext.py", line 140, in build_extension
          super().build_extension(ext)
        File "/home/geremia/.local/lib/python3.12/site-packages/setuptools/_distutils/command/build_ext.py", line 585, in build_extension
          objects = self.compiler.compile(
                    ^^^^^^^^^^^^^^^^^^^^^^
        File "/usr/lib64/python3.12/site-packages/torch/utils/cpp_extension.py", line 1027, in unix_wrap_ninja_compile
          _write_ninja_file_and_compile_objects(
        File "/usr/lib64/python3.12/site-packages/torch/utils/cpp_extension.py", line 2475, in _write_ninja_file_and_compile_objects
          _run_ninja_build(
        File "/usr/lib64/python3.12/site-packages/torch/utils/cpp_extension.py", line 2910, in _run_ninja_build
          raise RuntimeError(message) from e
      RuntimeError: Error compiling objects for extension
      An error occurred when building editable wheel for torchaudio.
      See debugging tips in: https://setuptools.pypa.io/en/latest/userguide/development_mode.html#debugging-tips
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building editable for torchaudio
Failed to build torchaudio
error: failed-wheel-build-for-install

× Failed to build installable wheels for some pyproject.toml based projects
╰─> torchaudio
collect_env.py output
Collecting environment information...
PyTorch version: 2.13.0a0
Is debug build: False
CUDA used to build PyTorch: 13.3
ROCM used to build PyTorch: N/A

OS: Slackware Linux  (x86_64)
GCC version: (GCC) 15.3.0
Clang version: 22.1.8
CMake version: version 4.4.3
Libc version: glibc-2.43

Python version: 3.12.14 (main, Aug 13 2026, 15:48:25) [GCC 15.3.0] (64-bit runtime)
Python platform: Linux-7.2.0-x86_64-AMD_Ryzen_Threadripper_2990WX_32-Core_Processor-with-glibc2.43
Is CUDA available: True
CUDA runtime version: 13.3.73
CUDA_MODULE_LOADING set to: 
GPU models and configuration: GPU 0: Quadro RTX 4000
Nvidia driver version: Could not collect
cuDNN version: Could not collect
Is XPU available: False
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: False
Caching allocator config: N/A

CPU:
Architecture:                            x86_64
CPU op-mode(s):                          32-bit, 64-bit
Address sizes:                           43 bits physical, 48 bits virtual
Byte Order:                              Little Endian
CPU(s):                                  64
On-line CPU(s) list:                     0-63
Vendor ID:                               AuthenticAMD
Model name:                              AMD Ryzen Threadripper 2990WX 32-Core Processor
CPU family:                              23
Model:                                   8
Thread(s) per core:                      2
Core(s) per socket:                      32
Socket(s):                               1
Stepping:                                2
Microcode version:                       0x800820d
Frequency boost:                         disabled
CPU(s) scaling MHz:                      52%
CPU max MHz:                             4200.0000
CPU min MHz:                             2200.0000
BogoMIPS:                                5999.10
Flags:                                   fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid amd_dcm aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb hw_pstate ssbd ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 clzero xsaveerptr arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif overflow_recov succor smca sev sev_es
Virtualization:                          AMD-V
L1d cache:                               1 MiB (32 instances)
L1i cache:                               2 MiB (32 instances)
L2 cache:                                16 MiB (32 instances)
L3 cache:                                64 MiB (8 instances)
NUMA node(s):                            4
NUMA node0 CPU(s):                       0-7,32-39
NUMA node1 CPU(s):                       16-23,48-55
NUMA node2 CPU(s):                       8-15,40-47
NUMA node3 CPU(s):                       24-31,56-63
Vulnerability Gather data sampling:      Not affected
Vulnerability Ghostwrite:                Not affected
Vulnerability Indirect target selection: Not affected
Vulnerability Itlb multihit:             Not affected
Vulnerability L1tf:                      Not affected
Vulnerability Mds:                       Not affected
Vulnerability Meltdown:                  Not affected
Vulnerability Mmio stale data:           Not affected
Vulnerability Old microcode:             Not affected
Vulnerability Reg file data sampling:    Not affected
Vulnerability Retbleed:                  Mitigation; untrained return thunk; SMT vulnerable
Vulnerability Spec rstack overflow:      Mitigation; Safe RET
Vulnerability Spec store bypass:         Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:                Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:                Mitigation; Retpolines; IBPB conditional; STIBP disabled; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Vulnerability Srbds:                     Not affected
Vulnerability Tsa:                       Not affected
Vulnerability Tsx async abort:           Not affected
Vulnerability Vmscape:                   Mitigation; IBPB before exit to userspace

Versions of relevant libraries:
[pip3] flake8==6.1.0
[pip3] mypy_extensions==1.1.0
[pip3] numpy==2.5.2
[pip3] onnxruntime==1.28.0
[pip3] onnxruntime-gpu==1.28.0.dev20260722004
[pip3] torch==2.11.0a0+gitunknown
[conda] Could not collect

You might want to pip install the latest torchaudio==2.11 release as according to the repository no new features will land in audio:

TorchAudio 2.11 works with torch 2.11 and with every future torch release (2.12, 2.13, etc.). It is the latest release, and it is the only one you need: there is nothing to upgrade in TorchAudio when you upgrade torch, and installing TorchAudio does not pin torch to a specific version.

We have transitioned TorchAudio into a maintenance phase…

so I’m unsure if anyone is still testing the build using newer toolchains.

Yeah, I saw that and figured it’d work with Pytorch 2.13.0, so maybe I’m using too bleeding-edge a GCC, though GCC 14 produced the same issue.

I can’t just do pip install torchaudio==2.11.0 because that gives:

RuntimeError: Detected that PyTorch and TorchAudio were compiled with different CUDA versions. PyTorch has CUDA version 13.3 whereas TorchAudio has CUDA version 13.0. Please install the TorchAudio version that matches your PyTorch version.

So it seems I have to build torchaudio from source.

Well, it ended up I didn’t need to compile libtorchaudio.so for the apps I’m using that require torchaudio; I just needed the Python bindings, no C++ library.

I built Python-only torchaudio successfully with:

diff --git a/setup.py b/setup.py
index 8030c54..22468a5 100644
--- a/setup.py
+++ b/setup.py
@@ -134,7 +134,7 @@ def _main():
         ],
         packages=find_packages(where="src"),
         package_dir={"": "src"},
-        ext_modules=setup_helpers.get_ext_modules(),
+        ext_modules=[],
         cmdclass={
             "build_ext": setup_helpers.get_build_ext(),
             "clean": clean,

:top_hat:-tip to Google Gemini:

If you only need TorchAudio for I/O (torchaudio.load), audio processing transforms (MelSpectrogram, Resample, Spectrogram, MFCC), or neural networks, you do not need to compile libtorchaudio.so. TorchAudio’s Python API delegates all GPU tensor operations directly to PyTorch’s C++/CUDA backend.