飞桨Ai(二)paddle使用CPU版本可以正常识别,切换为GPU版本时无法识别结果

慈云数据 2024-05-01 技术支持 96 0

一、问题描述:

  • 刚开始用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(可选)

                  • 在搜索栏中直接搜索 控制面板-》程序-》卸载程序,找到如下红框中下错版本的CUDA相关程序进行删除在这里插入图片描述

                    2、去官网下载需要的CUDA和CUDNN版本

                    • 注意版本对应!!!根据GPU计算能力和型号去网上查可行的版本,然后尽量选旧一点的,新的容易翻车

                      • CUDA下载地址
                      • CUDNN官网下载地址
                      • Windows系统CUDA10.2+CUDNN安装教程

                        在这里插入图片描述

                        • 注意:如果C盘空间足够,建议一路下一步,如果安装到别的盘可能会出现一些问题,害,都是教训

                          3、更换paddle-gpu的版本

                          • 从最新的能够支持你电脑的CUDA版本逐步往后试,注意CPU版本的和GPU版本的不兼容,下载前把CPU的先删了
                            • 官网下载安装教程
                            • 在左上角更换下载安装教程版本

                              4、测试结果

                              • 测试结果显示如下,说明安装成功

                                参考:

                                • 【避坑】paddlepaddle-gpu安装报错:The GPU architecture in your current machine is Pascal, which is not
                                • CUDA版本降级操作(记录
                                • 卸载错误的cuda版本+安装正确的cuda+cudnn+pytorch
                                • Windows系统CUDA10.2+CUDNN安装教程
微信扫一扫加客服

微信扫一扫加客服

点击启动AI问答
Draggable Icon