Search code examples
pythondockertensorflowopencvapt

ImportError: libGL.so.1 when running Docker container with OpenCV


I'm getting the following error when running my docker container:

  W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such fi
le or directory
2021-07-01 18:39:36.985933: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Traceback (most recent call last):
  File "/opt/program/analyze", line 4, in <module>
    from analysis.image_data_analyzer import ImageDataAnalyzer
  File "/opt/program/analysis/image_data_analyzer.py", line 1, in <module>
    from alibi_detect.utils.saving import save_detector, load_detector
  File "/usr/local/lib/python3.6/site-packages/alibi_detect/__init__.py", line 1, in <module>
    from . import ad, cd, models, od, utils
  File "/usr/local/lib/python3.6/site-packages/alibi_detect/od/__init__.py", line 10, in <module>
    from .llr import LLR
  File "/usr/local/lib/python3.6/site-packages/alibi_detect/od/llr.py", line 13, in <module>
    from alibi_detect.utils.perturbation import mutate_categorical
  File "/usr/local/lib/python3.6/site-packages/alibi_detect/utils/perturbation.py", line 1, in <module>
    import cv2
  File "/usr/local/lib64/python3.6/site-packages/cv2/__init__.py", line 5, in <module>
    from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

I tried running the following commands as suggested here.

RUN apt-get update ##[edited]
RUN apt-get install ffmpeg libsm6 libxext6  -y

However, I get the error /bin/sh: apt-get: command not found. I also tried installing libGL with yum, but that also did not work. The parent image of this container is linux. Any ideas on how to solve this error? Thank you.


Solution

  • Solved issue by adding this line to the Dockerfile: RUN yum -y install mesa-libGL