btx0424 / OmniDrones

https://omnidrones.readthedocs.io/
MIT License
126 stars 23 forks source link

Cannot import torch #53

Open JJJJJllll opened 4 months ago

JJJJJllll commented 4 months ago

Hi, I hope it finds you well! I'm using Issac Sim 2023.1.0.hotfix, python3.7, and I cannot import pytorch, would you please help me with it? I created a python env with conda and copied configuration file from Omnidrones. I can run python -c "from omni.isaac.kit import SimulationApp" But I can't run python -c "import torch; print(torch.__path__)", errors are like that:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/comb/.local/share/ov/pkg/isaac_sim-2023.1.0-hotfix.1/extscache/omni.pip.torch-2_0_1-2.0.2+105.1.lx64/torch-2-0-1/torch/__init__.py", line 454, in <module>
    ''').strip()) from None
ImportError: Failed to load PyTorch C extensions:
    It appears that PyTorch has loaded the `torch/_C` folder
    of the PyTorch repository rather than the C extensions which
    are expected in the `torch._C` namespace. This can occur when
    using the `install` workflow. e.g.
        $ python setup.py install && python -c "import torch"

    This error can generally be solved using the `develop` workflow
        $ python setup.py develop && python -c "import torch"  # This should succeed
    or by running Python from a different directory.

I'm really confused. Looking forward to your reply!

jinwoolee1230 commented 4 months ago

for 2023.1.0 hotfix, python3.7 did not work. Instead, python 3.10.12 worked well.

btx0424 commented 4 months ago

As pointed out by @jinwoolee, Isaac Sim 2023.* is shipped with Python 3.10. Different Python versions do not share compiled binaries. So the shipped PyTorch, which was built under python 3.10, won't work in a Python 3.7 environment.

I believe switching to 3.10 would solve the problem

JJJJJllll commented 4 months ago

Thanks for your kind reply @jinwoolee1230 @btx0424 ! I'll try using Issac Sim 2022.2.0 with python 3.7 or 2023.1.0 with 3.10.12.