dusty-nv / jetson-containers

Machine Learning Containers for NVIDIA Jetson and JetPack-L4T
MIT License
1.9k stars 416 forks source link

The container does not run after restarting it following the installation of an extension. #440

Open hotchilisauce opened 3 months ago

hotchilisauce commented 3 months ago

Hello, I am using Stable diffusion webui on Jetson AGX Xavier 32GB. I am on JetPack version 5.1.3, and using container image 35.3.1. Initially, it runs well. However, after running it and installing extensions like ADetailer, problems arise. If I install an extension and do not close Docker, I can use the extension normally. But if I shut down Docker and restart the container, it doesn't run and shows the following error.

Traceback (most recent call last): File "launch.py", line 48, in <module> main() File "launch.py", line 44, in main start() File "/opt/stable-diffusion-webui/modules/launch_utils.py", line 432, in start import webui File "/opt/stable-diffusion-webui/webui.py", line 13, in <module> initialize.imports() File "/opt/stable-diffusion-webui/modules/initialize.py", line 37, in imports from modules import processing, gradio_extensons, ui # noqa: F401 File "/opt/stable-diffusion-webui/modules/processing.py", line 14, in <module> import cv2 File "/usr/local/lib/python3.8/dist-packages/cv2/__init__.py", line 181, in <module> bootstrap() File "/usr/local/lib/python3.8/dist-packages/cv2/__init__.py", line 175, in bootstrap if __load_extra_py_code_for_module("cv2", submodule, DEBUG): File "/usr/local/lib/python3.8/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.8/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "/usr/local/lib/python3.8/dist-packages/cv2/mat_wrapper/__init__.py", line 39, in <module> cv._registerMatType(Mat) AttributeError: partially initialized module 'cv2' has no attribute '_registerMatType' (most likely due to a circular import)

From what I've found regarding the issue, if I delete the installed extensions (ADetailer, ... etc) from the extension folder, the container runs properly. Currently, this means that if an extension is installed, it must be deleted and reinstalled before the next container startup to run.

What is the problem? If you know how to solve it, please let me know. Thank you.

dusty-nv commented 3 months ago

@hotchilisauce I think when the extension is installed, it changes packages in the container (like OpenCV). But then when you shutdown the container, these changes are lost (except for the source files of the extension itself, which are presumably saved under the mounted /data/stable-diffusion location)

What you can try is saving the working container to a new tag with docker commit command, and then run that tag next time.