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

持续更新中......

相关推荐
Cosolar几秒前
Harness:大模型Agent的“操作系统”,2026年AI工程化的核心革命
人工智能·面试·llm
67X3 分钟前
【论文研读】Deep learning improves prediction of drug–drug anddrug–food interactions
人工智能·深度学习
jinanwuhuaguo42 分钟前
人工智能的进化阶梯:AI、ANI、AGI与ASI的核心区别与深度剖析
开发语言·人工智能·agi·openclaw
程序员Shawn1 小时前
【深度学习 | 第三篇】-卷积神经网络
人工智能·深度学习·cnn
vkv55881 小时前
我做了一个自媒体多平台发布工具:支持 AI 生成、账号管理、自动登录与批量发布
人工智能·媒体
Lenyiin1 小时前
《Python 修炼全景指南:一》从环境搭建到第一个程序
开发语言·python
IT_陈寒2 小时前
React hooks依赖数组这个坑差点把我埋了
前端·人工智能·后端
涛声依旧393162 小时前
Python项目实战:学生信息管理系统
开发语言·python·数据挖掘
我科绝伦(Huanhuan Zhou)2 小时前
分享一个服务故障自愈系统
运维·人工智能·自动化
做个文艺程序员2 小时前
Spring AI + Qwen3.5 实现多步 Agent:从工具调用到自主任务拆解的踩坑全记录
java·人工智能·spring