-
Notifications
You must be signed in to change notification settings - Fork 123
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
PyTorch "Undefined symbol" error when importing SAM ONNX models to cluster #161
Comments
Hi, @marias65. I couldn't reproduce your error on my machine but found a few similar issues here and here that the cause might be installing pytorch via conda and a possible solution would be pointing to the CPU wheel during installation. Quick question: are you able to import PyTorch in the $ python -c "import torch; print(torch.__version__)" I was able to set up a new environment with the latest version of PyTorch and run the script to export the model to ONNX files. Could I ask you to try on your end as well? Please change the name: new_segment_anything_cpu
channels:
- pytorch
- nvidia
- conda-forge
- defaults
dependencies:
- python==3.8.*
- geopandas~=0.11.1
- ipython~=8.5.0
- ipywidgets~=8.0.2
- jupyter~=1.0.0
- matplotlib~=3.6.0
- numpy~=1.23.3
# - pytorch=2.0.0=py3.8_cpu_0
# - torchvision=0.15.0=py38_cpu
# - torchaudio=2.0.0=py38_cpu
- pip~=22.2.0
- pandas~=1.5.0
- rasterio~=1.3.2
- shapely~=1.8.4
- tqdm~=4.64.1
- scikit-image~=0.20.0
# - pip:
# - git+https://github.com/facebookresearch/segment-anything.git
# - ../../src/vibe_core
# - cartopy~=0.21.0
# - xarray~=2022.10.0
# - ipympl~=0.9.3
# - onnx~=1.14.0
# - onnxruntime~=1.15.0 Once the env is created, please activate it and install the pip packages: $ micromamba activate new_segment_anything_cpu
$ pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu
$ pip install git+https://github.com/facebookresearch/segment-anything.git
$ pip install ../../src/vibe_core
$ pip install cartopy~=0.21.0 xarray~=2022.10.0 ipympl~=0.9.3 onnx~=1.14.0 onnxruntime~=1.15.0 Make sure the path to Please, let me know if you are able to run the exportation script in this new environment. |
Thank you for your response! I was not able to run I was able to create the new_segment_anything_cpu environment and install all the pip packages you listed but when I attempted to run |
Hi, @marias65. I was able to replicate your issue. Installing the pytorch 2.1.0 with the appropriate wheel within the segment anything environment solved the problem for me. In summary, what I did was:
After that, I was able to import torch: $ python -c "import torch; print(torch.__version__)"
2.1.2+cpu Please, could you let me know if this works for you? I will fix the environment yaml files in the next release. |
Another possibility that worked for me (and won't change the pytorch version) was creating the environment with the following yaml: name: segment_anything_cpu
channels:
- pytorch
- nvidia
- conda-forge
- defaults
dependencies:
- python==3.8.*
- geopandas~=0.11.1
- ipython~=8.5.0
- ipywidgets~=8.0.2
- jupyter~=1.0.0
- matplotlib~=3.6.0
- numpy~=1.23.3
- pip~=22.2.0
- pandas~=1.5.0
- rasterio~=1.3.2
- shapely~=1.8.4
- tqdm~=4.64.1
- scikit-image~=0.20.0
- pip:
- --extra-index-url https://download.pytorch.org/whl/cpu
- torch~=2.0.0
- torchvision~=0.15.0
- torchaudio~=2.0.0
- git+https://github.com/facebookresearch/segment-anything.git
- ../../src/vibe_core
- cartopy~=0.21.0
- xarray~=2022.10.0
- ipympl~=0.9.3
- onnx~=1.14.0
- onnxruntime~=1.15.0 by running:
With the environment activated:
|
I'm glad that error is fixed. For this new one, the script doesn't require that much memory, especially with the The script also logs a few messages (e.g., when it is able to load the encoder/decoder model and when it starts converting them), but these didn't show up, which I find it weird. Are you able to import import onnx
import onnxruntime |
Closing this issue for now. @marias65, let me know if you are still facing this error. |
Currently trying to follow the segment anything notebook to run sentinel2_segmentation.ipynb but when trying to import SAM's ONNX models to the cluster with
! python ../../scripts/export_sam_models.py --models vit_b
, I run into an error that says "ImportError: /home/msbksan/micromamba/envs/segment_anything_cpu/lib/python3.8/site-packages/torch/lib/libtorch_cpu.so: undefined symbol: iJIT_NotifyEvent"The text was updated successfully, but these errors were encountered: