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

Installing audio in develop mode macOS #867

Closed
jiwidi opened this issue Aug 7, 2020 · 2 comments
Closed

Installing audio in develop mode macOS #867

jiwidi opened this issue Aug 7, 2020 · 2 comments

Comments

@jiwidi
Copy link
Contributor

jiwidi commented Aug 7, 2020

❓ Trouble installing audio in editable mode and running test

Hi, I'm working in a contribution to add TEDLIUM dataset #765 and I'm having trouble making my local installation of torchaudio to work in editable mode.

Initially I didnt find any instructions on how to locally compile the code to run in editable mode but I the main contributing instructions from main repository https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md and python setup.py develop as the way to install locally. I tried it myself and failed, my system is the following:

macOS 10.15.5
conda installation, environment using python 3.7.7
gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
Apple clang version 11.0.0 (clang-1100.0.33.12)
Target: x86_64-apple-darwin19.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

During install I get the following warning:

Your compiler (g++) is not compatible with the compiler Pytorch was
built with for this platform, which is clang++ on darwin. Please
use clang++ to to compile your extension. Alternatively, you may
compile PyTorch from source using g++, and then you can also use
g++ to compile your extension.

The library gets installed but when I try to import/use it then It fails with:

Python 3.7.7 (default, May  6 2020, 04:59:01)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import torchaudio
libc++abi.dylib: terminating with uncaught exception of type c10::Error: 1Explicitly provided namespace (torchaudio) in schema string does not match namespace of enclsing 0 block (torchaudio).  Move this definition to the (unique) TORCH_LIBRARY block corresponding to this namespace (and consider deleting the namespace from your schema string.)  (Error occurred while processing 0 block at /Users/jaime/Documents/Github/audio/torchaudio/csrc/register.cpp:8)
Exception raised from _def at ../aten/src/ATen/core/library.cpp:111 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) + 169 (0x113e787f9 in libc10.dylib)
frame #1: torch::Library::_def(c10::FunctionSchema&&, c10::OperatorName*) & + 3127 (0x10645b387 in libtorch_cpu.dylib)
frame #2: torch::Library::_def(c10::either<c10::OperatorName, c10::FunctionSchema>&&, torch::CppFunction&&) & + 728 (0x10645b8b8 in libtorch_cpu.dylib)
frame #3: torch::Library& torch::Library::def<char const (&) [31], void (*)(long long)>(char const (&) [31], void (*&&)(long long)) & + 161 (0x120e169e1 in _torchaudio.so)
frame #4: TORCH_LIBRARY_init_torchaudio(torch::Library&) + 790 (0x120e15d16 in _torchaudio.so)
frame #5: torch::detail::TorchLibraryInit::TorchLibraryInit(torch::Library::Kind, void (*)(torch::Library&), char const*, c10::optional<c10::DispatchKey>, char const*, unsigned int) + 246 (0x120e163f6 in _torchaudio.so)
frame #6: _GLOBAL__sub_I_register.cpp + 584 (0x120e337d8 in _torchaudio.so)
frame #7: 0x0 + 4629410275 (0x113ef31e3 in ???)
frame #8: 0x0 + 4629411310 (0x113ef35ee in ???)
frame #9: 0x0 + 4629389323 (0x113eee00b in ???)
frame #10: 0x0 + 4629381140 (0x113eec014 in ???)
frame #11: 0x0 + 4629381300 (0x113eec0b4 in ???)
frame #12: 0x0 + 4629323312 (0x113edde30 in ???)
frame #13: 0x0 + 4629364219 (0x113ee7dfb in ???)
frame #14: dlopen + 171 (0x7fff6a60dd8a in libdyld.dylib)
frame #15: py_dl_open + 131 (0x104ca7ae3 in _ctypes.cpython-37m-darwin.so)
<omitting python frames>

My guess is that this problem comes from using gcc as a compiler instead of clang, I found other ppl who encountered the same problem facebookresearch/maskrcnn-benchmark#365 and they recommended to upgrade gcc (I have gcc 4.9 installed too) but the pytorch setup installer wont catch it neither.

Has any of the developers using macOS encountered this problem before? Is there something I'm missing? Any way to force audio setup file to use clang?

edit:

I solved the compiler problems but the problems still persists. Installing now with:
MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py develop from here but the problem still persists.

I uninstalled torchaudiopython -m pip uninstall torchaudio and run python setup.py clean and recloned the repository to make sure there is no pth python files and make sure I will use the new compiled version.

@mthrok
Copy link
Collaborator

mthrok commented Aug 7, 2020

Hi @jiwidi

It is highly recommended to use nightly build of PyTorch.

conda install pytorch -c pytorch-nightly
cd <torchaudio repo>
python setup.py clean develop
python -c 'import torchaudio;print(torchaudio.utils.sox_utils.list_effects())'

I just tested this with my macbook (master branch) and it worked fine. I often also see the warning about the compiler but so far it works.

@jiwidi
Copy link
Contributor Author

jiwidi commented Aug 7, 2020

Hi @jiwidi

It is highly recommended to use nightly build of PyTorch.

conda install pytorch -c pytorch-nightly
cd <torchaudio repo>
python setup.py clean develop
python -c 'import torchaudio;print(torchaudio.utils.sox_utils.list_effects())'

I just tested this with my macbook (master branch) and it worked fine. I often also see the warning about the compiler but so far it works.

This fixed my issue thanks! In case it comes handy in the future I found the way to force setup.py to compile with clang

run

MACOSX_DEPLOYMENT_TARGET=10.9 CC=clang CXX=clang++ python setup.py develop

@jiwidi jiwidi closed this as completed Aug 7, 2020
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

2 participants