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

serverless yolov5 missing module fix #6361

Closed
wants to merge 2 commits into from
Closed

serverless yolov5 missing module fix #6361

wants to merge 2 commits into from

Conversation

hardikdava
Copy link
Contributor

Adding missing module as required by docker

Motivation and context

Current serverless function for yolov5 raises following error:

23.06.22 18:38:53.215 sor.http.w0.python.logger (E) Exception raised while running init_context {"worker_id": "0"}
Traceback (most recent call last):
  File "/opt/nuclio/_nuclio_wrapper.py", line 432, in <module>
    run_wrapper()
  File "/opt/nuclio/_nuclio_wrapper.py", line 420, in run_wrapper
    loop.run_until_complete(wrapper_instance.initialize())
  File "/opt/conda/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/opt/nuclio/_nuclio_wrapper.py", line 147, in initialize
    await self._initialize_context()
  File "/opt/nuclio/_nuclio_wrapper.py", line 158, in _initialize_context
    init_context_result = getattr(self._entrypoint_module, 'init_context')(self._context)
  File "/opt/nuclio/main.py", line 11, in init_context
    model = torch.hub.load('ultralytics/yolov5', 'yolov5s')  # or yolov5m, yolov5l, yolov5x, custom
  File "/opt/conda/lib/python3.10/site-packages/torch/hub.py", line 558, in load
    model = _load_local(repo_or_dir, model, *args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/torch/hub.py", line 587, in _load_local
    model = entry(*args, **kwargs)
  File "/root/.cache/torch/hub/ultralytics_yolov5_master/hubconf.py", line 93, in yolov5s
    return _create('yolov5s', pretrained, channels, classes, autoshape, _verbose, device)
  File "/root/.cache/torch/hub/ultralytics_yolov5_master/hubconf.py", line 33, in _create
    from models.common import AutoShape, DetectMultiBackend
  File "/root/.cache/torch/hub/ultralytics_yolov5_master/models/common.py", line 28, in <module>
    from utils.dataloaders import exif_transpose, letterbox
  File "/root/.cache/torch/hub/ultralytics_yolov5_master/utils/dataloaders.py", line 31, in <module>
    from utils.augmentations import (Albumentations, augment_hsv, classify_albumentations, classify_transforms, copy_paste,
  File "/root/.cache/torch/hub/ultralytics_yolov5_master/utils/augmentations.py", line 15, in <module>
    from utils.general import LOGGER, check_version, colorstr, resample_segments, segment2box, xywhn2xyxy
  File "/root/.cache/torch/hub/ultralytics_yolov5_master/utils/general.py", line 38, in <module>
    from ultralytics.yolo.utils.checks import check_requirements
ModuleNotFoundError: No module named 'ultralytics'
23.06.22 18:38:53.627 sor.http.w0.python.logger (W) Failed to read from connection {"err": "EOF"}
23.06.22 18:38:53.627 sor.http.w0.python.logger (E) Unexpected termination of child process {"error": null, "status": "exit status 1"}
panic: Wrapper process for worker 0 exited unexpectedly with: exit status 1

How has this been tested?

I tested by deploying serverless function for yolov5

serverless/deploy_gpu.sh serverless/pytorch/ultralytics/yolov5/
  • I submit my changes into the develop branch
  • I have added a description of my changes into the CHANGELOG file

Adding missing dependency of yolov5
adding ultralytics dependency for yolov5 as required
@SpecLad
Copy link
Contributor

SpecLad commented Jun 23, 2023

This shouldn't be necessary, as this function is built from the ultralytics/yolov5 base image, which already includes the ultralytics package.

Could you run pip freeze in the Docker image built by Nuclio from the unmodified YAML file? E.g. docker run cvat.pth.ultralytics.yolov5 pip freeze.

@hardikdava
Copy link
Contributor Author

@SpecLad I got the list of installed packages and it does not haveultralytics in it.

absl-py==1.4.0
addict==2.4.0
aiohttp==3.8.4
aiosignal==1.3.1
albumentations==1.3.0
anyio==3.6.2
argcomplete==3.0.5
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
arrow==1.2.3
asttokens @ file:///opt/conda/conda-bld/asttokens_1646925590279/work
astunparse==1.6.3
async-timeout==4.0.2
attrs==22.2.0
Automat==22.10.0
backcall @ file:///home/ktietz/src/ci/backcall_1611930011877/work
beautifulsoup4 @ file:///opt/conda/conda-bld/beautifulsoup4_1650462163268/work
bleach==6.0.0
boto==2.49.0
brotlipy==0.7.0
cachetools==5.3.0
certifi @ file:///croot/certifi_1671487769961/work/certifi
cffi @ file:///croot/cffi_1670423208954/work
chardet @ file:///home/builder/ci_310/chardet_1640804867535/work
charset-normalizer @ file:///tmp/build/80754af9/charset-normalizer_1630003229654/work
coloredlogs==15.0.1
Comet==3.1.0
comm==0.1.3
conda==23.1.0
conda-build==3.23.3
conda-content-trust @ file:///tmp/abs_5952f1c8-355c-4855-ad2e-538535021ba5h26t22e5/croots/recipe/conda-content-trust_1658126371814/work
conda-package-handling @ file:///croot/conda-package-handling_1672865015732/work
conda_package_streaming @ file:///croot/conda-package-streaming_1670508151586/work
constantly==15.1.0
contourpy==1.0.7
coremltools==6.2
crcmod==1.7
cryptography @ file:///croot/cryptography_1677533068310/work
cycler==0.11.0
debugpy==1.6.6
decorator @ file:///opt/conda/conda-bld/decorator_1643638310831/work
defusedxml==0.7.1
dnspython==2.3.0
exceptiongroup==1.1.1
executing @ file:///opt/conda/conda-bld/executing_1646925071911/work
expecttest==0.1.4
fasteners==0.18
fastjsonschema==2.16.3
filelock @ file:///croot/filelock_1672387128942/work
flatbuffers==23.3.3
flit_core @ file:///opt/conda/conda-bld/flit-core_1644941570762/work/source/flit_core
fonttools==4.39.2
fqdn==1.5.1
frozenlist==1.3.3
gcs-oauth2-boto-plugin==3.0
gitdb==4.0.10
GitPython==3.1.31
glob2 @ file:///home/linux1/recipes/ci/glob2_1610991677669/work
gmpy2 @ file:///tmp/build/80754af9/gmpy2_1645455533097/work
google-apitools==0.5.32
google-auth==2.16.3
google-auth-oauthlib==0.4.6
google-reauth==0.1.1
grpcio==1.51.3
gsutil==5.21
httplib2==0.20.4
humanfriendly==10.0
hyperlink==21.0.0
hypothesis==6.70.0
idna @ file:///croot/idna_1666125576474/work
imageio==2.26.1
incremental==22.10.0
ipykernel==6.22.0
ipython @ file:///croot/ipython_1676582224036/work
ipython-genutils==0.2.0
isoduration==20.11.0
jedi @ file:///tmp/build/80754af9/jedi_1644315229345/work
Jinja2 @ file:///croot/jinja2_1666908132255/work
joblib==1.2.0
jsonpointer==2.3
jsonschema==4.17.3
jstyleson==0.0.2
jupyter-events==0.6.3
jupyter_client==8.1.0
jupyter_core==5.3.0
jupyter_server==2.5.0
jupyter_server_terminals==0.4.4
jupyterlab-pygments==0.2.2
kiwisolver==1.4.4
lazy_loader==0.2
libarchive-c @ file:///tmp/build/80754af9/python-libarchive-c_1617780486945/work
lxml==4.9.2
Markdown==3.4.3
markdown-it-py==2.2.0
MarkupSafe @ file:///opt/conda/conda-bld/markupsafe_1654597864307/work
matplotlib==3.7.1
matplotlib-inline @ file:///opt/conda/conda-bld/matplotlib-inline_1662014470464/work
mdurl==0.1.2
mistune==2.0.5
mkl-fft==1.3.1
mkl-random @ file:///home/builder/ci_310/mkl_random_1641843545607/work
mkl-service==2.4.0
monotonic==1.6
mpmath==1.3.0
msgpack==0.6.1
multidict==6.0.4
nbclassic==0.5.3
nbclient==0.7.2
nbconvert==7.2.10
nbformat==5.8.0
nest-asyncio==1.5.6
networkx==2.8.8
notebook==6.5.3
notebook_shim==0.2.2
nuclio-sdk==0.4.0
numpy==1.23.4
oauth2client==4.1.3
oauthlib==3.2.2
onnx==1.13.1
onnx-simplifier==0.4.19
onnxruntime==1.14.1
opencv-python==4.7.0.72
opencv-python-headless==4.7.0.72
openvino==2022.3.0
openvino-dev==2022.3.0
openvino-telemetry==2022.3.0
packaging==23.0
pandas==1.3.5
pandocfilters==1.5.0
parso @ file:///opt/conda/conda-bld/parso_1641458642106/work
pexpect @ file:///tmp/build/80754af9/pexpect_1605563209008/work
pickleshare @ file:///tmp/build/80754af9/pickleshare_1606932040724/work
Pillow==9.4.0
pkginfo @ file:///croot/pkginfo_1666725041340/work
platformdirs==3.2.0
pluggy @ file:///tmp/build/80754af9/pluggy_1648024709248/work
prometheus-client==0.16.0
prompt-toolkit @ file:///croot/prompt-toolkit_1672387306916/work
protobuf==3.20.3
psutil @ file:///opt/conda/conda-bld/psutil_1656431268089/work
ptyprocess @ file:///tmp/build/80754af9/ptyprocess_1609355006118/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl
pure-eval @ file:///opt/conda/conda-bld/pure_eval_1646925070566/work
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycosat @ file:///croot/pycosat_1666805502580/work
pycparser @ file:///tmp/build/80754af9/pycparser_1636541352034/work
Pygments==2.14.0
pyOpenSSL @ file:///croot/pyopenssl_1677607685877/work
pyparsing==3.0.9
pyrsistent==0.19.3
PySocks @ file:///home/builder/ci_310/pysocks_1640793678128/work
python-dateutil==2.8.2
python-etcd==0.4.5
python-json-logger==2.0.7
pytz @ file:///croot/pytz_1671697431263/work
pyu2f==0.1.5
PyWavelets==1.4.1
PyYAML @ file:///croot/pyyaml_1670514731622/work
pyzmq==25.0.2
qudida==0.0.4
requests @ file:///croot/requests_1678709721434/work
requests-oauthlib==1.3.1
retry-decorator==1.1.1
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rich==13.3.2
rsa==4.7.2
ruamel.yaml @ file:///croot/ruamel.yaml_1666304550667/work
ruamel.yaml.clib @ file:///croot/ruamel.yaml.clib_1666302247304/work
scikit-image==0.20.0
scikit-learn==1.2.2
scipy==1.10.1
seaborn==0.12.2
Send2Trash==1.8.0
six @ file:///tmp/build/80754af9/six_1644875935023/work
smmap==5.0.0
sniffio==1.3.0
sortedcontainers==2.4.0
soupsieve @ file:///croot/soupsieve_1666296392845/work
stack-data @ file:///opt/conda/conda-bld/stack_data_1646927590127/work
sympy @ file:///croot/sympy_1668202399572/work
tensorboard==2.12.0
tensorboard-data-server==0.7.0
tensorboard-plugin-wit==1.8.1
terminado==0.17.1
texttable==1.6.7
thop==0.1.1.post2209072238
threadpoolctl==3.1.0
tifffile==2023.3.21
tinycss2==1.2.1
toml @ file:///tmp/build/80754af9/toml_1616166611790/work
toolz @ file:///croot/toolz_1667464077321/work
torch==2.0.0
torchaudio==2.0.0
torchdata @ file:///__w/_temp/conda_build_env/conda-bld/torchdata_1678741239947/work
torchelastic==0.2.2
torchtext==0.15.0
torchvision==0.15.0
tornado==6.2
tqdm @ file:///opt/conda/conda-bld/tqdm_1664392687731/work
traitlets @ file:///croot/traitlets_1671143879854/work
triton==2.0.0
Twisted==22.10.0
types-dataclasses==0.6.6
typing_extensions==4.5.0
uri-template==1.2.0
urllib3 @ file:///croot/urllib3_1673575502006/work
wcwidth @ file:///Users/ktietz/demo/mc3/conda-bld/wcwidth_1629357192024/work
webcolors==1.12
webencodings==0.5.1
websocket-client==1.5.1
Werkzeug==2.2.3
yarl==1.8.2
zope.interface==6.0
zstandard @ file:///croot/zstandard_1677013143055/work

@SpecLad
Copy link
Contributor

SpecLad commented Jun 26, 2023

Okay, I think I see what's going on. Ultralytics updated their YOLOv5 model to require the ultralytics package, but they also updated their Docker image to install this package (see ultralytics/yolov5#11529).

I compared the version numbers in your log with the ones in my image, and they are older, so I believe that your image was just built with an outdated version of the base image. It should be sufficient to delete the image (docker image rm cvat.pth.ultralytics.yolov5), purge the build cache (docker system prune) and deploy again.

Since I don't think any changes to CVAT are needed, I'm going to close this. If your issue persists, feel free to reopen it.

@SpecLad SpecLad closed this Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants