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

ImportError: libGL.so.1: cannot open shared object file: No such file or directory #1567

Closed
atinfinity opened this issue May 10, 2022 · 4 comments · Fixed by #1568
Closed
Assignees

Comments

@atinfinity
Copy link

atinfinity commented May 10, 2022

Checklist

  1. I have searched related issues but cannot get the expected help.
    Yes.
  2. The bug has not been fixed in the latest version.
    Yes.
    RUN apt-get update && apt-get install -y git ninja-build libglib2.0-0 libsm6 libxrender-dev libxext6 \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/*

Describe the bug
I tried to run demo/image_demo.py in docker container.
But, I could not run demo/image_demo.py. At this time, it occurs the following error.

ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Reproduction

  1. What command or script did you run?
git clone https://github.com/open-mmlab/mmsegmentation.git -b v0.24.1
cd mmsegmentation/docker
docker build -t mmsegmentation:0.24.1 .
docker run --runtime=nvidia -it mmsegmentation:0.24.1 bash

And, I run the following command in Docker container.

apt update
apt install wget
mkdir checkpoints
wget https://download.openmmlab.com/mmsegmentation/v0.5/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes/pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth -P checkpoints
python demo/image_demo.py demo/demo.png configs/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes.py checkpoints/pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth --device cuda:0 --palette cityscapes
  1. Did you make any modifications on the code or config? Did you understand what you have modified?
    No.

  2. What dataset did you use?
    Cityscapes Dataset

Environment

  1. Please run python mmseg/utils/collect_env.py to collect necessary environment information and paste it here.

I runned python mmseg/utils/collect_env.py. But, it occurs the following error.

ImportError: libGL.so.1: cannot open shared object file: No such file or directory
  1. You may add addition that may be helpful for locating the problem, such as
    • How you installed PyTorch [e.g., pip, conda, source]
    • Other environment variables that may be related (such as $PATH, $LD_LIBRARY_PATH, $PYTHONPATH, etc.)

This Dockerfile used pytorch/pytorch:1.11.0-cuda11.3-cudnn8-devel as base image.

Error traceback

# python demo/image_demo.py demo/demo.png configs/pspnet/pspnet_r50-d8_512x1024_40k_cityscapes.py checkpoints/pspnet_r50-d8_512x1024_40k_cityscapes_20200605_003338-2966598c.pth --device cuda:0 --palette cityscapes
Traceback (most recent call last):
  File "demo/image_demo.py", line 4, in <module>
    from mmseg.apis import inference_segmentor, init_segmentor, show_result_pyplot
  File "/mmsegmentation/mmseg/__init__.py", line 4, in <module>
    import mmcv
  File "/opt/conda/lib/python3.8/site-packages/mmcv/__init__.py", line 4, in <module>
    from .fileio import *
  File "/opt/conda/lib/python3.8/site-packages/mmcv/fileio/__init__.py", line 2, in <module>
    from .file_client import BaseStorageBackend, FileClient
  File "/opt/conda/lib/python3.8/site-packages/mmcv/fileio/file_client.py", line 15, in <module>
    from mmcv.utils.misc import has_method
  File "/opt/conda/lib/python3.8/site-packages/mmcv/utils/__init__.py", line 40, in <module>
    from .env import collect_env
  File "/opt/conda/lib/python3.8/site-packages/mmcv/utils/env.py", line 9, in <module>
    import cv2
  File "/opt/conda/lib/python3.8/site-packages/cv2/__init__.py", line 8, in <module>
    from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Bug fix

This Dockerfile need to install libgl1-mesa-dev for demo script.

@MengzhangLI
Copy link
Contributor

Hi, thanks for you nice issue & PR. We would review it ASAP!

Best,

@MengzhangLI
Copy link
Contributor

MengzhangLI commented May 10, 2022

BTW, could libgl1-mesa-glx also solve your problem?

Related PR in MMOCR: open-mmlab/mmocr#109.

@MengzhangLI MengzhangLI self-assigned this May 10, 2022
@atinfinity
Copy link
Author

@MengzhangLI

BTW, could libgl1-mesa-glx also solve your problem?

Yes. Thank you for your suggestion. I will apply #1568.

@liuwake
Copy link

liuwake commented Sep 3, 2024

pip install opencv-python-headless works for me.

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 a pull request may close this issue.

4 participants
@atinfinity @liuwake @MengzhangLI and others