簡體   English   中英

Tensorflow(1.13.1)導入時出現異常:DLL加載失敗(Windows 10)

[英]Tensorflow (1.13.1) Exception when import: DLL load failed (Windows 10)

我在Windows 10機器上安裝了Python 3.7.3。 之后我下載了tensorflow模塊: pip install https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.13.1-cp37-cp37m-win_amd64.whl

在計算機上安裝了Visual Studio 2019,附加了MSVC v141(VS 2017)和MSVC v140(VS 2015)。

當我在python中運行import tensorflow as tf時,我收到以下錯誤:

Traceback (most recent call last):
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\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\foo\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: Eine DLL-Initialisierungsroutine ist fehlgeschlagen.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\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\foo\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\foo\AppData\Local\Programs\Python\Python37\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: Eine DLL-Initialisierungsroutine ist fehlgeschlagen.


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.

我從其他答案中測試了一些解決方案,但沒有解決我的問題。 有沒有人有想法?


編輯:原因是我的CPU沒有AVX支持。 現在它有效。

TensorFlow版本二進制版本1.6及更高版本預先構建了AVX指令集。

因此,在沒有這些指令集的任何CPU上,CPU或GPU版本的TF都將無法加載。
顯然,您的CPU型號不支持AVX指令集。 你仍然可以使用TensorFlow和下面給出的替代方案:

  • 嘗試使用Google Colab來使用TensorFlow。
    使用TF的最簡單方法是切換到谷歌colab。你得到預先安裝的最新穩定TF版本。 您也可以使用pip install來安裝任何其他首選TF版本。
    它具有額外的優勢,因為您可以根據任務輕松切換到不同的硬件加速器(cpu,gpu,tpu)。 您只需要一個良好的互聯網連接就可以了。
  • 嘗試通過更改CPU優化標志從源構建TF。

暫無
暫無

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

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