关于使用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

持续更新中......

相关推荐
爱喝奶茶的企鹅15 分钟前
Ethan独立开发产品日报 | 2025-04-15
人工智能·程序员·产品
管二狗赶快去工作!19 分钟前
体系结构论文(七十一):Quantifying the Impact of Data Encoding on DNN Fault Tolerance
人工智能·神经网络·dnn
光亮的程序猿19 分钟前
confluent-kafka入门教程
python·kafka
夜松云21 分钟前
机器学习中的距离度量与优化方法:从曼哈顿距离到梯度下降
人工智能·机器学习·损失函数·梯度下降·前向传播·数学基础·交叉验证
三天不学习25 分钟前
Python快速入门指南:从零开始掌握Python编程
开发语言·python
大数据魔法师41 分钟前
豆瓣图书数据采集与可视化分析
python·数据分析·数据可视化
批量小王子41 分钟前
第1个小脚本:英语单语按字母个数进行升序排序
python
AmazingKO1 小时前
制作像素风《饥荒》类游戏的整体蓝图和流程
人工智能·python·游戏·docker·visual studio code·竹相左边
CV-杨帆1 小时前
trl的安装与单GPU多GPU测试
人工智能
_一条咸鱼_1 小时前
AI 大模型的 Prompt Engineering 原理
人工智能·深度学习·面试