Code Monkey home page Code Monkey logo

Comments (7)

rafaspadilha avatar rafaspadilha commented on June 17, 2024 1

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:

$ micromamba env create -f notebooks/segment_anything/env_cpu.yaml

With the environment activated:

$ python -c "import torch; print(torch.__version__)"
2.0.1+cpu

from farmvibes-ai.

rafaspadilha avatar rafaspadilha commented on June 17, 2024

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 segment_anything_cpy environment?

$ 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 env_cpy.yaml, commenting the pip lines as below:

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 src/vibe_core is correct on the $ pip install ../../src/vibe_core command.

Please, let me know if you are able to run the exportation script in this new environment.

from farmvibes-ai.

marias65 avatar marias65 commented on June 17, 2024

Thank you for your response! I was not able to run $ python -c "import torch; print(torch.__version__)" as it gave me the same iJIT_NotifyEvent error while in the segment_anything_cpu environment.

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 $ python -c "import torch; print(torch.__version__)" or ! python ../../scripts/export_sam_models.py --models vit_b I still came across the same iJIT_NotifyEvent error.

image

from farmvibes-ai.

rafaspadilha avatar rafaspadilha commented on June 17, 2024

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:

  • Create the segment_anything_cpu environment with the yaml that is currently available in the repo.
  • Run pip install torch~=2.1.0 --index-url https://download.pytorch.org/whl/cpu

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.

from farmvibes-ai.

marias65 avatar marias65 commented on June 17, 2024

Thank you! I rebuild farmvibes-ai and followed your latest solution and that seems to have helped!

image

Right now, I receive this message but looking into it further suggests that it is due to limited memory on the machine I am currently using. Otherwise, I would say that it worked, thank you

from farmvibes-ai.

rafaspadilha avatar rafaspadilha commented on June 17, 2024

I'm glad that error is fixed.

For this new one, the script doesn't require that much memory, especially with the vit_b model. What are your specs (memory and disk space)?

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 onnxruntime and onnx?

import onnx
import onnxruntime

from farmvibes-ai.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.