0

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.

  • docker prevents you from using various resources, graphics display (OpenGL) being one of them. it's a known issue. don't use docker unless you have to. – Christoph Rackwitz Jul 01 '21 at 18:51
  • the project requires docker. it seems that it's possible to run opengl in docker (https://stackoverflow.com/questions/55313610/importerror-libgl-so-1-cannot-open-shared-object-file-no-such-file-or-directo), but the apt-get commands are not working for me. – anonymous_helix Jul 01 '21 at 18:56
  • `apt-get: command not found` means you don't have `apt`. what distribution is this? – Christoph Rackwitz Jul 01 '21 at 19:02
  • how do you find that out using docker? – anonymous_helix Jul 01 '21 at 19:12
  • `lsb-release` and `uname`, perhaps with additional arguments https://www.cyberciti.biz/faq/how-to-check-os-version-in-linux-command-line/ – Christoph Rackwitz Jul 01 '21 at 19:17
  • What's the `FROM` line at the top of your Dockerfile? (Really, for a [mre], you should be providing the entire Dockerfile in the question itself). – Charles Duffy Jul 05 '21 at 22:01
  • The best solution for this problem is presented [ImportError: libGL.so.1: cannot open shared object file: No such file or directory](https://stackoverflow.com/a/69125651/5127304) which gives you a way to use a precompiled binary wheel with no external dependencies for the cases like Docker containers. – Elias Aug 24 '22 at 10:12
  • Installing `mesa-libGL` as [Charles Duffy suggested](https://stackoverflow.com/a/68262468/20581881) also worked for me! – tweak Nov 23 '22 at 12:45
  • Installing `mesa-libGL` as [Charles Duffy suggested](https://stackoverflow.com/a/68262468/20581881) also works for me – tweak Nov 23 '22 at 12:47

2 Answers2

3

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

  • That means you're using a RPM-based distro instead of a Debian-based one. (`yum` is appropriate for Red Hat / Fedora / etc; `apt-get` is for Debian / Ubuntu / etc). – Charles Duffy Jul 05 '21 at 22:02
1

In my case, I was creating a python server with flask, that uses the cv2 from OpenCV to analyze images, and I managed to solve this problem by using the python:3.9-slim-buster docker image (that is light version of python full image, only with the necessary dependencies for the Python runtime) and installing the opencv-contrib-python package (you can get a description of this package here). Also I manage to install some apt packages needed by OpenCV, there are libsm6, libxext6, ffmpeg, libfontconfig1, libxrender1, libgl1-mesa-glx.

I've also tested with the python:3.8-slim-buster docker image with the same Dockerfile structure and it's worked fine.

Dockerfile

FROM python:3.9-slim-buster

WORKDIR /app

COPY . .
RUN apt update && apt install -y libsm6 libxext6 ffmpeg libfontconfig1 libxrender1 libgl1-mesa-glx
RUN pip install -r /app/requirements.txt

EXPOSE 8080

ENTRYPOINT [ "python3", "/app/main.py" ]

requirements.txt

Flask
numpy
opencv-contrib-python
python-dotenv

Just in case, the numpy, Flask, and python-dotenv is not necessary to install, I'm installing here because I need it in my python service.

I've seen a couple issues about it, but not a definitive answer. Some ways works for some people, some ways not.

I hope it helps.