1.出错问题:The flag 'max_step' is defined twice. First from E:\研一下\demo_tensorflow.py, Second from . Descripti
解决方法:重启Spyder编辑器
2.TensorFlow2报错:
RuntimeError: Input pipelines based on Queues are not supported when eager execution is enabled. Please use tf.data to ingest data into your model instead.
解决方法:TensorFlow2的头文件改成这样import tensorflow.compat.v1 as tf,再加一句tf.disable_eager_execution(),关闭 Eager Execution,因为在 TensorFlow 2.0 版本中,Eager Execution 模式默认打开
Eager Execution 有啥优点?
1、快速调试即刻的运行错误并通过 Python 工具进行整合
2、借助易于使用的 Python 控制流支持动态模型
3、为自定义和高阶梯度提供强大支持
4、适用于几乎所有可用的 TensorFlow 运算
3.出错问题:导入minst数据集时头文件:
from tensorflow.examples.tutorials.mnist import input_data
报错:
No module named ‘tensorflow.examples.tutorials’
解决方法:
搜索到tensorflow文件夹,缺少examples,
下载tensorflow2.X.examples.tutorials-main后里面的最后一层文件tutorials
在tensorflow文件夹创建examples空文件夹,最后将tutorials放入examples里,如下图所示:
下载链接:
https://github.com/mumushiye/tensorflow2.X.examples.tutorials/tree/main
出错问题:
解决方法:重新打开spyder
5.
虚拟机不支持显卡驱动
显卡不支持虚拟化
6.ubuntu下命令行打开anaconda界面
source ~/anaconda3/bin/activate root
anaconda-navigator
- Windows11,安装Tensorflow的GPU版本
安装anaconda3后,安装Tensorflow的GPU版本,不需要单独安装cuda和cuDNN,一条命令即可下载完成配置~
打开Anaconda Prompt(anaconda)命令行界面,输入:
Conda create -n tensorflow_gpuenv tensorflow-gpu
随后等待大概不到10分钟,即可出现下图界面:
按照提示输入conda active tensorflow_gpuenv即可激活环境,然后输入python,进入编译环境,输入下图两行测试代码即可测试成功