一、问题描述:
- 刚开始用paddle的CPU版本,对训练好的模型进行推理,正常识别出想要的结果
- 后来尝试使用paddle的GPU版本,然后发现识别出来是空的
二、系统思路:
- 最终系统环境如下:
系统:win10 显卡:GeForce GT 730 GPU计算能力:3.5 Python:3.10 cuda:10.2.0 cudnn:7.6.5 paddlepaddle:2.4.2
- 总体思路:根据GPU计算能力和GPU型号,查找对应的CUDA版本,并且通过尝试降cuda版本和降paddle版本使其运行
三、解决过程
1、使用CUDA11.2、CUDNN8.2.1、paddle-gpu2.6.1的版本(×)
- 在网上查找资料,安装了如上的对应版本,报错如下
(base) D:\Downloads>python -c "import paddle; paddle.utils.run_check()" Running verify PaddlePaddle program ... I0831 10:35:55.205960 7352 interpretercore.cc:237] New Executor is Running. W0831 10:35:55.205960 7352 gpu_resources.cc:96] The GPU architecture in your current machine is Pascal, which is not compatible with Paddle installation with arch: 70 75 80 86 , it is recommended to install the corresponding wheel package according to the installation information on the official Paddle website. W0831 10:35:55.206962 7352 gpu_resources.cc:119] Please NOTE: device: 0, GPU Compute Capability: 3.5, Driver API Version: 11.4, Runtime API Version: 11.2 W0831 10:35:55.221961 7352 gpu_resources.cc:149] device: 0, cuDNN Version: 8.2. I0831 10:35:56.037954 7352 interpreter_util.cc:518] Standalone Executor is Used. PaddlePaddle works well on 1 GPU. PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.
- 说是成功了,但其实程序跑起来,gpu根本没用上!可以用下面这段代码测试。
from paddlenlp import Taskflow from pprint import pprint # 定义抽取目标的schema # 这里我们定义了一个schema,用于抽取人物和他们所在的组织 schema = [{"人物": ["姓名"]}, "组织"] # 创建UIE任务流实例 # 这里我们使用预训练的UIE模型,指定schema,并传入待抽取的文本 ie = Taskflow('information_extraction', schema=schema) # 待抽取的文本 text = "李彦宏是百度公司的创始人之一。" # 执行信息抽取 results = ie(text) # 打印抽取结果 pprint(results)
- 如果显示结果如下,则为成功,否则就有问题
2、降paddle-gpu的版本(×)
- 参考:【避坑】paddlepaddle-gpu安装报错:The GPU architecture in your current machine is Pascal, which is not
- 根据上面这个大佬的描述去施行,发现不同的版本还给我不同的报错,2.3~2.5的都试了一遍,还是不行
3、同时降CUDA版本和CUDNN版本(✔)
- 虽然根据官方文档,计算能力为3.5的GPU是可以支持11.2的,但实际上计算能力为3.5的GPU还是太老了,建议稍微降点版本
- 经过一遍遍尝试,最终采用CUDA 10.2、CUDNN 7.6.5、paddle-gpu 2.4.2的版本
四、解决方案
1、卸载原CUDA(可选)
- 如果显示结果如下,则为成功,否则就有问题
- 说是成功了,但其实程序跑起来,gpu根本没用上!可以用下面这段代码测试。
- 在网上查找资料,安装了如上的对应版本,报错如下
- 总体思路:根据GPU计算能力和GPU型号,查找对应的CUDA版本,并且通过尝试降cuda版本和降paddle版本使其运行
- 最终系统环境如下: