简体   繁体   English

验证tensorflow正确安装时出错

[英]Error when verifying tensorflow installed correctly

After installing tensorflow via this guide - https://github.com/jeffheaton/t81_558_deep_learning/blob/master/t81_558_class_01_1_overview.ipynb - I get an error that I do not understand. 通过本指南安装tensorflow之后-https: //github.com/jeffheaton/t81_558_deep_learning/blob/master/t81_558_class_01_1_overview.ipynb-我收到了一个我不理解的错误。 I can get into and then I active tf and get a prompt. 我可以进入,然后激活tf并得到提示。

After install, I run the following code to verify installation: 安装后,我运行以下代码来验证安装:

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")

This is the error I get: 这是我得到的错误:

 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.

These are the packages I installed: 这些是我安装的软件包:

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

As a noob, I have tried to google the error, but every installation that I have come across with errors is not similar to mine. 作为菜鸟,我尝试过搜索该错误,但是遇到的每个安装错误都与我的不相似。

The installation is via Juypter on a 3.6 kernel. 通过Juypter在3.6内核上进行安装。 All the packages installed correctly, but for some reason, verifying the install produces an error. 所有软件包均已正确安装,但由于某种原因,验证安装会产生错误。

edit: Sorry, I forgot to include the code! 编辑:对不起,我忘了包括代码!

My current installation was a mess. 我当前的安装一团糟。 I installed a couple of ide's, then python. 我安装了两个ide,然后安装了python。 The path was messed up, and it was a royal pain to troubleshoot. 路径被弄乱了,解决问题是一种皇家痛苦。

I started with a fresh os install and I am doing it the right way. 我从全新的OS安装开始,然后以正确的方式进行安装。

Installing tensorflow can be a pain, especially if you need GPU support. 安装tensorflow可能会很麻烦,尤其是在需要GPU支持的情况下。 Luckily it's gotten easier recently, and it is much easier than that guide makes it seem. 幸运的是,它最近变得越来越容易,并且比该指南看起来更容易。

This one line should install the correct version of tensorflow-gpu, keras, and the appropriate cuda and cudnn toolkits: 这一行应该安装tensorflow-gpu,keras以及正确的cuda和cudnn工具包的正确版本:

conda install -c anaconda keras-gpu

I would just give it a go if you haven't already as it should just take a few minutes 如果您还没有的话,我会试一试,因为它只需要几分钟

Too much of a headache getting tf installed on my laptop. 在笔记本电脑上安装tf太让人头疼。

Solution: AWS EC2 Ubuntu 18.04 (free tier), installed Tensorflow, doing remote development with VS Code locally. 解决方案:AWS EC2 Ubuntu 18.04(免费版),安装了Tensorflow,使用VS Code在本地进行远程开发。

I learned a ton setting up tf on Linux. 我学到了很多在Linux上设置tf的知识。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM