【避坑】paddlepaddle-gpu安装报错:The GPU architecture in your current machine is Pascal, which is not

这篇具有很好参考价值的文章主要介绍了【避坑】paddlepaddle-gpu安装报错:The GPU architecture in your current machine is Pascal, which is not。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

版本与报错信息

完整的系统、显卡等环境如下:

  • 系统:win10
  • 显卡:GeForce GTX 1060 6GB
  • python 3.7.16
  • cuda:cuda 11.2.0
  • cudnn:cudnn 8.2.1
  • paddlepaddle:pip安装 版本:gpu==2.5.1.post112

安装指令为:

python -m pip install paddlepaddle-gpu==2.5.1.post112 -f https://www.paddlepaddle.org.cn/whl/windows/mkl/avx/stable.html

安装成功后,测试结果如下:

(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: 6.1, Driver API Version: 12.2, 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.

注意这个警告信息:

The GPU architecture in your current machine is Pascal, which is not compatible with Paddle installation with arch: 70 75 80 86

我以为只是一个警告信息,直接忽略了。但是当我具体写代码时,我发现了个很严重的问题!!!

(w) D:\Downloads>python
Python 3.7.16 (default, Jan 17 2023, 16:06:28) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import paddle
>>> paddle.ones([3,3])
W0831 10:13:48.890246 16284 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:13:48.891247 16284 gpu_resources.cc:119] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 12.2, Runtime API Version: 11.2
W0831 10:13:48.901255 16284 gpu_resources.cc:149] device: 0, cuDNN Version: 8.2.
Tensor(shape=[3, 3], dtype=float32, place=Place(gpu:0), stop_gradient=True,
       [[0., 0., 0.],
        [0., 0., 0.],
        [0., 0., 0.]])
>>> paddle.ones([3,3]) *3
Tensor(shape=[3, 3], dtype=float32, place=Place(gpu:0), stop_gradient=True,
       [[0., 0., 0.],
        [0., 0., 0.],
        [0., 0., 0.]])

paddle.ones([3,3])返回的结果是 0!!!!直接震惊,后续测试其他的代码也是如此,这说明确实是安装失败了!
后续我安装了 CPU 版本的 paddle,发现是正常的,说明确实是 GPU 版本没安装成功!这里我对比了 torch、tensorflow,这两个框架的 GPU 都能用!!所以 paddle 实锤了…

2.4.1.post112 版本安装(×)

继续尝试,我试着安装版本低一些的 paddle,先尝试的是 2.4.1.post112。
我在(https://www.paddlepaddle.org.cn/whl/windows/mkl/avx/stable.html)网页下载了 2.4.1.post112 版本的 whl 文件,然后安装:

D:\Downloads>pip install paddlepaddle_gpu-2.4.1.post112-cp37-cp37m-win_amd64.whl -i https://pypi.tuna.tsinghua.edu.cn/simple/

安装完成后,测试结果如下:

(w) D:\Downloads>python -c "import paddle; paddle.utils.run_check()"
Running verify PaddlePaddle program ...
W0831 10:04:52.412166 12988 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 12.2, Runtime API Version: 11.2
W0831 10:04:52.426165 12988 gpu_resources.cc:91] device: 0, cuDNN Version: 8.2.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\anaconda3\envs\w\lib\site-packages\paddle\utils\install_check.py", line 270, in run_check
    _run_dygraph_single(use_cuda, use_xpu, use_npu)
  File "D:\anaconda3\envs\w\lib\site-packages\paddle\utils\install_check.py", line 136, in _run_dygraph_single
    linear_out = linear(input_tensor)
  File "D:\anaconda3\envs\w\lib\site-packages\paddle\fluid\dygraph\layers.py", line 948, in __call__
    return self.forward(*inputs, **kwargs)
  File "D:\anaconda3\envs\w\lib\site-packages\paddle\nn\layer\common.py", line 176, in forward
    x=input, weight=self.weight, bias=self.bias, name=self.name
  File "D:\anaconda3\envs\w\lib\site-packages\paddle\nn\functional\common.py", line 1882, in linear
    return _C_ops.linear(x, weight, bias)
OSError: Invalid enum backend type `63`.
  [..\paddle/phi/common/backend.h:140]

报了新的错误:OSError: Invalid enum backend type 63.

develop 版本安装(×)

通过在 github 的 issue (https://github.com/PaddlePaddle/Paddle/issues/49964)上发现了同样的错误,查到有大佬给出解决方法:
【避坑】paddlepaddle-gpu安装报错:The GPU architecture in your current machine is Pascal, which is not,Issue,paddlepaddle,python,paddlepaddle,CUDN,GPU
安装指令依他的,如下

python -m pip install paddlepaddle-gpu==0.0.0.post112 -f https://www.paddlepaddle.org.cn/whl/windows/gpu/develop.html

安装成功后测试结果如下,依然报错(这是最开始的错误):

(w) D:\Downloads>python -c "import paddle; paddle.utils.run_check()"
Running verify PaddlePaddle program ...
I0831 10:13:26.942690 11972 program_interpreter.cc:175] New Executor is Running.
W0831 10:13:26.943701 11972 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:13:26.943701 11972 gpu_resources.cc:119] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 12.2, Runtime API Version: 11.2
W0831 10:13:26.956668 11972 gpu_resources.cc:149] device: 0, cuDNN Version: 8.2.
I0831 10:13:27.715677 11972 interpreter_util.cc:602] Standalone Executor is Used.
PaddlePaddle works well on 1 GPU.
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.

ERROR:The GPU architecture in your current machine is Pascal, which is not compatible with Paddle installation with arch: 70 75 80 86

可以发现,GPU 版本的 paddle,ones 函数的结果都是 0,很明显安装失败!

(w) D:\Downloads>python
Python 3.7.16 (default, Jan 17 2023, 16:06:28) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import paddle
>>> paddle.ones([3,3])
W0831 10:13:48.890246 16284 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:13:48.891247 16284 gpu_resources.cc:119] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 12.2, Runtime API Version: 11.2
W0831 10:13:48.901255 16284 gpu_resources.cc:149] device: 0, cuDNN Version: 8.2.
Tensor(shape=[3, 3], dtype=float32, place=Place(gpu:0), stop_gradient=True,
       [[0., 0., 0.],
        [0., 0., 0.],
        [0., 0., 0.]])
>>> paddle.ones([3,3]) *3
Tensor(shape=[3, 3], dtype=float32, place=Place(gpu:0), stop_gradient=True,
       [[0., 0., 0.],
        [0., 0., 0.],
        [0., 0., 0.]])

2.3.2.post112 版本安装

继续尝试之前的版本,在(https://www.paddlepaddle.org.cn/whl/windows/mkl/avx/stable.html)网页下载了 2.3.2.post112 版本的 whl 文件,然后安装:
安装指令如下:

pip install paddlepaddle_gpu-2.3.2.post112-cp37-cp37m-win_amd64.whl

环境中所有包的版本如下:

(w) D:\Downloads>conda list
# packages in environment at D:\anaconda3\envs\w:
#
# Name                    Version                   Build  Channel
anyio                     3.7.1                    pypi_0    pypi
astor                     0.8.1                    pypi_0    pypi
ca-certificates           2023.05.30           haa95532_0    defaults
certifi                   2022.12.7        py37haa95532_0    defaults
charset-normalizer        3.2.0                    pypi_0    pypi
decorator                 5.1.1                    pypi_0    pypi
exceptiongroup            1.1.3                    pypi_0    pypi
h11                       0.14.0                   pypi_0    pypi
httpcore                  0.17.3                   pypi_0    pypi
httpx                     0.24.1                   pypi_0    pypi
idna                      3.4                      pypi_0    pypi
numpy                     1.21.6                   pypi_0    pypi
openssl                   1.1.1v               h2bbff1b_0    defaults
opt-einsum                3.3.0                    pypi_0    pypi
paddle-bfloat             0.1.7                    pypi_0    pypi
paddlepaddle-gpu          2.3.2.post112            pypi_0    pypi 
pillow                    9.5.0                    pypi_0    pypi
pip                       22.3.1           py37haa95532_0    defaults
protobuf                  3.20.0                   pypi_0    pypi
python                    3.7.16               h6244533_0    defaults
python-version            0.0.2                    pypi_0    pypi
requests                  2.31.0                   pypi_0    pypi
setuptools                65.6.3           py37haa95532_0    defaults
six                       1.16.0                   pypi_0    pypi
sniffio                   1.3.0                    pypi_0    pypi
sqlite                    3.41.2               h2bbff1b_0    defaults
typing-extensions         4.7.1                    pypi_0    pypi
urllib3                   2.0.4                    pypi_0    pypi
vc                        14.2                 h21ff451_1    defaults
vs2015_runtime            14.27.29016          h5e58377_2    defaults
wheel                     0.38.4           py37haa95532_0    defaults
wincertstore              0.2              py37haa95532_2    defaults

测试结果如下:

(w) D:\Downloads>python -c "import paddle; paddle.utils.run_check()"
Running verify PaddlePaddle program ...
W0831 10:32:31.453032 12400 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 12.2, Runtime API Version: 11.2
W0831 10:32:31.468046 12400 gpu_resources.cc:91] device: 0, cuDNN Version: 8.2.
PaddlePaddle works well on 1 GPU.
PaddlePaddle works well on 1 GPUs.
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.

(w) D:\Downloads>python -c "import paddle; conv = paddle.nn.Conv1D(3, 1, 1); ts = paddle.to_tensor([[[1.1], [4.5], [1.4]]], dtype='float32'); print(conv(ts))
W0831 10:32:42.271850 13316 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 12.2, Runtime API Version: 11.2
W0831 10:32:42.285848 13316 gpu_resources.cc:91] device: 0, cuDNN Version: 8.2.
Tensor(shape=[1, 1, 1], dtype=float32, place=Place(gpu:0), stop_gradient=False,
       [[[1.36227489]]])

成功!还是不放心,再写了个脚本测试了一下:

import paddle
from paddle.vision.transforms import Normalize

transform = Normalize(mean=[127.5], std=[127.5], data_format='CHW')
# 下载数据集并初始化 DataSet
train_dataset = paddle.vision.datasets.MNIST(mode='train', transform=transform)
test_dataset = paddle.vision.datasets.MNIST(mode='test', transform=transform)

# 模型组网并初始化网络
lenet = paddle.vision.models.LeNet(num_classes=10)
model = paddle.Model(lenet)

# 模型训练的配置准备,准备损失函数,优化器和评价指标
model.prepare(paddle.optimizer.Adam(parameters=model.parameters()),
              paddle.nn.CrossEntropyLoss(),
              paddle.metric.Accuracy())

# 模型训练
model.fit(train_dataset, epochs=5, batch_size=512, verbose=1)
# 模型评估
model.evaluate(test_dataset, batch_size=128, verbose=1)

运行成功,放心了!!!

D:\anaconda3\envs\w\python.exe E:\Code\paddle_test\p.py 
W0831 10:51:13.105628 15956 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 6.1, Driver API Version: 12.2, Runtime API Version: 11.2
W0831 10:51:13.128626 15956 gpu_resources.cc:91] device: 0, cuDNN Version: 8.2.
The loss value printed in the log is the current step, and the metric is the average value of previous steps.
Epoch 1/5
D:\anaconda3\envs\w\lib\site-packages\paddle\fluid\dygraph\amp\auto_cast.py:303: UserWarning: For float16, amp only support NVIDIA GPU with Compute Capability 7.0 or higher, current GPU is: NVIDIA GeForce GTX 1060 6GB, with Compute Capability: 6.1.
  % (paddle.device.cuda.get_device_name(), prop[0], prop[1]))
step 118/118 [==============================] - loss: 0.1857 - acc: 0.8243 - 90ms/step          
Epoch 2/5
step 118/118 [==============================] - loss: 0.1530 - acc: 0.9593 - 76ms/step          
Epoch 3/5
step 118/118 [==============================] - loss: 0.1555 - acc: 0.9718 - 74ms/step          
Epoch 4/5
step 118/118 [==============================] - loss: 0.0283 - acc: 0.9774 - 73ms/step          
Epoch 5/5
step 118/118 [==============================] - loss: 0.0505 - acc: 0.9806 - 73ms/step          
Eval begin...
step 79/79 [==============================] - loss: 0.0014 - acc: 0.9770 - 24ms/step          
Eval samples: 10000

Process finished with exit code 0

总结 paddlepaddle-gpu 安装方法

paddlepaddle-gpu 安装步骤

  1. 安装 Anaconda,这里就不多说了,啥版本都可以
  2. 安装 CUDA 和 CUDNN。(划重点这里必须参照 paddle 官网给的 cuda 和 cudnn 版本来安装!!!

paddlepaddle官网(https://www.paddlepaddle.org.cn/install/quick?docurl=/documentation/docs/zh/install/pip/windows-pip.html)对cuda和cudnn版本的要求描述如下:

  • 如果您的计算机没有 NVIDIA® GPU,请安装CPU 版的 PaddlePaddle
  • 如果您的计算机有 NVIDIA® GPU,请确保满足以下条件并且安装 GPU 版 PaddlePaddle
    • CUDA 工具包 10.2 配合 cuDNN v7.6.5,如需使用 PaddleTensorRT 推理,需配合 TensorRT7.0.0.11
    • CUDA 工具包 11.2 配合 cuDNN v8.2.1,如需使用 PaddleTensorRT 推理,需配合 TensorRT8.2.4.2
    • CUDA 工具包 11.6 配合 cuDNN v8.4.0,如需使用 PaddleTensorRT 推理,需配合 TensorRT8.4.0.6
    • CUDA 工具包 11.7 配合 cuDNN v8.4.1,如需使用 PaddleTensorRT 推理,需配合 TensorRT8.4.2.4
    • CUDA 工具包 11.8 配合 cuDNN v8.6.0,如需使用 PaddleTensorRT 推理,需配合 TensorRT8.5.1.7
    • CUDA 工具包 12.0 配合 cuDNN v8.9.1, 如需使用 PaddleTensorRT 推理,需配合 TensorRT8.6.1.6
    • GPU 运算能力超过 3.5 的硬件设备
    • 注:目前官方发布的 windows 安装包仅包含 CUDA 10.2/11.2/11.6/11.7/11.8/12.0,如需使用其他 cuda 版本,请通过源码自行编译。您可参考 NVIDIA 官方文档了解 CUDA、CUDNN 和 TensorRT 的安装流程和配置方法,请见CUDA,cuDNN,TensorRT

PS: 按照官网要求我安装的版本为:CUDA11.2cuDNN8.2.1。此外,CUDA 和 CUDNN 的安装教程可以看这位大佬写的博客:https://blog.csdn.net/Vertira/article/details/125060383,写的很详细。

  1. 安装 paddle ,这里尽量选较老一点的版本,比如我最终是选择 2.3.2.post112 版本才安装成功的。安装方法参考官网,不建议安装最新版本的 paddle。建议参考网页(https://www.paddlepaddle.org.cn/whl/windows/mkl/avx/stable.html)下载 whl 文件,离线安装,这样可供选择的版本更多些。

写在最后

  1. CUDA 与 CUDNN 版本一定要对应,paddle 对驱动版本限制很死!!!(无力吐槽)
  2. paddle-gpu 版本要多尝试,建议老一点的版本(CPU 版本的 paddle 不影响)
  3. 不确定我的版本是否也适合你们,但是只能多尝试版本,感觉这两个错就是paddle版本的问题,多尝试吧。诶…

就这样,希望本文对你有所帮助,感谢阅读。文章来源地址https://www.toymoban.com/news/detail-713850.html

到了这里,关于【避坑】paddlepaddle-gpu安装报错:The GPU architecture in your current machine is Pascal, which is not的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包