Installing Tensorflow 2 gets a dll failed to load in pywrap_tensorflow.py

放肆的年华 提交于 2020-07-04 00:20:20

问题


I have had problems here, here and there installing tensorflow 2 over the last year or so. So I am trying miniconda.

I have an amd radeon hd 6670 and an amd radeon hd 6450.

I just downloaded miniconda and made an environment and did a pip install --upgrade tensorflow in an miniconda prompt on windows 8.1 and got tensorflow 2.2.

When I try to import tensorflow I get the stack trace below.

I did download visual studio to get the latest redistributebles (I think).

seems like this occurs near this line: from tensorflow.python.pywrap_tensorflow_internal import *

Edit 1: I used this yaml file for python 3.6 (the other was 3.7), but it produced the same error.

Edit 2: I upgraded to conda 4.8.3 and python 3.7 (in the yaml file) and got the same error. This is the line in pywrap internal that shows the problem:

line 28: _pywrap_tensorflow_internal = swig_import_helper()

In swig helper:

fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])

Looks like it's trying to find itself? Anyone have a clue?

Edit 3: This looks like the same problem, but it's dated. This seems to be the same problem that got fixed by using 2015 c++ redistributebles. I do have 2015 x64 and 2015-2019 x86 installed.

Edit 4: Trying 3.5 gets a subprocess error (please see below).

Edit 5: Trying 3.7 with: conda install 'tensorflow==mkl' (and no yaml file) did work (3.6 did not work). Unfortunately it still takes 10 seconds to import tf2!

Searching for: -gpu swig_import_helper "Failed to load the native TensorFlow runtime" results in about 3.6k hits, so this is an ongoing problem.

Edit 5: installing keras breaks with this bug. trying the fix gets: AttributeError: module 'tensorflow' has no attribute 'compat'. so tendorflow does not work anymore.

Does anyone have a repeatable process that is stable? I am trying to work with the code from Deep Learning with Python, Second Edition.

Edit 6: unstalling minconda took about an hour. installing a new anaconda worked fine. using their yaml file gets a nice install. but importing tensorflow gets a dll load error.

Edit 7. trying python 3.8 and using a virtual environment is much faster. i can install tensorflow. but using it gets:

ImportError: Could not find the DLL(s) 'msvcp140_1.dll'. TensorFlow requires that these DLLs be installed in a directory that is named in your %PATH% environmen
t variable. 

I do have the redistributables installed and windows/system32 is on the path:

(handson-ml2) d:\ray\dev\mlbooks\handson-ml2>echo %PATH%
d:\pyvenvs\handson-ml2\Scripts;C:\Program Files (x86)\Common Files\Oracle\Java\j
avapath;c:\Rtools\bin;c:\Rtools\mingw_32\bin;C:\ProgramData\Oracle\Java\javapath
;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x8
6;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\Wi
ndowsPowerShell\v1.0\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Stati
c;C:\Program Files (x86)\Common Files\Acronis\SnapAPI\;C:\Program Files (x86)\AM
D\ATI.ACE\Core-Static;C:\gnuplot\bin;C:\Program Files\Git\cmd;C:\Program Files\C
alibre2\;C:\Program Files\MiKTeX 2.9\miktex\bin\x64\;C:\Program Files\MySQL\MySQ
L Utilities 1.6\;C:\Program Files (x86)\Common Files\Acronis\VirtualFile\;C:\Pro
gram Files (x86)\Common Files\Acronis\VirtualFile64\;C:\Program Files (x86)\Comm
on Files\Acronis\FileProtector\;C:\Program Files (x86)\Common Files\Acronis\File
Protector64\;C:\Program Files\nodejs\;C:\Program Files (x86)\Brackets\command;C:
\Program Files\Microsoft VS Code\bin;C:\Users\ray\AppData\Local\Programs\Python\
Launcher\;d:\bin;C:\Users\ray\AppData\Roaming\npm;C:\Users\ray\AppData\Local\ato
m\bin;C:\Program Files (x86)\FAHClient;x:\Program Files\Docker Toolbox

Here and here are a similar problems.

Some have suggested copying the dll's to the python path area.

Seems to have turned in to a warning overnight. Now I get:

(handson-ml2) d:\ray\dev\mlbooks\handson-ml2>py
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AM
D64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2020-06-25 13:53:13.746994: W tensorflow/stream_executor/platform/default/dso_lo
ader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64
_101.dll not found
2020-06-25 13:53:13.776619: I tensorflow/stream_executor/cuda/cudart_stub.cc:29]
 Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Pip subprocess error:
ERROR: Could not find a version that satisfies the requirement bokeh>=2.0.0 (fro
m panel>=0.7.0->holoviews->-r D:\ray\dev\COVID-19\condaenv.tvdi0rp1.requirements
.txt (line 5)) (from versions: 0.2, 0.3, 0.4, 0.4.1, 0.4.4, 0.5.0, 0.5.1, 0.5.2,
 0.6.0, 0.6.1, 0.7.0, 0.7.1, 0.8.0, 0.8.1, 0.8.2, 0.9.0, 0.9.1, 0.9.2, 0.9.3, 0.
10.0, 0.11.0, 0.11.1, 0.12.0, 0.12.1, 0.12.2, 0.12.3, 0.12.4, 0.12.5, 0.12.6, 0.
12.7, 0.12.9, 0.12.10, 0.12.11, 0.12.13, 0.12.14, 0.12.15, 0.12.16, 0.13.0, 1.0.
0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.1.0, 1.2.0, 1.3.0, 1.3.1, 1.3.2, 1.3.4, 1.4.0)
ERROR: No matching distribution found for bokeh>=2.0.0 (from panel>=0.7.0->holov
iews->-r D:\ray\dev\COVID-19\condaenv.tvdi0rp1.requirements.txt (line 5))


CondaEnvException: Pip failed

This is the original stack trace:

Traceback (most recent call last):
  File "d:\miniconda3\envs\tf2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "d:\miniconda3\envs\tf2\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "d:\miniconda3\envs\tf2\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 "d:\miniconda3\envs\tf2\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "d:\miniconda3\envs\tf2\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "2.py", line 1, in <module>
    import tensorflow as tf
  File "d:\miniconda3\envs\tf2\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "d:\miniconda3\envs\tf2\lib\site-packages\tensorflow\python\__init__.py", line 50, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "d:\miniconda3\envs\tf2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 69, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "d:\miniconda3\envs\tf2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "d:\miniconda3\envs\tf2\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "d:\miniconda3\envs\tf2\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 "d:\miniconda3\envs\tf2\lib\imp.py", line 242, in load_module
    return load_dynamic(name, filename, file)
  File "d:\miniconda3\envs\tf2\lib\imp.py", line 342, in load_dynamic
    return _load(spec)
ImportError: DLL load failed: The specified module could not be found.


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.

来源:https://stackoverflow.com/questions/62376660/installing-tensorflow-2-gets-a-dll-failed-to-load-in-pywrap-tensorflow-py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!