From a8ff9ff130420407dcfc4328649af27dcaca2c15 Mon Sep 17 00:00:00 2001 From: cord <1139172570@qq.com> Date: Tue, 1 Jul 2025 15:23:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=93=9D=E5=8C=BA=E5=AE=89=E5=85=A8=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E6=95=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...erfile-ascendbase-infer.txt => Dockerfile} | 111 +++++++++--------- .../Dockerfile/Dockerfile-ascend-toolkit.txt | 43 ------- IndexSDK/Dockerfile/install_deps.sh | 61 ---------- IndexSDK/Dockerfile/urls.conf | 8 -- 4 files changed, 56 insertions(+), 167 deletions(-) rename IndexSDK/Dockerfile/{Dockerfile-ascendbase-infer.txt => Dockerfile} (97%) delete mode 100644 IndexSDK/Dockerfile/Dockerfile-ascend-toolkit.txt delete mode 100644 IndexSDK/Dockerfile/install_deps.sh delete mode 100644 IndexSDK/Dockerfile/urls.conf diff --git a/IndexSDK/Dockerfile/Dockerfile-ascendbase-infer.txt b/IndexSDK/Dockerfile/Dockerfile similarity index 97% rename from IndexSDK/Dockerfile/Dockerfile-ascendbase-infer.txt rename to IndexSDK/Dockerfile/Dockerfile index 16a983823..7a8d14eaa 100644 --- a/IndexSDK/Dockerfile/Dockerfile-ascendbase-infer.txt +++ b/IndexSDK/Dockerfile/Dockerfile @@ -1,55 +1,56 @@ -FROM ubuntu:18.04 -WORKDIR /tmp -COPY install_deps.sh ./ -COPY ./urls.conf ./ -# TODO -RUN chmod 777 /tmp -# 系统包 + Pip3.9 -RUN . ./urls.conf && cp -a /etc/apt/sources.list /etc/apt/sources.list.bak && \ - sed -i "$ARCHIVE_DOCKR" /etc/apt/sources.list && \ - sed -i "$SECRITY_DOCKR" /etc/apt/sources.list -RUN apt update && \ - apt install --no-install-recommends ca-certificates -y && \ - apt install --no-install-recommends wget vim dos2unix net-tools ssh lsof sshpass -y && \ - apt install --no-install-recommends curl gcc g++ make pkg-config unzip autoconf autoconf -y && \ - apt install --no-install-recommends libblas3 liblapack3 gfortran libxml2 -y && \ - apt install --no-install-recommends pciutils liblapack-dev libblas-dev libffi-dev libssl-dev -y && \ - apt install --no-install-recommends zlib1g-dev xz-utils libgmpxx4ldbl -y && \ - apt clean && rm -rf /var/lib/apt/lists/* -# 安装Python -RUN . ./urls.conf && wget $PYTHON_DOCKR && \ - tar -xf Python-3.9.11.tar.xz && \ - cd Python-3.9.11 && \ - mkdir build && cd build && \ - ../configure --enable-shared --prefix=/usr/local/python3.9.11 && \ - make -j && make install && \ - cd .. && rm -rf build && cd .. && rm -rf Python-3.9.11 && rm -f Python-3.9.11.tar.xz && \ - ldconfig -ENV PATH=$PATH:/usr/local/python3.9.11/bin \ - LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/python3.9.11/lib -RUN . ./urls.conf && mkdir ~/.pip && touch ~/.pip/pip.conf && \ - echo "[global]" > ~/.pip/pip.conf && \ - echo "trusted-host=mirrors.aliyun.com" >> ~/.pip/pip.conf && \ - echo "index-url=$INDEX_DOCKR" >> ~/.pip/pip.conf && \ - echo "timeout=200" >> ~/.pip/pip.conf -# python包 -RUN pip3.9 install -U pip && \ - pip3.9 install numpy && \ - pip3.9 install decorator && \ - pip3.9 install sympy==1.4 && \ - pip3.9 install cffi==1.12.3 && \ - pip3.9 install pyyaml && \ - pip3.9 install pathlib2 && \ - pip3.9 install protobuf && \ - pip3.9 install scipy && \ - pip3.9 install requests && \ - pip3.9 install attrs && \ - pip3.9 install psutil && \ - rm -rf /root/.cache/pip - -# 安装cmake -RUN . ./urls.conf && wget $CMAKE_DOCKR && \ - tar xf cmake-3.23.1.tar.gz && cd cmake-3.23.1 && ./configure --prefix=/usr && \ - make -j && make -j install && cd .. && rm -rf cmake-3.23.1* && bash install_deps.sh -# 清理临时目录 -RUN rm -rf ./* +FROM ubuntu:18.04 +WORKDIR /tmp +COPY install_deps.sh ./ +COPY ./urls.conf ./ +# TODO +RUN chmod 777 /tmp +# 系统包 + Pip3.9 +RUN . ./urls.conf && cp -a /etc/apt/sources.list /etc/apt/sources.list.bak && \ + sed -i "$ARCHIVE_DOCKR" /etc/apt/sources.list && \ + sed -i "$SECRITY_DOCKR" /etc/apt/sources.list +RUN apt update && \ + apt install --no-install-recommends ca-certificates -y && \ + apt install --no-install-recommends wget vim dos2unix net-tools ssh lsof sshpass -y && \ + apt install --no-install-recommends curl gcc g++ make pkg-config unzip autoconf autoconf -y && \ + apt install --no-install-recommends libblas3 liblapack3 gfortran libxml2 -y && \ + apt install --no-install-recommends pciutils liblapack-dev libblas-dev libffi-dev libssl-dev -y && \ + apt install --no-install-recommends zlib1g-dev xz-utils libgmpxx4ldbl -y && \ + apt clean && rm -rf /var/lib/apt/lists/* +# 安装Python +RUN . ./urls.conf && wget $PYTHON_DOCKR && \ + tar -xf Python-3.9.11.tar.xz && \ + cd Python-3.9.11 && \ + mkdir build && cd build && \ + ../configure --enable-shared --prefix=/usr/local/python3.9.11 && \ + make -j && make install && \ + cd .. && rm -rf build && cd .. && rm -rf Python-3.9.11 && rm -f Python-3.9.11.tar.xz && \ + ldconfig +ENV PATH=$PATH:/usr/local/python3.9.11/bin \ + LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/python3.9.11/lib +RUN . ./urls.conf && mkdir ~/.pip && touch ~/.pip/pip.conf && \ + echo "[global]" > ~/.pip/pip.conf && \ + echo "trusted-host=mirrors.aliyun.com" >> ~/.pip/pip.conf && \ + echo "index-url=$INDEX_DOCKR" >> ~/.pip/pip.conf && \ + echo "timeout=200" >> ~/.pip/pip.conf +# python包 +RUN pip3.9 install -U pip && \ + pip3.9 install numpy && \ + pip3.9 install decorator && \ + pip3.9 install sympy==1.4 && \ + pip3.9 install cffi==1.12.3 && \ + pip3.9 install pyyaml && \ + pip3.9 install pathlib2 && \ + pip3.9 install protobuf && \ + pip3.9 install scipy && \ + pip3.9 install requests && \ + pip3.9 install attrs && \ + pip3.9 install psutil && \ + rm -rf /root/.cache/pip + +# 安装cmake +RUN . ./urls.conf && wget $CMAKE_DOCKR && \ + tar xf cmake-3.23.1.tar.gz && cd cmake-3.23.1 && ./configure --prefix=/usr && \ + make -j && make -j install && cd .. && rm -rf cmake-3.23.1* && bash install_deps.sh +# 清理临时目录 +RUN rm -rf ./* + diff --git a/IndexSDK/Dockerfile/Dockerfile-ascend-toolkit.txt b/IndexSDK/Dockerfile/Dockerfile-ascend-toolkit.txt deleted file mode 100644 index 4aa351800..000000000 --- a/IndexSDK/Dockerfile/Dockerfile-ascend-toolkit.txt +++ /dev/null @@ -1,43 +0,0 @@ -ARG BASE_VERSION -ARG BASE=ascendbase-infer:$BASE_VERSION -FROM $BASE -ARG CHIP=all -WORKDIR /tmp -COPY . ./ -# 1.驱动路径环境变量设置 -ARG ASCEND_BASE=/usr/local/Ascend -ENV LD_LIBRARY_PATH=\ -$ASCEND_BASE/driver/lib64:\ -$ASCEND_BASE/driver/lib64/common:\ -$ASCEND_BASE/driver/lib64/driver:\ -$LD_LIBRARY_PATH -# 2. CANN Toolkit安装 -ARG TOOLKIT_PKG -ARG TOOLKIT_PATH=$ASCEND_BASE/ascend-toolkit/latest - -# 安装Toolkit -RUN mkdir -p $ASCEND_BASE/driver && \ - cp version.info $ASCEND_BASE/driver/ && \ - cp ascend_install.info /etc/ && \ - if [ "$CHIP" != "all" ]; \ - then \ - CHIPOPTION="--chip=$CHIP"; \ - else \ - CHIPOPTION=""; \ - fi && \ - chmod +x $TOOLKIT_PKG && \ - ./$TOOLKIT_PKG --quiet --install --install-path=$ASCEND_BASE \ - --install-for-all $CHIPOPTION && \ - rm -f $TOOLKIT_PKG && \ - rm -rf $ASCEND_BASE/driver && \ - rm -f /etc/ascend_install.info - -ENV GLOG_v=2 \ - LD_LIBRARY_PATH=$TOOLKIT_PATH/runtime/lib64:$LD_LIBRARY_PATH \ - TBE_IMPL_PATH=$TOOLKIT_PATH/opp/op_impl/built-in/ai_core/tbe \ - PATH=$TOOLKIT_PATH/atc/ccec_compiler/bin:$TOOLKIT_PATH/atc/bin:$PATH \ - ASCEND_OPP_PATH=$TOOLKIT_PATH/opp \ - ASCEND_AICPU_PATH=$TOOLKIT_PATH -ENV PYTHONPATH=$TBE_IMPL_PATH:$PYTHONPATH - -RUN rm -rf ./* \ No newline at end of file diff --git a/IndexSDK/Dockerfile/install_deps.sh b/IndexSDK/Dockerfile/install_deps.sh deleted file mode 100644 index 29db4cd5d..000000000 --- a/IndexSDK/Dockerfile/install_deps.sh +++ /dev/null @@ -1,61 +0,0 @@ -set -e -. ./urls.conf -# OpenBLAS -wget ${OpenBLAS_SH} -O OpenBLAS-0.3.10.tar.gz -tar -xf OpenBLAS-0.3.10.tar.gz -cd OpenBLAS-0.3.10 -make FC=gfortran USE_OPENMP=1 -j -make install -ln -s /opt/OpenBLAS/lib/libopenblas.so /usr/lib/libopenblas.so -cd .. && rm -f OpenBLAS-0.3.10.tar.gz && rm -rf OpenBLAS-0.3.10 - -# faiss 1.7.4 -install_path=/usr/local/faiss/faiss1.7.4 -wget ${FAISS_SH} -O faiss-1.7.4.tar.gz -tar -xf faiss-1.7.4.tar.gz && cd faiss-1.7.4/faiss - -arch="$(uname -m)" -if [ "${arch}" = "aarch64" ]; then - gcc_version="$(gcc -dumpversion)" - if ["${gcc_version}" = "4.8.5" ]; then - sed -i '20i /*' utils/simdlib.h - sed -i '24i */' utils/simdlib.h - fi -fi -sed -i "131 i\\ - \\ - virtual void search_with_filter (idx_t n, const float *x, idx_t k,\\ - float *distances, idx_t *labels, const void *mask = nullptr) const {} \\ -" Index.h -sed -i "38 i\\ - \\ -template \\ -IndexIDMapTemplate::IndexIDMapTemplate (IndexT *index, std::vector &ids):\\ - index (index),\\ - own_fields (false)\\ -{\\ - this->is_trained = index->is_trained;\\ - this->metric_type = index->metric_type;\\ - this->verbose = index->verbose;\\ - this->d = index->d;\\ - id_map = ids;\\ -}\\ -" IndexIDMap.cpp -sed -i "29 i\\ - \\ - explicit IndexIDMapTemplate (IndexT *index, std::vector &ids);\\ -" IndexIDMap.h -sed -i "199 i\\ - utils/sorting.h -" CMakeLists.txt - -cd .. -cmake -B build . -DFAISS_ENABLE_GPU=OFF -DFAISS_ENABLE_PYTHON=OFF -DBUILD_TESTING=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${install_path} -cd build && make -j && make install -cd ../.. && rm -rf faiss-1.7.4* - -wget ${RELEASE_SH} && \ -cp release-1.8.1.tar.gz /tmp/googletest-release-1.8.1.tar.gz && \ -tar xf release-1.8.1.tar.gz && cd googletest-release-1.8.1 && \ -cmake -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/usr/local/gtest . && make -j && make install && \ -cd .. && rm -rf release-1.8.1.tar.gz googletest-release-1.8.1 \ No newline at end of file diff --git a/IndexSDK/Dockerfile/urls.conf b/IndexSDK/Dockerfile/urls.conf deleted file mode 100644 index dfc67ca6f..000000000 --- a/IndexSDK/Dockerfile/urls.conf +++ /dev/null @@ -1,8 +0,0 @@ -OpenBLAS_SH=https://github.com/xianyi/OpenBLAS/archive/v0.3.10.tar.gz -FAISS_SH=https://github.com/facebookresearch/faiss/archive/v1.7.4.tar.gz -RELEASE_SH=https://github.com/google/googletest/archive/refs/tags/release-1.8.1.tar.gz -PYTHON_DOCKR=https://repo.huaweicloud.com/python/3.9.11/Python-3.9.11.tar.xz -CMAKE_DOCKR=https://github.com/Kitware/CMake/releases/download/v3.23.1/cmake-3.23.1.tar.gz -INDEX_DOCKR=http://mirrors.aliyun.com/pypi/simple -ARCHIVE_DOCKR=s@http://.*archive.ubuntu.com@http://mirrors.huaweicloud.com@g -SECRITY_DOCKR=s@http://.*security.ubuntu.com@http://mirrors.huaweicloud.com@g \ No newline at end of file -- Gitee