Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

ModuleNotFoundError: No module named 'sahi.model' #1481

Closed
r-matsuzaka opened this issue Nov 3, 2022 · 11 comments · Fixed by #1479
Closed

ModuleNotFoundError: No module named 'sahi.model' #1481

r-matsuzaka opened this issue Nov 3, 2022 · 11 comments · Fixed by #1479
Assignees
Labels
bug / fix Something isn't working help wanted Extra attention is needed
Milestone

Comments

@r-matsuzaka
Copy link

🐛 Bug

I just want to run tutorial here.

Environment

  • Ubuntu Desktop 22.04 LTS
  • GPU RTX2080
  • Driver nvidia-driver-510

To Reproduce

  • Dockerfile
FROM nvidia/cuda:11.6.0-cudnn8-devel-ubuntu20.04

# https://serverfault.com/questions/683605/docker-container-time-timezone-will-not-reflect-changes
ENV TZ=Asia/Tokyo
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

RUN apt-get update && apt-get install -y python3 python3-pip \
&& apt-get install ffmpeg libsm6 libxext6  -y

RUN pip3 install --no-cache-dir \
   jupyterlab \
   lightning-flash[image] \
   icedata \
   icevision
  • docker-compose.yaml
version: "3"
services:
  notebook:
    build: .
    volumes:
      - ".:/home/work"
      - ".jupyter:/root/.jupyter"
    ports:
      - "7777:7777"
    tty: true
    environment:
      - JUPYTER_ENABLE_LAB=yes
      - NVIDIA_VISIBLE_DEVICES=all
      - NVIDIA_DRIVER_CAPABILITIES=all
    deploy:
       resources:
         reservations:
           devices:
             - capabilities:
               - gpu
    command: jupyter lab --ip=0.0.0.0 --port=7777 --allow-root --no-browser --NotebookApp.token=''

Then, run

docker compose up

Connect to localhost:7777 and open up jupyter.

Then, run

from functools import partial

import flash
from flash.core.utilities.imports import example_requires
# from flash.image import InstanceSegmentation, InstanceSegmentationData

example_requires("image")

import icedata  # noqa: E402

I got the error

ModuleNotFoundErrorTraceback (most recent call last)
Cell In [3], line 9
5 # from flash.image import InstanceSegmentation, InstanceSegmentationData
7 example_requires("image")
----> 9 import icedata # noqa: E402

File /usr/local/lib/python3.8/dist-packages/icedata/init.py:1
----> 1 import icedata.utils
2 import icedata.template
4 from icedata.utils import *

File /usr/local/lib/python3.8/dist-packages/icedata/utils/init.py:1
----> 1 from icedata.utils.utils import *
2 from icedata.utils.plot_size_histogram import *

File /usr/local/lib/python3.8/dist-packages/icedata/utils/utils.py:3
1 all = ["load_model_weights_from_url", "load_data"]
----> 3 from icevision.all import *
6 def load_model_weights_from_url(
7 model: nn.Module, url: str, map_location=torch.device("cpu"), **kwargs
8 ) -> None:
9 state_dict = torch.hub.load_state_dict_from_url(
10 url, map_location=map_location, **kwargs
11 )

File /usr/local/lib/python3.8/dist-packages/icevision/init.py:7
5 from icevision.data import *
6 from icevision import backbones
----> 7 from icevision import models
8 from icevision.metrics import *
9 from icevision.visualize import *

File /usr/local/lib/python3.8/dist-packages/icevision/models/init.py:32
29 from icevision.models import fastai
31 if SoftDependencies.sahi:
---> 32 from icevision.models import inference_sahi

File /usr/local/lib/python3.8/dist-packages/icevision/models/inference_sahi.py:14
10 from icevision.visualize.utils import *
11 from icevision.tfms.albumentations import albumentations_adapter
---> 14 from sahi.model import DetectionModel
15 from sahi.prediction import ObjectPrediction
16 from sahi.predict import get_sliced_prediction as sahi_get_sliced_prediction

ModuleNotFoundError: No module named 'sahi.model'

@r-matsuzaka r-matsuzaka added bug / fix Something isn't working help wanted Extra attention is needed labels Nov 3, 2022
@krshrimali
Copy link
Contributor

Hi, @r-matsuzaka - Thank you for creating this issue. We are aware of this issue, and looking at it. Meanwhile, can I please know what pytorch_lightning version you have in your environment?

@r-matsuzaka
Copy link
Author

@krshrimali
Hi.

what pytorch_lightning version you have in your environment?

pytorch-lightning==1.8.0.post1

mypc@mypc:~/test$ docker run --gpus all -it --rm docker-notebook /bin/bash
root@72eaa22896b8:/# pip3 freeze                         
absl-py==1.3.0
albumentations==1.3.0
antlr4-python3-runtime==4.9.3
anyio==3.6.2
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
asttokens==2.1.0
attrs==22.1.0
Babel==2.11.0
backcall==0.2.0
beautifulsoup4==4.11.1
bleach==5.0.1
cachetools==5.2.0
certifi==2022.9.24
cffi==1.15.1
charset-normalizer==2.1.1
click==8.1.3
contourpy==1.0.6
cycler==0.11.0
Cython==0.29.32
dataclasses==0.6
decorator==5.1.1
defusedxml==0.7.1
docstring-parser==0.15
effdet==0.2.4
efficientnet-pytorch==0.7.1
entrypoints==0.4
executing==1.2.0
fastcore==1.3.29
fastjsonschema==2.16.2
filelock==3.8.0
fire==0.4.0
fonttools==4.38.0
fsspec==2022.10.0
fvcore==0.1.5.post20220512
google-auth==2.14.0
google-auth-oauthlib==0.4.6
grpcio==1.50.0
huggingface-hub==0.10.1
icedata==0.5.1
icevision==0.12.0
idna==3.4
imageio==2.22.3
importlib-metadata==5.0.0
importlib-resources==5.10.0
iopath==0.1.10
ipykernel==5.5.6
ipython==8.6.0
ipython-genutils==0.2.0
jedi==0.18.1
Jinja2==3.1.2
joblib==1.2.0
json5==0.9.10
jsonargparse==4.9.0
jsonschema==4.17.0
jupyter-client==7.4.4
jupyter-core==4.11.2
jupyter-server==1.21.0
jupyterlab==3.5.0
jupyterlab-pygments==0.2.2
jupyterlab-server==2.16.2
kiwisolver==1.4.4
lightning-bolts==0.6.0
lightning-flash==0.8.0
lightning-lite==1.8.0.post1
lightning-utilities==0.3.0
loguru==0.6.0
Markdown==3.4.1
MarkupSafe==2.1.1
matplotlib==3.6.2
matplotlib-inline==0.1.6
mistune==2.0.4
munch==2.5.0
nbclassic==0.4.8
nbclient==0.7.0
nbconvert==7.2.3
nbformat==5.7.0
nest-asyncio==1.5.6
networkx==2.8.8
nose==1.3.7
notebook==6.5.2
notebook-shim==0.2.2
numpy==1.23.4
nvidia-cublas-cu11==11.10.3.66
nvidia-cuda-nvrtc-cu11==11.7.99
nvidia-cuda-runtime-cu11==11.7.99
nvidia-cudnn-cu11==8.5.0.96
oauthlib==3.2.2
omegaconf==2.2.3
opencv-python==4.6.0.66
opencv-python-headless==4.6.0.66
packaging==21.3
pandas==1.5.1
pandocfilters==1.5.0
parso==0.8.3
pexpect==4.8.0
pickleshare==0.7.5
Pillow==9.3.0
pkgutil-resolve-name==1.3.10
portalocker==2.6.0
pretrainedmodels==0.7.4
prometheus-client==0.15.0
prompt-toolkit==3.0.31
protobuf==3.20.1
ptyprocess==0.7.0
pure-eval==0.2.2
pyasn1==0.4.8
pyasn1-modules==0.2.8
pybboxes==0.1.5
pycocotools==2.0.5
pycparser==2.21
pyDeprecate==0.3.2
Pygments==2.13.0
pyparsing==3.0.9
pyrsistent==0.19.2
pystiche==1.0.1
python-dateutil==2.8.2
pytorch-lightning==1.8.0.post1
pytz==2022.6
PyWavelets==1.4.1
PyYAML==6.0
pyzmq==24.0.1
qudida==0.0.4
requests==2.28.1
requests-oauthlib==1.3.1
resnest==0.0.6b20221103
rsa==4.9
sahi==0.11.1
scikit-image==0.19.3
scikit-learn==1.1.3
scipy==1.9.3
seaborn==0.12.1
segmentation-models-pytorch==0.3.0
Send2Trash==1.8.0
Shapely==1.8.5.post1
six==1.16.0
sniffio==1.3.0
soupsieve==2.3.2.post1
stack-data==0.6.0
tabulate==0.9.0
tensorboard==2.10.1
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
termcolor==2.1.0
terminado==0.17.0
terminaltables==3.1.10
threadpoolctl==3.1.0
tifffile==2022.10.10
timm==0.6.11
tinycss2==1.2.1
tomli==2.0.1
torch==1.13.0
torchmetrics==0.10.2
torchvision==0.14.0
tornado==6.2
tqdm==4.64.1
traitlets==5.5.0
typing-extensions==4.4.0
urllib3==1.26.12
wcwidth==0.2.5
webencodings==0.5.1
websocket-client==1.4.1
Werkzeug==2.2.2
yacs==0.1.8
yolov5-icevision==6.0.0
zipp==3.10.0

@krshrimali
Copy link
Contributor

Hi, @r-matsuzaka - Okay, so not a fault of pytorch_lightning. This is broken in upstream (icevision): airctic/icevision#1146. Could you please try downgrading sahi to 0.10.8 using: pip install sahi==0.10.8? A PR is opened to icevision: airctic/icevision#1147, but meanwhile - I'll send a PR to pin it in Flash.

Please let me know if downgrading doesn't fix your issue temporarily. Thanks!!

@r-matsuzaka
Copy link
Author

@krshrimali
Hi.
Thank you very much. I had no error.

Screenshot from 2022-11-04 01-04-14

@krshrimali
Copy link
Contributor

Thanks, @r-matsuzaka for acknowledging. I've created a PR to fix it, and also looking at the other issue you've created. Once the next release of Flash is made, those should be fixed. I'll re-open this issue until we have fixed it in flash without us requesting users to down-grade a specific library. ❤️ Thank you again!

@krshrimali krshrimali reopened this Nov 3, 2022
@krshrimali krshrimali self-assigned this Nov 3, 2022
@krshrimali krshrimali added this to the 0.8.x milestone Nov 3, 2022
@r-matsuzaka
Copy link
Author

Thank you again!

My pleasure. Thank you for your polite and quick response!

@fcakyon
Copy link
Contributor

fcakyon commented Nov 13, 2022

Hello @r-matsuzaka @krshrimali i am the core maintainer of sahi. I would be more than glad to work on a PR to Icevisionor Lightning AI to add v0.11 support. Migration is very easy. I am deeply sorry for that backward incompatible architectural update jump from 0.10 to 0.11.

@krshrimali
Copy link
Contributor

Hi, @fcakyon - Thank you so much for reaching out, great work with sahi! 🚀

Please don't be sorry, I'm glad you offered help to have this fixed. I think, this fix will go to icevision, and then we can just get rid of the requirement where we hard-coded sahi's version to the backward-compatible one. From what I remember, there was a PR already to icevision, maybe you can help them push it forward or take a look if it's already done?

@fcakyon
Copy link
Contributor

fcakyon commented Nov 13, 2022

I will try to get in contact with icevision devs, thanks for the response!

@krshrimali
Copy link
Contributor

Awesome, thank you @fcakyon - once it's done, could you please let me know here, or just send a PR to un-pin the sahi's version in Flash? I can help land it (we'll also need icevision's release once the PR is merged upstream). Thank you for your help! ❤️

@fcakyon
Copy link
Contributor

fcakyon commented Nov 13, 2022

OK @krshrimali, will let you know once icevision is updated and a new version is shipped 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug / fix Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants