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

[BUG] ImportError: dlopen(...): Symbol not found when import torchrl on MacOS apple chip #1638

Closed
3 tasks done
FrankTianTT opened this issue Oct 22, 2023 · 12 comments
Closed
3 tasks done
Assignees
Labels
bug Something isn't working

Comments

@FrankTianTT
Copy link
Contributor

FrankTianTT commented Oct 22, 2023

Describe the bug

I tried to install the compiled torchrl on the apple chip and encountered a problem:

IImportError: dlopen(/Users/frank/opt/anaconda3/envs/torch_rl/lib/python3.9/site-packages/torchrl/_torchrl.so, 0x0002): Symbol not found: __ZN5torch8autograd13_wrap_outputsERKNSt3__16vectorIN2at6TensorENS1_9allocatorIS4_EEEERKNS1_13unordered_setIPN3c1010TensorImplENS1_4hashISD_EENS1_8equal_toISD_EENS5_ISD_EEEESL_NSB_8ArrayRefINSB_8optionalIS4_EEEERKNS1_10shared_ptrINS0_4NodeEEERKNS1_8functionIFS7_S7_S7_EEESL_RKNSV_IFS4_S4_EEE
  Referenced from: <8552E3F0-1AEE-3F35-A976-0E08118BC1F7> /Users/frank/opt/anaconda3/envs/torch_rl/lib/python3.9/site-packages/torchrl/_torchrl.so
  Expected in:     <66FB8649-BB87-3CD6-A177-462038DCAE02> /Users/frank/opt/anaconda3/envs/torch_rl/lib/python3.9/site-packages/torch/lib/libtorch_cpu.dylib

BTW, in the latest release, torchrl already supports apple chips, but the README still requires users to install it locally. I don't know if installing from pip is supported now.

To Reproduce

import torchrl
>>> import torchrl
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/frank/opt/anaconda3/envs/torch_rl/lib/python3.9/site-packages/torchrl/__init__.py", line 38, in <module>
    import torchrl.collectors
  File "/Users/frank/opt/anaconda3/envs/torch_rl/lib/python3.9/site-packages/torchrl/collectors/__init__.py", line 6, in <module>
    from .collectors import (
  File "/Users/frank/opt/anaconda3/envs/torch_rl/lib/python3.9/site-packages/torchrl/collectors/collectors.py", line 42, in <module>
    from torchrl.data.tensor_specs import CompositeSpec, TensorSpec
  File "/Users/frank/opt/anaconda3/envs/torch_rl/lib/python3.9/site-packages/torchrl/data/__init__.py", line 6, in <module>
    from . import datasets
  File "/Users/frank/opt/anaconda3/envs/torch_rl/lib/python3.9/site-packages/torchrl/data/datasets/__init__.py", line 1, in <module>
    from .d4rl import D4RLExperienceReplay
  File "/Users/frank/opt/anaconda3/envs/torch_rl/lib/python3.9/site-packages/torchrl/data/datasets/d4rl.py", line 21, in <module>
    from torchrl.data.replay_buffers import TensorDictReplayBuffer
  File "/Users/frank/opt/anaconda3/envs/torch_rl/lib/python3.9/site-packages/torchrl/data/replay_buffers/__init__.py", line 6, in <module>
    from .replay_buffers import (
  File "/Users/frank/opt/anaconda3/envs/torch_rl/lib/python3.9/site-packages/torchrl/data/replay_buffers/replay_buffers.py", line 25, in <module>
    from torchrl.data.replay_buffers.samplers import (
  File "/Users/frank/opt/anaconda3/envs/torch_rl/lib/python3.9/site-packages/torchrl/data/replay_buffers/samplers.py", line 13, in <module>
    from torchrl._torchrl import (
ImportError: dlopen(/Users/frank/opt/anaconda3/envs/torch_rl/lib/python3.9/site-packages/torchrl/_torchrl.so, 0x0002): Symbol not found: __ZN5torch8autograd13_wrap_outputsERKNSt3__16vectorIN2at6TensorENS1_9allocatorIS4_EEEERKNS1_13unordered_setIPN3c1010TensorImplENS1_4hashISD_EENS1_8equal_toISD_EENS5_ISD_EEEESL_NSB_8ArrayRefINSB_8optionalIS4_EEEERKNS1_10shared_ptrINS0_4NodeEEERKNS1_8functionIFS7_S7_S7_EEESL_RKNSV_IFS4_S4_EEE
  Referenced from: <8552E3F0-1AEE-3F35-A976-0E08118BC1F7> /Users/frank/opt/anaconda3/envs/torch_rl/lib/python3.9/site-packages/torchrl/_torchrl.so
  Expected in:     <66FB8649-BB87-3CD6-A177-462038DCAE02> /Users/frank/opt/anaconda3/envs/torch_rl/lib/python3.9/site-packages/torch/lib/libtorch_cpu.dylib

System info

Describe the characteristic of your environment:

  • Python version: I tried both 3.8 and 3.9
  • TorchRL version: 0.2.0
  • OS: 14.0 (23A344)
  • Chip: Apple M2 Pro

Reason and Possible fixes

According to the troubleshooting in the README, I installed the latest version of XCode, while it is does not help.

Checklist

  • I have checked that there is no similar issue in the repo (required)
  • I have read the documentation (required)
  • I have provided a minimal working example to reproduce the bug (required)
@FrankTianTT FrankTianTT added the bug Something isn't working label Oct 22, 2023
@Jianye-Xu
Copy link

I have encountered exactly the same issue.
System info

  • Python version: 3.10.0
  • torchrl version: 0.2.0
  • OS: macOS Ventura 13.5.1 (22G90)
  • Chip: Apple M2 Pro

@vmoens
Copy link
Contributor

vmoens commented Oct 22, 2023

I will correct the README asap and look into this, thanks for reporting!

Which PyTorch version are you using?

@FrankTianTT
Copy link
Contributor Author

Which PyTorch version are you using?

@vmoens I installed torchrl directly without manually installing torch, and this default torch version is 2.1.0

@Jianye-Xu
Copy link

@vmoens I tried both torch 2.0.1 and torch 2.1.0.

@vmoens
Copy link
Contributor

vmoens commented Oct 23, 2023

It should work with PT 2.1.0 (and no other).
I'll try to reproduce this and push a fix!

@abdulmuneer
Copy link

I have the same issue.

Platform: Apple M1 Pro
Python==3.11.5
torch==2.1.0

Installed torchrl through command pip install torchrl

@vmoens
Copy link
Contributor

vmoens commented Oct 24, 2023

This will be resolved by #1642 which I will push soon!

@vmoens vmoens closed this as completed Oct 24, 2023
@abdulmuneer
Copy link

@vmoens , I couldn't follow how this issue is resolved in #1642 . The PR is removing support for Apple silicon in the Readme. Is there a solution that will help users of torchrl run the library on apple silicon?

@vmoens
Copy link
Contributor

vmoens commented Oct 25, 2023

I'm pushing the fixed binaries in a couple of hours top! This PR is the release branch for 0.2.1 which will fix the osx binaries

@vmoens
Copy link
Contributor

vmoens commented Oct 25, 2023

I have pushed the binaries, you can now install torchrl with a pip install on apple silicon! Sorry for the mess

@Jianye-Xu
Copy link

Thanks, it works now!

@abdulmuneer
Copy link

Thank you @vmoens . It works for me too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants