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

持续更新中......

相关推荐
金銀銅鐵11 分钟前
费马小定理
python·数学·算法
code_pgf17 分钟前
AI-Agent记忆机制分析
大数据·人工智能
阿拉斯攀登2 小时前
安全与可控性:输出校验、权限控制
人工智能·chatgpt·agent·memory·claude·知识库·向量数据库
冬奇Lab2 小时前
每日一个开源项目(第152篇):SAG - 用 SQL JOIN 代替 PageRank 做多跳 RAG 检索
人工智能·开源
冬奇Lab2 小时前
Workflow 系列(09):主流框架对比——Prompt-based、LangGraph、Temporal、n8n 如何选
人工智能·工作流引擎
程序员老猫2 小时前
vide coding 个人产品,那就从博客开始吧
人工智能·程序员·全栈
geo搜搜果数据3 小时前
实测5大AI平台品牌排名:复现GEO监测流程
人工智能·langchain·搜搜果
minge00014 小时前
【世界杯中的AI】(2026-07-05)当足球遇见AI:7月5日世界杯的“人机共舞”与冷门之夜
人工智能·科技·世界杯