当前位置: 首页 > news >正文

企业网站推荐微信公众号人工服务电话

企业网站推荐,微信公众号人工服务电话,营销型企业网站建设方案书,网站开发有关费用接前文,本文介绍制作PaddleOCR/PaddleHub的GPU版本Docker镜像,以便在GPU环境下高效运行。 环境依赖 🔔 镜像制作过程在下述环境中进行的,酌情参考。 基础环境 ubuntu 22.04gcc/g++ 11.04Python 3.10paddlepaddle-gpu==2.6.1.post120paddleocr 2.7.5opencv-python 4.9.0.8…

接前文,本文介绍制作PaddleOCR/PaddleHub的GPU版本Docker镜像,以便在GPU环境下高效运行。

环境依赖

🔔  镜像制作过程在下述环境中进行的,酌情参考。

基础环境

  • ubuntu 22.04
  • gcc/g++ 11.04
  • Python 3.10
  • paddlepaddle-gpu==2.6.1.post120
  • paddleocr 2.7.5
  • opencv-python 4.9.0.80
  • paddlehub 2.4.0

GPU环境

  • cuda 12.2
  • Driver API Version: 12.4
  • Runtime API Version: 11.8

环境变量

必须的步骤

export CUDA_VISIBLE_DEVICES=0export LD_LIBRARY_PATH=/usr/local/cuda-12.2/lib64:$LD_LIBRARY_PATH
export PATH=/usr/local/cuda-12.2/bin:$PATH
export CUDA_HOME=/usr/local/cuda-12.2

基础镜像

拉取官方镜像并启动容器:

docker run -it --gpus all --name=paddlegpu -d paddlepaddle-gpu:2.6.1

说明:

如果无法拉取这个镜像(或嫌弃该镜像内容太多),也可以使用前文中生成的镜像 paddlehub:base ,然后逐步处理。

安装paddlepaddle-gpu

安装 CUDA12.0 包含 cuDNN 动态链接库的 PaddlePaddle

python3 -m pip install paddlepaddle-gpu==2.6.1.post120 -f https://www.paddlepaddle.org.cn/whl/linux/cudnnin/stable.html

验证

python3.10 -c "import paddle; paddle.utils.run_check()"

cuda和cuDNN安装完成后,验证正常如下:

root@b40610924ca2:/usr/local/cuda-12.2/targets/x86_64-linux/lib# python3.10 -c "import paddle; paddle.utils.run_check()"
Running verify PaddlePaddle program ... 
I0511 02:00:54.641423   814 program_interpreter.cc:212] New Executor is Running.
W0511 02:00:54.643276   814 gpu_resources.cc:119] Please NOTE: device: 0, GPU Compute Capability: 8.0, Driver API Version: 12.4, Runtime API Version: 11.8
W0511 02:00:54.643945   814 gpu_resources.cc:164] device: 0, cuDNN Version: 8.9.
I0511 02:00:55.097067   814 interpreter_util.cc:624] Standalone Executor is Used.
PaddlePaddle works well on 1 GPU.
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.

 可能出现的问题

 执行检测指令后出现异常响应:

root@e93431fbf153:/PaddleOCR# python3.10 -c "import paddle; paddle.utils.run_check()"
/usr/local/lib/python3.10/dist-packages/paddle/base/framework.py:688: UserWarning: You are using GPU version Paddle, but your CUDA device is not set properly. CPU device will be used by default.warnings.warn(
Running verify PaddlePaddle program ... 
[2024-05-10 13:17:24,497] [ WARNING] install_check.py:60 - You are using GPU version PaddlePaddle, but there is no GPU detected on your machine. Maybe CUDA devices is not set properly.Original Error is 
I0510 13:17:24.505074  4123 program_interpreter.cc:212] New Executor is Running.
I0510 13:17:24.539232  4123 interpreter_util.cc:624] Standalone Executor is Used.
PaddlePaddle works well on 1 CPU.
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.

解决

安装 CUDA 和 cuDNN。

  • CUDA

如果宿主机安装了CUDA,可直接拷贝到容器内(宿主机上CUDA安装过程不演示):

docker cp /usr/local/cuda paddlegpu:/usr/local# 下面的步骤是因为有软连接。如果没有,则省略
# docker cp /usr/local/cuda-12.2 paddlegpu:/usr/local##添加环境变量
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

容器内查看CUDA安装结果:

root@b40610924ca2:/# nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Tue_Aug_15_22:02:13_PDT_2023
Cuda compilation tools, release 12.2, V12.2.140
Build cuda_12.2.r12.2/compiler.33191640_0

说明:

如果基础镜像中包含了旧版本的CUDA,可直接删除。然后拷贝新版本使用。

  • 安装cuDNN

容器内执行下面这个指令,确保执行成功:

python3 -m pip install paddlepaddle-gpu==2.6.1.post120 -f https://www.paddlepaddle.org.cn/whl/linux/cudnnin/stable.html

安装PoddleOCR

在容器内执行:

wget https://github.com/PaddlePaddle/PaddleOCR/archive/refs/tags/v2.7.5.tar.gz && \tar -zxvf v2.7.5.tar.gz && \mv PaddleOCR-2.7.5 PaddleOCR \&& rm -rf v2.7.5.tar.gz \&& cd PaddleOCR \&& pip3.10 install -r requirements.txt -i https://mirror.baidu.com/pypi/simple \&& mkdir -p /PaddleOCR/inference/ \&& wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_det_infer.tar && \tar xf ch_ppocr_mobile_v2.0_det_infer.tar -C /PaddleOCR/inference/ && \wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_cls_infer.tar && \tar xf ch_ppocr_mobile_v2.0_cls_infer.tar -C /PaddleOCR/inference/ && \wget https://paddleocr.bj.bcebos.com/dygraph_v2.0/ch/ch_ppocr_mobile_v2.0_rec_infer.tar && \tar xf ch_ppocr_mobile_v2.0_rec_infer.tar -C /PaddleOCR/inference/ \&& rm -rf ch_ppocr_mobile_v2.0_det_infer.tar \&& rm -rf ch_ppocr_mobile_v2.0_cls_infer.tar \&& rm -rf ch_ppocr_mobile_v2.0_rec_infer.tar

安装paddlehub

pip3.10 install --upgrade -i https://mirror.baidu.com/pypi/simple paddlehub## 以下包 是执行hub serving install 时需要安装的包
pip3.10 install -i https://mirror.baidu.com/pypi/simple shapely
pip3.10 install -i https://mirror.baidu.com/pypi/simple pyclipper
pip3.10 install -i https://mirror.baidu.com/pypi/simple scikit-image
pip3.10 install -i https://mirror.baidu.com/pypi/simple imgaug
pip3.10 install -i https://mirror.baidu.com/pypi/simple lmdb

安装模块

#表格识别
hub install deploy/hubserving/structure_table#文字识别
hub install deploy/hubserving/ocr_system#版面识别
hub install deploy/hubserving/structure_layout

不报错,说明安装成功了。

说明:

其他模块按需安装。

其他问题

ImportError: libGL.so.1

File "/usr/local/lib/python3.10/dist-packages/paddlehub/vision/utils.py", line 18, in <module>import cv2
ImportError: libGL.so.1: cannot open shared object file: No such file or directory

需要安装如下包(容器内):

apt-get update
apt-get install libgl1-mesa-glx -y
apt-get install libglib2.0-0 -y

降级protobuf

报错:

TypeError: Descriptors cannot be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:1. Downgrade the protobuf package to 3.20.x or lower.
…………

解决方案:降级

pip3.10 install -i https://mirror.baidu.com/pypi/simple protobuf==3.20.2

缺少模型文件

类似如下报错:

    raise ValueError(
ValueError: not find model.pdmodel or inference.pdmodel in ./inference/ch_PP-OCRv3_det_infer/

少哪个模型就下载、解压到inference目录下即可。

同时,修改params.py文件:

cd /PaddleOCR
vi deploy/hubserving/structure_table/params.pydef read_params():cfg = pp_ocr_read_params()# params for table structure modelcfg.table_max_len = 488#cfg.table_model_dir = './inference/en_ppocr_mobile_v2.0_table_structure_infer/'cfg.table_model_dir = './inference/ch_ppstructure_mobile_v2.0_SLANet_infer/'#cfg.table_char_dict_path = './ppocr/utils/dict/table_structure_dict.txt'cfg.table_char_dict_path = './ppocr/utils/dict/table_structure_dict_ch.txt'cfg.show_log = Falsereturn cfg

版本问题

启动gpu版本的服务后,客户端调用时报错ÿ

http://www.dtcms.com/a/479512.html

相关文章:

  • 国家电网智能车载终端TBOX
  • 南宁网站建设升上去proxy网站
  • chatgpt-codex使用显示Error starting conversation
  • 搜狐网站建设的建议网站开发工资多少
  • Java中关于HashMap的元素遍历的顺序问题
  • 南通江苏网站建设建设淘宝网站的市场分析
  • 网站备案容易通过吗深入挖掘wordpress
  • 网站程序基础wordpress安装无法连接数据库
  • 淘宝天猫优惠卷网站建设网站建设 好发信息网
  • 柔性制造的终极答案:富唯智能机器人如何以“全能感官”实现一机多能
  • Zabbix 配置钉钉告警
  • 网站建设最快多长时间苏州做网站公司精选苏州聚尚网络
  • Docker 镜像版本Alpine、Slim、Bookworm、Bullseye、Stretch、Jessie
  • 网上网站代码可以下载吗转移网站如何转数据库
  • 企业网站示例网站建设方案撰写
  • 数据结构:哈希基础、6种哈希函数构造方法、4种解决哈希冲突的方法和哈希扩展(一致性哈希+虚拟节点+布隆过滤器)
  • 网站做哪种推广好建设银行租房网站湖北
  • 网站建设公司基本流程无锡专业做网站
  • 工商注册网站官网网站和app可以做充值余额功能
  • 东莞网站开发后缀微营销论文
  • 【AI论文】Paper2Video:从科学论文自动生成视频
  • Pod的进阶
  • 汽车4s店网站建设方案自己设计建房子的软件
  • 玉器哪家网站做的好中小企业信息网官网
  • Node.js zlib模块所有 API 详解 + 常用 API + 使用场景
  • wordpress怎么加入站长统计聊城网站建设策划建设公司
  • 优化网站的软件wordpress文章全部展示
  • 大型网站建设行情吉林长春建设工程信息网站
  • 在线网站做品牌网站怎么样
  • 从零开始认识大模型:它的过去、现在与未来以及核心原理