首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >验证tensorflow安装是否正确时出错

问验证tensorflow安装是否正确时出错
EN

Stack Overflow用户
提问于 2019-09-04 11:08:12
回答 3查看 343关注 0票数 1

通过本指南- https://github.com/jeffheaton/t81_558_deep_learning/blob/master/t81_558_class_01_1_overview.ipynb -安装tensorflow后,我得到一个我不理解的错误。我可以进入,然后激活tf并得到提示。

安装完成后,我运行以下代码来验证安装:

代码语言:javascript
复制
import sys

    import tensorflow.keras
    import pandas as pd
    import sklearn as sk
    import tensorflow as tf

    print(f"Tensor Flow Version: {tf.__version__}")
    print(f"Keras Version: {tensorflow.keras.__version__}")
    print()
    print(f"Python {sys.version}")
    print(f"Pandas {pd.__version__}")
    print(f"Scikit-Learn {sk.__version__}")
    print("GPU is", "available" if tf.test.is_gpu_available() else "NOT AVAILABLE")

这是我得到的错误:

代码语言:javascript
复制
 ImportError                               Traceback (most recent call last)
        ~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
             57 
        ---> 58   from tensorflow.python.pywrap_tensorflow_internal import *
             59   from tensorflow.python.pywrap_tensorflow_internal import __version__

        ~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in <module>
             27             return _mod
        ---> 28     _pywrap_tensorflow_internal = swig_import_helper()
             29     del swig_import_helper

        ~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()
             23             try:
        ---> 24                 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
             25             finally:

        ~\Anaconda3\lib\imp.py in load_module(name, file, filename, details)
            241         else:
        --> 242             return load_dynamic(name, filename, file)
            243     elif type_ == PKG_DIRECTORY:

        ~\Anaconda3\lib\imp.py in load_dynamic(name, path, file)
            341             name=name, loader=loader, origin=path)
        --> 342         return _load(spec)
            343 

        ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.

        During handling of the above exception, another exception occurred:

        ImportError                               Traceback (most recent call last)
        <ipython-input-2-0b3eb45acbe5> in <module>
              1 import sys
              2 
        ----> 3 import tensorflow.keras
              4 import pandas as pd
              5 import sklearn as sk

        ~\Anaconda3\lib\site-packages\tensorflow\__init__.py in <module>
             38 import sys as _sys
             39 
        ---> 40 from tensorflow.python.tools import module_util as _module_util
             41 
             42 from tensorflow._api.v2 import audio

        ~\Anaconda3\lib\site-packages\tensorflow\python\__init__.py in <module>
             47 import numpy as np
             48 
        ---> 49 from tensorflow.python import pywrap_tensorflow
             50 
             51 # Protocol buffers

        ~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>
             72 for some common reasons and solutions.  Include the entire stack trace
             73 above this error message when asking for help.""" % traceback.format_exc()
        ---> 74   raise ImportError(msg)
             75 
             76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long

        ImportError: Traceback (most recent call last):
          File "C:\Users\madew\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
            from tensorflow.python.pywrap_tensorflow_internal import *
          File "C:\Users\madew\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
            _pywrap_tensorflow_internal = swig_import_helper()
          File "C:\Users\madew\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
            _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
          File "C:\Users\madew\Anaconda3\lib\imp.py", line 242, in load_module
            return load_dynamic(name, filename, file)
          File "C:\Users\madew\Anaconda3\lib\imp.py", line 342, in load_dynamic
            return _load(spec)
        ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.


        Failed to load the native TensorFlow runtime.

    See https://www.tensorflow.org/install/errors

    for some common reasons and solutions.  Include the entire stack trace
    above this error message when asking for help.

下面是我安装的包:

代码语言:javascript
复制
pip install --exists-action i --upgrade sklearn
pip install --exists-action i --upgrade pandas
pip install --exists-action i --upgrade pandas-datareader
pip install --exists-action i --upgrade matplotlib
pip install --exists-action i --upgrade pillow
pip install --exists-action i --upgrade tqdm
pip install --exists-action i --upgrade requests
pip install --exists-action i --upgrade h5py
pip install --exists-action i --upgrade pyyaml
pip install --exists-action i --upgrade tensorflow_hub
pip install --exists-action i --upgrade bayesian-optimization
pip install --exists-action i --upgrade spacy
pip install --exists-action i --upgrade gensim
pip install --exists-action i --upgrade flask
pip install --exists-action i --upgrade boto3
pip install --exists-action i --upgrade gym
pip install --exists-action i --upgrade tensorflow==2.0.0-beta1
pip install --exists-action i --upgrade keras-rl2 --user

作为一个新手,我尝试用google搜索这个错误,但我遇到的每个安装错误都与我的不同。

在3.6内核上通过Juypter进行安装。所有软件包都已正确安装,但由于某些原因,验证安装会产生错误。

编辑:对不起,我忘了加代码了!

EN

回答 3

Stack Overflow用户

发布于 2019-09-26 15:32:48

在我的笔记本电脑上安装tf太麻烦了。

解决方案:亚马逊网络服务EC2 Ubuntu18.04(自由层),安装Tensorflow,在本地使用VS代码进行远程开发。

我学到了很多在Linux上设置tf的知识。

票数 1
EN

Stack Overflow用户

发布于 2019-09-08 09:19:00

我现在的安装是一团糟。我安装了几个ide,然后是python。这条路乱七八糟,故障排除是一件非常痛苦的事情。

我从一个全新的os安装开始,并且我正在以正确的方式进行安装。

票数 0
EN

Stack Overflow用户

发布于 2019-09-11 21:12:30

安装tensorflow可能会很痛苦,特别是在需要GPU支持的情况下。幸运的是,最近它变得更容易了,而且它比指南所说的要容易得多。

这一行应该安装正确版本的tensorflow-gpu、keras以及适当的cuda和cudnn工具包:

代码语言:javascript
复制
conda install -c anaconda keras-gpu

如果你还没有,我会试一试,因为它应该只需要几分钟的时间

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57780983

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档