关于使用tensorflow_gpu遇到的问题

前言

我使用的是tensorflow_gpu2.6与python3.9,还要下载cuda与cudnn。

numpy版本问题

AttributeError: module 'numpy' has no attribute 'object'. np.object was a deprecated alias for the builtin object. To avoid this error in existing code, use object by itself. Doing this will not modify any behavior and is safe.

解决方法:

下载高一些版本或低一些的版本,tensorfolw2.6适配的时1.20以上

pip install numpy==1.21

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.
  2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

解决方法:

保持protobuf的版本在3.19到3.20之间

pip install protobuf==3.19

keras版本问题

from tensorflow.compat.v2.experimental import dtensor as dtensor_api ImportError: cannot import name 'dtensor' from 'tensorflow.compat.v2.experimental'

解决方法:

keras的版本要与tensorflow最好保持一致

pip install keras==2.6

持续更新中......

相关推荐
开源技术19 分钟前
深入了解Turso,这个“用Rust重写的SQLite”
人工智能·python
初恋叫萱萱20 分钟前
构建高性能生成式AI应用:基于Rust Axum与蓝耘DeepSeek-V3.2大模型服务的全栈开发实战
开发语言·人工智能·rust
u0109272711 小时前
RESTful API设计最佳实践(Python版)
jvm·数据库·python
我材不敲代码5 小时前
Python实现打包贪吃蛇游戏
开发语言·python·游戏
0思必得07 小时前
[Web自动化] Selenium处理动态网页
前端·爬虫·python·selenium·自动化
水如烟7 小时前
孤能子视角:“组织行为学–组织文化“
人工智能
韩立学长7 小时前
【开题答辩实录分享】以《基于Python的大学超市仓储信息管理系统的设计与实现》为例进行选题答辩实录分享
开发语言·python
大山同学8 小时前
图片补全-Context Encoder
人工智能·机器学习·计算机视觉
qq_192779878 小时前
高级爬虫技巧:处理JavaScript渲染(Selenium)
jvm·数据库·python
薛定谔的猫19828 小时前
十七、用 GPT2 中文对联模型实现经典上联自动对下联:
人工智能·深度学习·gpt2·大模型 训练 调优