记一次tensorflow安装
Tensorflow 2.5.0 + Cuda 11.2 + cudnn 8.1 (windows)
pip install --ignore-installed --upgrade tensorflow-gpu
报错Could not install packages due to an OSError
Consider using the `--user` option or check the permissions.

pip install --user --ignore-installed --upgrade tensorflow-gpu


pip install --user pyqt5==5.12.0

pip install --user pyqtwebengine==5.12.0

pip install --user pyqt5==5.12.3
pip install --user pyqtwebengine==5.12.1
pip install --user daal==2021.4.0
pip install --user ruamel-yaml
再仔细看下后三句是版本不兼容

pip uninstall +对应的clyent,nbformat
再pip install clyent==1.2.1
pip install nbformat==5.4.0
就可以了
【我好累,但是jupyter notebook终于可以用了吗】
base环境下输入jupyter notebook
ImportError: cannot import name ‘soft_unicode‘ from ‘markupsafe‘
输入pip show markupsafe
发现已安装
“降版本重装“python -m pip install markupsafe==2.0.1
安装成功但是

不管怎样,再输入jupyter notebook
可以开了!

输入没有报错……万幸

啊抄老师ppt上代码后才发现,那是python2的语法,于是加括号

咋还错,哦咱先定义一下

咋还错,搜一下于是错误
错误AttributeError: module 'tensorflow' has no attribute 'Session'
不用担心,你的tensorflow已经安装成功,原因是你安装的tensorflow是2.0以上版本
修改为
sess = tf.compat.v1.Session()

痛苦……咋还错,继续搜
无法执行sess.run()的原因是tensorflow版本不同导致的,tensorflow版本2.0无法兼容版本1.0.
解决办法:
tf.compat.v1.disable_eager_execution()
最后的神级代码
import tensorflow as tf tf.compat.v1.disable_eager_execution() hello = tf.constant('hello,tensorflow') sess= tf.compat.v1.Session() print(sess.run(hello))

呜呜呜孩子谢谢你!!!

浙公网安备 33010602011771号