[英]“Failed to load native TensorFlow runtime.”
因此,我創建了一個程序來從 TensorFlow 加載數據集,但我收到一個錯誤,我不知道這意味着什么。
我的代碼是:
import tensorflow as tf
from tensorflow import keras
import numpy as np
import matplotlib.pyplot as plt
data = keras.dataset_fashion_mnist
(train_images, train_labels), (test_images, test_labels) = data.data_load()
print(train_labels[1])
我應該得到一個數字 output 而不是錯誤。
錯誤是:
Traceback (most recent call last):
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "helloworld.py", line 1, in <module>
import tensorflow as tf
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 98, in <module>
from tensorflow_core import *
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
module = self._load()
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\Khosr\AppData\Local\Programs\Python\Python37\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.
我不知道該怎么做才能解決這個問題以及嘗試什么。 我確保我安裝了 tensorflow 並且我安裝了。 我認為這與圖書館 iteff 有關。
您的錯誤似乎與此類似: https://github.com/tensorflow/tensorflow/issues/22794
一般的解決方案是使用特定版本的 CUDA 和特定版本的 tensorflow,例如
tensorflow-gpu==1.14.0
python 3.6.8
CUDA v10.0
cudnn 7.4.1.5
你能提供你的圖書館版本嗎? 我建議使用conda
在 Windows 上安裝 tensorflow 因為它有助於安裝正確的版本而不是自己設置。
編輯
請嘗試這些步驟(取自 Tensorflow 的文檔: https://www.tensorflow.org/install/pip )
Go 到 Visual Studio 下載: https://visualstudio.microsoft.com/vs/older-downloads/
Select 可再發行組件和構建工具
下載並安裝 Microsoft Visual C++ 2015 Redistributable Update 3
在 windows 上啟用長路徑: https://superuser.com/questions/1119883/windows-10-enable-ntfs-long-paths-policy-option-missing
最后,請確保您的 CPU 支持 AVX 指令: https://en.wikipedia.org/wiki/Advanced_Vector_Extensions#CPUs_with_AVX
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.