由于docker hub 里只有vitis-ai的cpu版本镜像可以直接通过pull命令倒入,但是一些程序运行还是需要gpu版本,因此需要自己build vitis-ai-gpu。
官网给的代码是这样的
Use below commands to build the GPU docker:
cd setup/docker
./docker_build_gpu.sh
To run the GPU docker, use command:
./docker_run.sh xilinx/vitis-ai-gpu:latest
但是应该是国内网络的原因,就算科学上网也不太行以下记录一些错误以及能找到的最优的解决办法。(前提是从github上clone了最新的Vitis-AI)
参考APT Hash sum mismatch错误的常见解决方法总结_MingCHEN的博客-CSDN博客
更换apt源
# 备份
sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo gedit /etc/apt/sources.list
我选用的是清华镜像源 下面的网站可以根据系统版本选择镜像源,更改源文件内容即可ubuntu | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
更新列表
sudo apt-get update
sudo apt-get upgrade
更新vitis-ai-gpu.Dockerfile文件的内容,路径是/Vitis-AI/setup/docker/dockerfiles
参考 在 docker 中运行 apt-get update 报错 returned a non-zero code: 100 - Rioka - 博客园
搜索文件中的apt-get update,将其改成
apt-get update -o Acquire::CompressionTypes::Order::=gz
并在前面的RUN 后面添加网易的源,以及删除 /var/lib/apt/lists/文件的语句:需要修改的地方我列下了:
#例如 原本:
RUN chmod 1777 /tmp \
&& mkdir /scratch \
&& chmod 1777 /scratch \
&& apt-get update -y \
&& apt-get install -y --no-install-recommends \
apt-transport-https \
#修改后:
RUN sed -i "s@/archive.ubuntu.com/@/mirrors.163.com/@g" /etc/apt/sources.list \
&& rm -rf /var/lib/apt/lists/* \
&& chmod 1777 /tmp \
&& mkdir /scratch \
&& chmod 1777 /scratch \
&& apt-get update -o Acquire::CompressionTypes::Order::=gz -y \
&& apt-get install -y --no-install-recommends \
apt-transport-https \
#原本:
RUN apt-get -y install \
libgtest-dev \
libeigen3-dev \
rpm \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer1.0-dev \
libgtk-3-dev \
libpng-dev \
libjpeg-dev \
libopenexr-dev \
libtiff-dev \
libwebp-dev \
libgtk2.0-dev \
libhdf5-dev \
opencl-clhpp-headers \
opencl-headers \
pocl-opencl-icd \
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& apt install -y gcc-8 g++-8 gcc-9 g++-9 \
&& wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null \
&& apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' \
&& apt-get update -y \
#修改后:这里不需要加前面的语句
RUN apt-get -y install \
libgtest-dev \
libeigen3-dev \
rpm \
libavcodec-dev \
libavformat-dev \
libswscale-dev \
libgstreamer-plugins-base1.0-dev \
libgstreamer1.0-dev \
libgtk-3-dev \
libpng-dev \
libjpeg-dev \
libopenexr-dev \
libtiff-dev \
libwebp-dev \
libgtk2.0-dev \
libhdf5-dev \
opencl-clhpp-headers \
opencl-headers \
pocl-opencl-icd \
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& apt install -y gcc-8 g++-8 gcc-9 g++-9 \
&& wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null \
&& apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' \
&& apt-get update -o Acquire::CompressionTypes::Order::=gz -y \
#原本:
RUN wget --progress=dot:mega -O xrt.deb ${XRT_URL} \
&& ls -lhd ./xrt.deb \
&& apt-get update -y \
&& apt-get install -y ./xrt.deb \
&& rm -fr /tmp/*
#修改后:
RUN sed -i "s@/archive.ubuntu.com/@/mirrors.163.com/@g" /etc/apt/sources.list \
&& rm -rf /var/lib/apt/lists/* \
&& wget --progress=dot:mega -O xrt.deb ${XRT_URL} \
&& ls -lhd ./xrt.deb \
&& apt-get update -o Acquire::CompressionTypes::Order::=gz -y \
&& apt-get install -y ./xrt.deb \
&& rm -fr /tmp/*
网络连接问题,重新执行一次 ./docker_build_gpu.sh
类似的和网络有关的问题,比如一些包安装失败,都可以重新执行