[问题已处理]-虚拟机运行container报错libEGL warning- egl- failed to create dri2 screen
物理机相对较新,可能硬件对某些版本支持不太友好。调整基础镜像为nvidia/opengl:1.0-glvnd-devel-ubuntu22.04测试就没问题了。导语:同一个镜像在22.04的宿主机上egl没问题,在16.04的宿主机上提示。原Dockerfile如下,基础镜像是ubuntu:22.04。
·
导语:同一个镜像在22.04的宿主机上egl没问题,在16.04的宿主机上提示
VMware: No 3D enabled (0, Success). libEGL warning: egl: failed to create dri2 screen VMware: No 3D enabled (0, Success). libEGL warning: egl: failed to create dri2 screen
处理方法:
物理机相对较新,可能硬件对某些版本支持不太友好。调整基础镜像为nvidia/opengl:1.0-glvnd-devel-ubuntu22.04 测试就没问题了。
原Dockerfile如下,基础镜像是ubuntu:22.04
FROM ubuntu:22.04 as builder-base
ENV DEBIAN_FRONTEND=noninteractive
RUN --mount=type=tmpfs,target=/tmp sed -i -e 's/^APT/# APT/' -e 's/^DPkg/# DPkg/' /etc/apt/apt.conf.d/docker-clean \
&& apt-get update -qqq 1>/dev/null \
&& apt-get install libxml2 gcc wget vim -y -qqq --no-install-recommends \
&& cd /tmp && wget -c -q http://172.16.40.245:82/2204/cuda117_2204.tgz \
&& wget -c -q http://172.16.40.245:82/docker_build/amd64/16.04/jsoncpp_dcmtk_opencv_node.tgz \
&& wget -c -q http://172.16.40.245:82/docker_build/amd64/22.04/sources.list.ali -O /srv/sources.list.ali \
&& wget -c -q http://172.16.40.245:82/docker_build/amd64/16.04/get-pip.py -O /srv/get-pip.py \
&& wget -c -q http://172.16.40.245:82/docker_build/ANTs.2.1.0.Debian-Ubuntu_X64.tgz \
&& tar zxf /tmp/jsoncpp_dcmtk_opencv_node.tgz -C /opt/ \
&& tar zxf /tmp/ANTs.2.1.0.Debian-Ubuntu_X64.tgz -C /usr/local/ \
&& tar -zxf /tmp/cuda117_2204.tgz -C /
### 安装完成后清理不必要的文件
RUN --mount=type=tmpfs,target=/tmp rm -rf /usr/local/cuda-11.7/doc/* && \
find /usr/local/cuda-11.7/ -type f -name '*.pdf' -delete
# COPY TensorRT-8.0.1.6.tgz /opt/
# RUN tar zxf /opt/TensorRT-8.0.1.6.tgz -C /opt/ \
# && rm -rf TensorRT-8.0.1.6.tgz
#FROM ubuntu:22.04 as builder-freesurfer
#COPY freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tgz /opt/
#RUN tar zxf /opt/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tgz -C /usr/local/ \
#&& rm -rf /opt/freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0.tgz
#FROM ubuntu:22.04
FROM ubuntu:22.04
COPY --from=builder-base /opt/ /opt/
COPY --from=builder-base /srv/ /srv/
COPY --from=builder-base /usr/local/ANTs.2.1.0.Debian-Ubuntu_X64 /usr/local/ANTs.2.1.0.Debian-Ubuntu_X64
COPY --from=builder-base /usr/local/cuda-11.7 /usr/local/cuda-11.7
RUN ln -s /usr/local/cuda-11.7 /usr/local/cuda
### 先安装python3.10
RUN sed -i -e 's/^APT/# APT/' -e 's/^DPkg/# DPkg/' /etc/apt/apt.conf.d/docker-clean \
&& rm -rf /etc/apt/sources.list.d/* \
&& apt-get update -qqq 1>/dev/null \
&& apt-get install python3.10 -y -qqq --no-install-recommends \
### 安装egl
&& apt-get install libegl1-mesa-dev libgles2-mesa-dev -y -qqq --no-install-recommends \
&& apt-get install python3-dev python3-distutils -y -qqq --no-install-recommends \
&& rm -rf /usr/bin/python3 \
&& ln -s /usr/bin/python3.10 /usr/bin/python3 \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /root/.cache/pip/
RUN apt-get update -qqq 1>/dev/null \
&& apt-get install vim lsof git zip rsync pigz curl telnet wget unzip net-tools inetutils-ping -y -qqq --no-install-recommends \
&& DEBIAN_FRONTEND="noninteractive" apt-get install tzdata -y -qqq --no-install-recommends \
&& rm -rf /etc/localtime \
&& ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*
### 安装openfoa7
RUN --mount=type=tmpfs,target=/tmp cd /tmp \
&& wget -c -q http://172.16.40.245:82/docker_build/amd64/22.04/openfoam7_2204.tgz \
&& tar zxf openfoam7_2204.tgz && mv /tmp/srv/OpenFOAM-7 /opt/openfoam7 \
&& ldconfig
RUN --mount=type=tmpfs,target=/tmp cd /tmp \
&& wget -c -q http://172.16.40.245:82/docker_build/VTK-8.2.0.tgz \
&& tar zxf VTK-8.2.0.tgz && rm -rf /usr/local/include/vtk-8.2 && cp -rf VTK-8.2.0/* /usr/local/ \
&& rm -rf /srv/VTK-8.2.0 \
&& ldconfig
RUN rsync -aq /opt/dcmtk/ /usr/local/ \
&& rsync -aq /opt/opencv/ /usr/local/ \
&& rm -f /usr/lib/x86_64-linux-gnu/libstdc++.so.6 \
&& ldconfig
### 这里要注意一下 # 忘记为啥了
#RUN rm -f /usr/lib/x86_64-linux-gnu/libstdc++.so.6 \
#&& ln -s /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.26 /usr/lib/x86_64-linux-gnu/libstdc++.so.6 \
#&& ldconfig
### 这一串需要替换成jenkins中的python依赖
# RUN --mount=type=tmpfs,target=/tmp cd /tmp \
# && wget -c http://172.16.40.245:82/2204/pythonlib_drwise_2.0.tgz \
# && rm -rf /usr/lib/python* /usr/local/lib/python* \
# && tar xpPf pythonlib_drwise_2.0.tgz -C / \
# && find /usr/local/lib -name '*.pyc' -delete \
# && apt clean \
# && rm -rf /var/lib/apt/lists/* \
# && rm -rf /root/.cache/pip/
### 替换python依赖
RUN rm -rf /usr/local/lib/python3.10 /usr/local/lib/python2.7
COPY python3.10 /usr/local/lib/python3.10
COPY python2.7 /usr/local/lib/python2.7
### 安装pip
RUN python3 /srv/get-pip.py -i https://pypi.tuna.tsinghua.edu.cn/simple >/dev/null 2>&1 \
&& python3 -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple >/dev/null 2>&1 \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /root/.cache/pip/
### env 部分java 和TensorRT-8.0.1.6 没有了
RUN echo "export LC_ALL='C.UTF-8'" >> /root/.bashrc \
&& echo "export LANG='C.UTF-8'" >> /root/.bashrc \
&& echo "export ANTSPATH=/usr/local/ANTs.2.1.0.Debian-Ubuntu_X64" >> /root/.bashrc \
&& echo "export JRE_HOME=\${JAVA_HOME}/jre" >> /root/.bashrc \
&& echo "export JAVA_HOME=/opt/jdk1.8.0_151" >> /root/.bashrc \
&& echo "export DCMDICTPATH=/usr/local/share/dcmtk/dicom.dic" >>/root/.bashrc \
&& echo "export DCMDICTPATH=/usr/local/share/dcmtk/dicom.dic" >>/etc/profile \
&& echo "export CUDA_ROOT=/usr/local/cuda" >> /root/.bashrc \
&& echo "export CLASSPATH=.:\${JAVA_HOME}/lib:\${JRE_HOME}/lib" >> /root/.bashrc \
&& echo "export CPATH=\$CPATH:/usr/local/cuda-11.7/targets/x86_64-linux/include" >> /root/.bashrc \
&& echo "export PATH=\$PATH:\$CUDA_ROOT/bin:\$ANTSPATH" >> /root/.bashrc \
&& echo "export LD_LIBRARY_PATH=/usr/local/cuda-11.7/targets/x86_64-linux/lib:/opt/TensorRT-8.0.1.6/lib:/usr/local/lib/:\$LD_LIBRARY_PATH" >> /root/.bashrc \
&& echo "export LD_LIBRARY_PATH=/usr/local/cuda-11.7/targets/x86_64-linux/lib:/opt/TensorRT-8.0.1.6/lib:/usr/local/lib/:\$LD_LIBRARY_PATH" >> /root/profile
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8
ENV ANTSPATH /usr/local/ANTs.2.1.0.Debian-Ubuntu_X64
ENV JRE_HOME ${JAVA_HOME}/jre
ENV JAVA_HOME /opt/jdk1.8.0_151
ENV DCMDICTPATH /usr/local/share/dcmtk/dicom.dic
ENV CUDA_ROOT /usr/local/cuda
ENV CLASSPATH .:${JAVA_HOME}/lib:${JRE_HOME}/lib
ENV CPATH $CPATH:/usr/local/cuda-11.7/targets/x86_64-linux/include
# ENV PATH $PATH:$CUDA_ROOT/bin:$ANTSPATH
ENV PATH $PATH:${JAVA_HOME}/bin:$CUDA_ROOT/bin:$ANTSPATH
ENV LD_LIBRARY_PATH /usr/local/cuda-11.7/targets/x86_64-linux/lib:/opt/TensorRT-8.0.1.6/lib:/usr/local/lib/:$LD_LIBRARY_PATH
###
# --no-deps是一个pip命令选项,用于在安装包时防止安装依赖项。如果使用该选项,pip将不会安装所需的依赖项,而只会安装指定的软件包本身。这可用于避免意外更改系统中的其他软件包或避免冲突的依赖项版本。
# apt-get install libcups2-dev -y --no-install-recommends \
### 这里最好根据最新的显卡版本进行更新
RUN wget -c -q http://172.16.40.245:82/docker_build/libcuda.so.470.63.01 -O /usr/lib/x86_64-linux-gnu/libcuda.so.470.63.01
RUN --mount=type=tmpfs,target=/tmp export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda-11.7/targets/x86_64-linux/lib \
&& export CPATH=\$CPATH:/usr/local/cuda-11.7/targets/x86_64-linux/include \
&& rm -rf /usr/lib/x86_64-linux-gnu/libcuda.so.1 \
&& ln -s /usr/lib/x86_64-linux-gnu/libcuda.so.470.63.01 /usr/lib/x86_64-linux-gnu/libcuda.so.1 \
&& ln -s /usr/lib/x86_64-linux-gnu/libcuda.so.1 /usr/lib/x86_64-linux-gnu/libcuda.so \
&& apt clean \
&& rm -rf /var/lib/apt/lists/* \
&& rm -rf /root/.cache/pip/ \
&& ldconfig
### 以下不确定算法是否需要增加 大概率不需要
# COPY CTA_Client_Deploy /srv/CTA_Client_Deploy
# COPY libopencv_java.so /usr/lib/libopencv_java.so
# COPY libnewgsps.so /usr/lib/libnewgsps.so
# COPY libSvrCallLungRecon.so /usr/lib/libSvrCallLungRecon.so
# RUN cd /srv/CTA_Client_Deploy && bash /srv/CTA_Client_Deploy/copyfile.sh \
# && ldconfig
### 修改sh 到bash
RUN rm /bin/sh && ln -s /bin/bash /bin/sh
### 编译OpenFOAM 这里会报错
# COPY of_package.tgz /srv/of_package.tgz
# COPY of_install.sh /srv/of_install.sh
# RUN cd /srv/ && bash of_install.sh
### 这个后面没了吧,变成third_party了?
# RUN --mount=type=tmpfs,target=/tmp cd /tmp \
# && wget -c -q http://172.16.40.245:82/of_package.tgz \
# && wget -c -q http://172.16.40.245:82/of_install.sh \
# && chmod +x of_install.sh \
# && bash of_install.sh \
# && ln -sf /root/lung/CTFFR/ACVD/bin/ACVD /usr/bin/
### 增加peisu提供的算法依赖
RUN --mount=type=tmpfs,target=/tmp cd /tmp \
&& wget -c -q http://172.16.40.245:82/docker_build/amd64/22.04/lung_lib.tgz \
&& tar zxf lung_lib.tgz \
&& cp /tmp/lib/* /lib/x86_64-linux-gnu/
### libglib2.0-dev 请务必最后安装 会造成dpkg异常
RUN apt-get update -qqq 1>/dev/null \
&& DEBIAN_FRONTEND="noninteractive" apt-get install libcurand10 -y --no-install-recommends \
&& apt-get install libxrender1 -y -qqq --no-install-recommends \
&& apt-get install libglib2.0-dev -y -qqq --no-install-recommends \
### 清理hook提示
#&& echo > /etc/dpkg/dpkg.cfg.d/pkg-config-hook-config \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*
# k8s启动需要加这些env 否则cuda或者egl会有问题 建议直接开启特权模式 securityContext: privileged: true
# env:
# - name: NVIDIA_DRIVER_CAPABILITIES
# value: compute,utility,video,graphics,display
# - name: NVIDIA_VISIBLE_DEVICES
# value: all
更多推荐
已为社区贡献21条内容
所有评论(0)