Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: libGL.so.1 on CentOS

Tags:

mesa

When I try to import cv2 in python I get the following error:

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

I found this thread which suggested I install libgl1-mesa-glx, but I'm wondering if that's only available on Ubuntu because I'm on CentOS and when I try to sudo yum install libgl1-mesa-glx I get No package libgl1-mesa-glx available. Also, when I added the installation to my dockerfile I got this error: The command '/bin/sh -c yum install libgl1-mesa-glx' returned a non-zero code: 1

Then I found what looked like a Fedora solution to the same problem that said to use mesa-libGL-devel. When I sudo yum install mesa-libGL-devel it appears to install correctly, but when I added that to my dockerfile I get The command '/bin/sh -c yum install mesa-libGL-devel' returned a non-zero code: 1.

What else should I try?

EDIT: Here is the Dockerfile:

FROM nvidia/cuda:10.1-cudnn7-devel-centos7

WORKDIR /app/
COPY ./*.* ./
ENV CONDA_DIR "/opt/conda"
ENV PATH "$CONDA_DIR"/bin:$PATH
ONBUILD ENV PATH "$CONDA_DIR"/bin:$PATH

RUN  \
   yum -y install epel-release && \
    yum -y update && \
    yum install -y \
    bzip2 \
    curl \
    which \
    libXext \
    libSM \
    libXrender \
    git \
    cuda-nvcc-10-1 \
    openssh-server \
    postgresql-devel \
    yum clean all && rm -rf /var/cache/yum/*


RUN CONDA_VERSION="4.5.1" && \
    curl -L \
       https://repo.continuum.io/miniconda/Miniconda3-${CONDA_VERSION}-Linux-x86_64.sh -o miniconda.sh && \
    mkdir -p "$CONDA_DIR" && \
    bash miniconda.sh -f -b -p "$CONDA_DIR" && \
    echo "export PATH=$CONDA_DIR/bin:\$PATH" > /etc/profile.d/conda.sh && \
    rm miniconda.sh && \
    conda config --add channels conda-forge && \
    conda update -y conda && \
    conda config --set auto_update_conda False && \
    pip install --upgrade pip && \
    pip install -r requirements.txt && \
    rm -rf /root/.cache/pip/* && \
    conda install gdal==2.4.2 tensorflow-gpu numpy==1.16.5


RUN conda env create -f py2_env.yaml
RUN conda env create -f py3_env.yaml

#Add gdal
RUN yum update -y
RUN yum upgrade -y
RUN yum install -y gcc python3-dev python3-pip libxml2-dev libxslt1-dev zlib1g-dev g++

RUN export CPLUS_INCLUDE_PATH=/usr/include/gdal
RUN export C_INCLUDE_PATH=/usr/include/gdal
RUN yum install -y gdal libgdal-dev gdal-devel 
#RUN /opt/conda/envs/py2/bin/pip install gdal==2.4.2
RUN /opt/conda/envs/py3/bin/pip install gdal==2.4.2


RUN /bin/bash -c "conda init bash && source /root/.bashrc && conda activate py2 && conda install -y notebook ipykernel && ipython kernel install --user && conda deactivate"

RUN /bin/bash -c "conda init bash && source /root/.bashrc && conda activate py3 && conda install -y notebook ipykernel && ipython kernel install --user && conda deactivate"
like image 238
jss367 Avatar asked Mar 11 '20 01:03

jss367


1 Answers

Just add this command:

yum install mesa-libGL
like image 187
Nakul Avatar answered Nov 01 '22 12:11

Nakul