华为鲲鹏920 部署 cpu 版 paddleocr

拉取基础镜像
  • docker pull python:3.8

  • 设置 pip
    pip config set global.index-url https://mirror.baidu.com/pypi/simple

  • 设置 apt

mv /etc/apt/sources.list /etc/apt/sources.list.bak 
将以下内容写入/etc/apt/sources.list
echo '
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
# deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
# # deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
deb https://security.debian.org/debian-security bullseye-security main contrib non-free
# deb-src https://security.debian.org/debian-security bullseye-security main contrib non-free
' > /etc/apt/sources.list
  • apt update
安装基础工具

apt install cmake patchelf -y

安装paddlepaddle
  • git clone https://github.com/PaddlePaddle/Paddle.git 若需指定版本:git clone --single-branch -b v2.2.2 --recursive https://github.com/PaddlePaddle/Paddle.git

  • cd Paddle/python && pip install -r requirements.txt && pip install protobuf==3.20.3

  • cd Paddle

  • mkdir build && cd build

  • ulimit -n 4096 # 链接过程中打开文件数较多,可能超过系统默认限制导致编译出错,设置进程允许打开的最大文件数

  • cmake 编译选项表

cmake .. \
-D PY_VERSION=3 \
-D PYTHON_EXECUTABLE=`which python3` \
-D WITH_ARM=ON \
-D WITH_TESTING=OFF \
-D CMAKE_BUILD_TYPE=Release \
-D ON_INFER=ON \
-D WITH_XBYAK=OFF \
-D CMAKE_CXX_FLAGS="-Wno-error -w" \
-D WITH_GPU=OFF \
-D WITH_NCCL=OFF \
-D WITH_RCCL=OFF \
-D WITH_AVX=OFF
  • make TARGET=ARMV8 -j$(nproc) # 注意,因为处理器为ARM架构,如果不加TARGET=ARMV8则会在编译的时候报错。

  • cd Paddle/build/python/dist && pip install paddlepaddle-2.2.2-cp38-cp38-linux_aarch64.whl

  • python -c "import paddle.fluid as fluid; fluid.install_check.run_check()" # 如果出现Your Paddle Fluid is installed succesfully!,说明您已成功安装。

安装 paddleocr
  • git clone paddleocr
  • cd PaddleOCR && pip install -r requirements.txt && pip install "opencv-python-headless<4.3" && python setup.py install && pip install numpy==1.23

至此paddleocr安装成功,下面的编译安装opencv用不上。供可能需要opencv高版本的使用。

编译安装 opencv【可选】
# 需要修改OPENCV_EXTRA_MODULES_PATH为opencv_contrib的绝对路径
cmake .. \
-DCMAKE_SYSTEM_PROCESSOR=arm64 \
-DCMAKE_OSX_ARCHITECTURES=arm64 \
-DWITH_OPENJPEG=OFF \
-DWITH_IPP=OFF \
-D CMAKE_BUILD_TYPE=RELEASE \
-D BUILD_opencv_xfeatures2d=OFF \
-D CMAKE_INSTALL_PREFIX=$(python3 -c "import sys; print(sys.prefix)") \
-D ENABLE_NEON=ON \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D BUILD_opencv_python2=OFF \
-D BUILD_opencv_python3=ON \
-D OPENCV_ENABLE_NONFREE=ON \
-D OPENCV_PYTHON3_INSTALL_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
-D PYTHON_EXECUTABLE=`which python3` \
-D OPENCV_EXTRA_MODULES_PATH=/data/hisw_ai/opencv_contrib/modules 

# -D BUILD_opencv_xfeatures2d=OFF # 这个模块开启时会自动下载一些模型,有些模型在国外服务器,如果用不到里面的算法,这里不推荐打开。
# -D ENABLE_NEON=ON # NEON指令是针对ARM平台的加速指令,在ARMv7及以上支持
# -D OPENCV_GENERATE_PKGCONFIG=ON  # 此选项方便调用OpenCV库
  • make -j$(nproc)
  • 编译完后安装 make install
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值