You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When import cv2 (needed for some models), get AttributeError: module 'cv2.dnn' has no attribute 'DictValue'
Public issue has a workaround using opencv-python==4.8.0.74
Minimum reproducible example
$ docker run --shm-size=1g --ulimit memlock=-1 --ulimit stack=67108864 --rm -it nvcr.io/nvidia/modulus/modulus:24.09 bash
====================
== NVIDIA Modulus ==
====================
NVIDIA Release 24.09 (build 18526012)
Modulus PyPi Version 0.8.0 (Git Commit: eb01d2a)
Modulus Sym PyPi Version 1.7.0 (Git Commit: 249b76a)
Container image Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copyright (c) 2014-2024 Facebook Inc.
Copyright (c) 2011-2014 Idiap Research Institute (Ronan Collobert)
Copyright (c) 2012-2014 Deepmind Technologies (Koray Kavukcuoglu)
Copyright (c) 2011-2012 NEC Laboratories America (Koray Kavukcuoglu)
Copyright (c) 2011-2013 NYU (Clement Farabet)
Copyright (c) 2006-2010 NEC Laboratories America (Ronan Collobert, Leon Bottou, Iain Melvin, Jason Weston)
Copyright (c) 2006 Idiap Research Institute (Samy Bengio)
Copyright (c) 2001-2004 Idiap Research Institute (Ronan Collobert, Samy Bengio, Johnny Mariethoz)
Copyright (c) 2015 Google Inc.
Copyright (c) 2015 Yangqing Jia
Copyright (c) 2013-2016 The Caffe contributors
All rights reserved.
Various files include modifications (c) NVIDIA CORPORATION & AFFILIATES. All rights reserved.
This container image and its contents are governed by the NVIDIA Deep Learning Container License.
By pulling and using the container, you accept the terms and conditions of this license:
https://developer.nvidia.com/ngc/nvidia-deep-learning-container-license
WARNING: The NVIDIA Driver was not detected. GPU functionality will not be available.
Use the NVIDIA Container Toolkit to start this container with GPU support; see
https://docs.nvidia.com/datacenter/cloud-native/ .
root@a39474d3ac70:/workspace# python
Python 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license"for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in<module>
File "/usr/local/lib/python3.10/dist-packages/cv2/__init__.py", line 181, in<module>bootstrap()
File "/usr/local/lib/python3.10/dist-packages/cv2/__init__.py", line 175, in bootstrap
if __load_extra_py_code_for_module("cv2", submodule, DEBUG):
File "/usr/local/lib/python3.10/dist-packages/cv2/__init__.py", line 28, in __load_extra_py_code_for_module
py_module = importlib.import_module(module_name)
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/usr/local/lib/python3.10/dist-packages/cv2/typing/__init__.py", line 171, in<module>
LayerId = cv2.dnn.DictValue
AttributeError: module 'cv2.dnn' has no attribute 'DictValue'
>>> exit()
root@68fd1b511c77:/workspace# pip install opencv-python==4.8.0.74
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Collecting opencv-python==4.8.0.74
...
root@68fd1b511c77:/workspace# python
Python 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license"for more information.
>>> import cv2
>>>
Relevant log output
See above
Environment details
See above
The text was updated successfully, but these errors were encountered:
luke-conibear
changed the title
🐛[BUG]: Importing opencv-python fails when using the latest Modulus container.
🐛[BUG]: Importing opencv-python fails when using Modulus container (24.09)
Oct 21, 2024
Version
0.8.0
On which installation method(s) does this occur?
Docker
Describe the issue
Importing opencv-python fails when using Modulus container (24.09)
nvcr.io/nvidia/modulus/modulus:24.09
usesopencv-python==4.10.0.84
import cv2
(needed for some models), getAttributeError: module 'cv2.dnn' has no attribute 'DictValue'
opencv-python==4.8.0.74
Minimum reproducible example
Relevant log output
See above
Environment details
See above
The text was updated successfully, but these errors were encountered: