generative-models
generative-models copied to clipboard
ImportError: libGL.so.1 on reproducible environnement
Hi, Following the provided instructions, I've created a gitpod branch to automate these instructions, I keep getting this error even after installing required os packages:
File "/workspace/generative-models/.pt2/lib/python3.10/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
exec(code, module.__dict__)
File "/workspace/generative-models/scripts/demo/sampling.py", line 2, in <module>
from scripts.demo.streamlit_helpers import *
File "/workspace/generative-models/scripts/demo/streamlit_helpers.py", line 10, in <module>
from imwatermark import WatermarkEncoder
File "/workspace/generative-models/.pt2/lib/python3.10/site-packages/imwatermark/__init__.py", line 1, in <module>
from .watermark import WatermarkEncoder, WatermarkDecoder
File "/workspace/generative-models/.pt2/lib/python3.10/site-packages/imwatermark/watermark.py", line 5, in <module>
import cv2
File "/workspace/generative-models/.pt2/lib/python3.10/site-packages/cv2/__init__.py", line 181, in <module>
bootstrap()
File "/workspace/generative-models/.pt2/lib/python3.10/site-packages/cv2/__init__.py", line 153, in bootstrap
native_module = importlib.import_module("cv2")
File "/home/gitpod/.pyenv/versions/3.10.9/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
Do I have to download a specific model from huggingface?
Hi, you seem to be running into a problem with the opencv python package. It seems most likely that you have some missing dependencies (see here, maybe you can run sudo apt install ffmpeg libsm6 libtext6
) or some issue from streamlit (see here, run sudo apt install libgl1
in that case). Try running python -c "import cv2"
, if that fails, it's the first issue, if that runs through it is caused by streamlit. (Both of these fixes expect that you are running ubuntu)
if this doesn't help, try searching specifically for "opencv python" + your operating system & version.
Still having the same issue, we might be dealing with a deeper issue related to the Docker container's ability to access the graphics hardware, access the GPU (required by OpenCV for some operations) can be tricky because of the container isolation to host OS, even the Nvidia's Docker images didn't work (maybe due to the limitation of graphics ability), I think this has to be run outside of containers. How do you run this?
See here for installation instructions. I know that someone manged to make it work in docker, but for your nvidia/docker issues I recommend opening an issue with one of them.
See here for installation instructions. I know that someone manged to make it work in docker, but for your nvidia/docker issues I recommend opening an issue with one of them.
I confirm I'm having the same issue in Docker
root@4ff0cee5b260:/opt/program# python scripts/demo/detect.py assets/test_image.png
Traceback (most recent call last):
File "/opt/program/scripts/demo/detect.py", line 3, in <module>
import cv2
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 153, in bootstrap
native_module = importlib.import_module("cv2")
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
root@4ff0cee5b260:/opt/program#
In My docker file I have
FROM pytorchlightning/pytorch_lightning:base-cuda-py3.10-torch2.0-cuda11.8.0
# ...
COPY requirements/pt2.txt /opt/program/requirements.txt
# install requirements in order
RUN pip3 install -r /opt/program/requirements.txt
I'm also trying to build a docker image. I've tried a couple of base images, including pytorch/pytorch:1.12.1-cuda11.3-cudnn8-runtime which i found here and I always get some dependency error with RUN pip install -r requirements/pt2.txt
and they look something like ERROR: No matching distribution found for black==23.7.0
This is my Dockerfile
FROM pytorch/pytorch:1.12.1-cuda11.3-cudnn8-runtime
WORKDIR /app
RUN apt update && apt install -y git
RUN git clone https://github.com/Stability-AI/generative-models.git
WORKDIR /app/generative-models
RUN pip install -r requirements/pt2.txt
RUN pip install .
Edit: this worked for me (not sure about inferencing but I was able to build the app):
FROM pytorch/pytorch:latest
WORKDIR /app
RUN apt update && apt install -y git
RUN git clone https://github.com/Stability-AI/generative-models.git
WORKDIR /app/generative-models
RUN pip install -r requirements/pt2.txt
RUN pip install .
I have added a Dockerfile
with cuda 11.8, xformers, torch 2.0.1 and all required dependencies here