AttributeError: module 'tensorflow' has no attribute '__version__'解决方案

落日映苍穹つ 2022-04-11 11:55 1220阅读 0赞

最近电脑出现问题,tensorflow也总是bug连连,记录下出现的问题及解决方案。
问题:

  1. AttributeError: module 'tensorflow' has no attribute '__version__'

总之,就是tensorflow的各种属性不能使用。
单独创建了tensorflow的虚拟环境

  1. conda create -n tensorflow1 python=3.6
  2. source activate tensorflow1 #开启虚拟环境
  3. source deactivate #关闭虚拟环境

在虚拟环境中安装tensorflow的CPU和GPU版本,在原环境中均能正确使用,但在虚拟环境中总是报错
尝试方法并成功的操作如下:

  1. pip install tensorflow==1.9.0
  2. pip install tensorlflow-gpu==1.9.0
  3. pip3 install tensorflow==1.9.0
  4. pip3 install tensorflow-gpu==1.9.0

实践证明,cuda9.0、cudnn7.0与tensorflow=1.9.0更配哦,默认的最新版的1.12.0,可能会出现以下报错信息,究其原因是版本过高。

  1. ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory
  2. Failed to load the native TensorFlow runtime.

发表评论

表情:
评论列表 (有 0 条评论,1220人围观)

还没有评论,来说两句吧...

相关阅读