簡體   English   中英

驗證tensorflow正確安裝時出錯

[英]Error when verifying tensorflow installed correctly

通過本指南安裝tensorflow之后-https: //github.com/jeffheaton/t81_558_deep_learning/blob/master/t81_558_class_01_1_overview.ipynb-我收到了一個我不理解的錯誤。 我可以進入,然后激活tf並得到提示。

安裝后,我運行以下代碼來驗證安裝:

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

這是我得到的錯誤:

 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.

這些是我安裝的軟件包:

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

作為菜鳥,我嘗試過搜索該錯誤,但是遇到的每個安裝錯誤都與我的不相似。

通過Juypter在3.6內核上進行安裝。 所有軟件包均已正確安裝,但由於某種原因,驗證安裝會產生錯誤。

編輯:對不起,我忘了包括代碼!

我當前的安裝一團糟。 我安裝了兩個ide,然后安裝了python。 路徑被弄亂了,解決問題是一種皇家痛苦。

我從全新的OS安裝開始,然后以正確的方式進行安裝。

安裝tensorflow可能會很麻煩,尤其是在需要GPU支持的情況下。 幸運的是,它最近變得越來越容易,並且比該指南看起來更容易。

這一行應該安裝tensorflow-gpu,keras以及正確的cuda和cudnn工具包的正確版本:

conda install -c anaconda keras-gpu

如果您還沒有的話,我會試一試,因為它只需要幾分鍾

在筆記本電腦上安裝tf太讓人頭疼。

解決方案:AWS EC2 Ubuntu 18.04(免費版),安裝了Tensorflow,使用VS Code在本地進行遠程開發。

我學到了很多在Linux上設置tf的知識。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM