按照官方文档安装paddlepaddle 2.3.0后,进行环境验证时,总是提示如下错误:
TypeError: Descriptors cannot not 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.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
这说明我们使用的protobuf库的版本高了,可以卸载已经安装过的protobuf 版本,再安装3.20.x以下的版本,我们可以使用3.19.0版本即可,命令如下:
1、卸载protobuf 已经安装的版本
pip uninstall protobuf
Found existing installation: protobuf 4.21.1
Uninstalling protobuf-4.21.1:
Would remove:
......
Proceed (Y/n)? y
Successfully uninstalled protobuf-4.21.1
2、安装3.19.0版本
pip install protobuf==3.19.0
Installing collected packages: protobuf
Successfully installed protobuf-3.19.0
好了,再进行paddle环境的验证吧:文章来源:https://www.toymoban.com/news/detail-656138.html
>>> import paddle
>>> paddle.utils.run_check()
Running verify PaddlePaddle program ...
PaddlePaddle works well on 1 CPU.
W0601 23:27:12.940966 28720 fuse_all_reduce_op_pass.cc:76] Find all_reduce operators: 2. To make the speed faster, some all_reduce ops are fused during training, after fusion, the number of all_reduce ops is 2.
PaddlePaddle works well on 2 CPUs.
PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now.文章来源地址https://www.toymoban.com/news/detail-656138.html
到了这里,关于paddlepaddle安装问题protobuf package to 3.20.x or lower.的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!