Importerror dll load failed не найдена указанная процедура tensorflow
I ran through the TensorFlow object detection installation on Windows.
After successfully installing TensorFlow object detection,
I ran following command to test, and receiving error below. How can this be fixed?
Error: Traceback (most recent call last): File "C:\TestImage\models\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed while importing pywrap_tensorflow_internal: The specified module could not be found. Traceback (most recent call last): File "object_detection/builders/model_builder_test.py", line 21, in from object_detection.builders import model_builder File "c:\testimage\models\research\object_detection\builders\model_builder.py", line 23, in from object_detection.builders import anchor_generator_builder File "c:\testimage\models\research\object_detection\builders\anchor_generator_builder.py", line 23, in from object_detection.anchor_generators import flexible_grid_anchor_generator File "c:\testimage\models\research\object_detection\anchor_generators\flexible_grid_anchor_generator.py", line 17, in import tensorflow.compat.v1 as tf File "C:\TestImage\models\venv\lib\site-packages\tensorflow_init.py", line 41, in from tensorflow.python.tools import module_util as module_util File "C:\TestImage\models\venv\lib\site-packages\tensorflow\python_init.py", line 40, in from tensorflow.python.eager import context File "C:\TestImage\models\venv\lib\site-packages\tensorflow\python\eager\context.py", line 35, in from tensorflow.python import pywrap_tfe File "C:\TestImage\models\venv\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in from tensorflow.python import pywrap_tensorflow File "C:\TestImage\models\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in raise ImportError(msg) ImportError: Traceback (most recent call last): File "C:\TestImage\models\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed while importing _pywrap_tensorflow_internal: The specified module could not be found.
I'm using Anaconda 3.1.0 on Windows 7 64 bit. I have installed tensorflow(GPU). I am getting errors while running following command.
>>> import tensorflow as tf
The complete traceback
As clearly stated in the TF webpage The Anaconda installation is community supported, not officially supported. . so I would recommend you installed it with the alternative (that is pip) or move to a *nix OS distribution.
8 Answers 8
Installing Microsoft Visual C++ Redistributable für Visual Studio 2019 resolved the described problem for me
Tested on Windows 10 for Python 3.6 (Anaconda) and Tensorflow 2.1.0
This worked for me after searching high and low for a solution - thanks for mentioning it. (Windows Server 2016 - Standard)
I faced the same error. The problem is not with the python or tensorflow versions but the dependencies required for it from the windows operating system. Just follow the following steps and you are good to go.
I used to get this kind of error.
The reason that I had installed the wrong and mismatched versions of Tensorflow backend and Keras
The versions I fixed that has worked perfectly for me can be seen as below
- Tensorflow 2.0.0 ( 2.1.0 throws the error)
- Keras version 2.3.1
Tensorflow 2.1.0 works perfectly on my ubuntu machine at work, but your solution to use tensorflow 2.0.0 worked on my windows machine at work!
Yes, i used Windows for the work. I hope Tensorflow version 2.1.0 would throw no error in Linux. Thanks for your info.
In my case, Win10 could not find the module because the environment variable cuDNN was not set correctly!
You need to set the env var to the bin subfolder. In my case as I extracted it to C: , I had to add C:\cuda\bin to the path system varaible. For more infos, checkout this.
Or relate to this for checking the compatiblity of the versions.
cudnn lib version was wrong, so I replaced correct version of cudnn lib and it worked.
Tensorflow 1.3 need cudnn V6, make sure you have a cudnn64_6.dll in the folder C:\Program Files\NVIDIA Cudnn\cuda\bin and this path into the environment variable
I faced the same issue with tensorflow-1.12.0 what i did was :
- Install anaconda
- open anaconda prompt
- conda create -n tfp python=3.6
- activate tfp
- conda install tensorflow
- python
- Now check by importing tensorflow
the version i used was 3.6, but you can also try with 3.7 Hope it helps!
Thanks, this worked for me. My Anaconda install was version 5.2.0. Installing tensorflow 1.12.0 through the Anaconda Navigator did not work, but doing it your way did. I had to cd to C:\Users\Username\Anaconda3\Scripts for your line 5.
I downgraded tensorflow to 1.10.0 and it fixed the issue
Probably, your CPU does not have the instructions for AVX (needed for all tensorflow binaries since 1.6). You can check that with some tool like CPU-Z. If that is the case, you can donwload the correct wheel here (use SSE2 binaries):
I had the same issue. I upgraded pip version with:
also, downgraded with
ImportError: DLL load failed
for
windows 10
python 3.6
I fixed it. Spend days searching to fix them.
Installed tensorflow with pip install tensorflow-cpu
Updated visual C++ 2015-2019
The issue was because I didn't have nvidia graphics so that I should install with cpu version because I am using Radeon Vega 8 graphics.
I have tried different methods still it doesn't work then I apply this method it works for me.
STOP you antivirus protection software for half hour then install anaconda,it works fine. 100%
If you use python 3.6.10 and tensorflow 2.1.0 Just follow this -
pip install tensorflow==2.0
It worked for me.
I had first Upgraded the Anaconda prompt
I had then used conda create -n tfp python=3.7
conda activate tfp
Then import the tensorflow
I faced the similar issue for tensorflow 2.0 First I uninstalled tensorflow using pip uninstall tensorflow (no need to uninstall tensorflow-estimator or tensorboard). Then I reinstall using conda install tensorflow.
Never install the latest version of tensorflow it will raise an error DLL file load error
never run command on your computer as it not supports the tensorflow cpu most of the latest version supports mostly gpu
so while installing install the lower version of the tensorflow from my opininon the stable release of tensorflow is tensorflow 1.5 make sure you uninstalled your tensorflow installed in your computer pip uninstall tensorflow
After above step shutdown your pc and restart.Then only install tensorflow 1.5 command to install tensorflow version 1.5
Доброго времени суток, стоит python 3.9, сам tensorflow запускается из-под python 3.8 в командной строке windows
После py -3.8 и попытки import tensorflow лезет следующая ошибка:
Python 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 23:03:10) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import tensorlflow
Traceback (most recent call last):
File "", line 1, in
ModuleNotFoundError: No module named 'tensorlflow'
>>> import tensorflow
Traceback (most recent call last):
File "C:\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: Произошел сбой в программе инициализации библиотеки динамической компоновки (DLL).
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
File "C:\Python\Python38\lib\site-packages\tensorflow\__init__.py", line 41, in
from tensorflow.python.tools import module_util as _module_util
File "C:\Python\Python38\lib\site-packages\tensorflow\python\__init__.py", line 39, in
from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow
File "C:\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Python\Python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: Произошел сбой в программе инициализации библиотеки динамической компоновки (DLL).
Failed to load the native TensorFlow runtime.
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
С чем это может быть связано и что мне делать?
Python PyCharm Tensorflow
Здравствуйте форумчане , появилась необходимость использовать библиотеку tensorflow , вопреки.
Проблема компиляции Python + TensorFlow + Keras
Всем доброго здоровья. Возникла такая проблема. Не получается скрипт с модулями TensorFlow и Keras.
Создание LSTM сети в Python с TensorFlow
Здравствуйте, появилась проблема в написании кода LSTM сети на основе TensorFlow, в интернете есть.
I was trying to install tensorflow cpu version on windows10, but always got error when import tensorflow.
I read the common_installation_problems , tried many solution I found on github, stackoverflow, etc. I install visual studio 2015, visual studio 2017, Microsoft Visual C++ 2015 Redistributable Update 3(both 32 and 64), msvcp140.dll can find in both System32 and SysWow64 folder. But still can't import tensorflow.
Is there something I missed out?
iDiniy commented Nov 20, 2018
@Abdulr-intija thank you,i finaly resolve it .thank you
Source code / logs
run tensorflow_self_check.py result:
The text was updated successfully, but these errors were encountered:
testlump commented Nov 28, 2018 •
You might find it's best to recompile from source. This resolved the issue for me (see below for more information).
Here are some things I found compiling on Windows 10 with GPU support:
Check your CPU instruction set supports AVX with CPU-Z or an equivalent tool. If this isn't present (E.g. you're running an older CPU), you'll likely need to recompile tensorflow from source if you want it to work (this will likely apply irrespective of the OS).
Check you've got the correct CUDA libraries installed. The release Python package version of tensorflow (1.12) is built against CUDA 9.0 (I used package: cuda_9.0.176_win10.exe ) and CuDNN 7.0 (I used package: cudnn-9.0-windows10-x64-v7.4.1.5.zip ). If you have multiple CUDA versions installed side-by-side (v7.0, v9.0, v10.0) etc which you are not using, uninstall them.
Make sure your CUDA System environment variables are configured (E.g. for v9.0):
- Variable: CUDA_PATH Value: C:\Program Files\NVIDIA CPU Computing Toolkit\CUDA\v9.0
- Variable: CUDA_PATH_V9_0 Value: C:\Program Files\NVIDIA CPU Computing Toolkit\CUDA\v9.0
The CuDNN libraries should be unzipped to the CUDA install path, on Windows by default this is C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0 for version 9.0
Building from source
Install BAZEL and MSYS2 to their default locations (recommended). E.g. C:\MSYS2\ and C:\Bazel\
Clone or download the source as per the instructions and expand (E.g. C:\temp\tensorflow-master\ )
Edit the source file \third_party\gpus\cuda_configure.bzl and change the line ["grep", "--color=never", "-A1", "-E", define, to: ["C:/msys64/usr/bin/grep", "--color=never", "-A1", "-E", define, (RESPECT THE INDENTATION!)
If you have a username with a space in it - for example Peter Blakey so you users folder is C:\users\Peter Blakey\ , create a symlink from Peter in C:\Users\ - E.g. C:\users\Peter -> C:\users\Peter Blakey\ - The white-space causes path resolution problems during the build. E.g. from a command prompt in C:\users\ type mklink /d Peter "C:\Users\Peter Blakey" - you should now be able to cd in c:\users\Peter\ and see the contents of c:\users\Peter Blakey
If you have a username with a space in it, edit your User environment variables to path to Python.exe at the symlinked directory. E.g. Edit c:\users\Peter Blakey\AppData\Local\Programs\Python\Python36\ to C:\users\Peter\AppData\Local\Programs\Python\Python36\ and c:\users\Peter Blakey\AppData\Local\Programs\Python\Python36\Scripts\ to c:\users\Peter\AppData\Local\Programs\Python\Python36\Scripts\
Create a empty folder for the build - E.g. C:\temp\buildcache - make sure you have at least 20GB free.
Build Step
- Your compilation command should be something like this: bazel --output_user_root=C:/temp/buildcache build --config=opt --config=cuda --define=no_tensorflow_py_deps=true //tensorflow/tools/pip_package:build_pip_package
- If your CPU does not support AVX instruction set, when you build tensorflow omit the --config=opt flag so you build with bazel --output_user_root=C:/temp/buildcache build --config=cuda --define=no_tensorflow_py_deps=true //tensorflow/tools/pip_package:build_pip_package
Once it's built (takes several hours), follow the instructions to build the pip package (E.g. execute bazel-bin\tensorflow\tools\pip_package\build_pip_package C:/tmp/tensorflow_pkg and then install the resulting Python wheel package to your environment).
Finally, test the installed tensorflow with:
python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
Other notes
If the build fails, make sure you run bazel clean and delete the contents of the buildcache folder (E.g. c:\temp\buildcache ) before commencing a new build
You can build against the latest version of CUDA (v10.0) and cuDNN (v7) if you want. You may wish to try building against the supported version first, once you've verified that you can uninstall CUDA / CuDNN, install the latest versions and rebuild tensorflow.
thuojb commented Mar 3, 2018
Seems tensorflow 1.6 is the issue,
I installed 1.5 and it works just fine
try
pip install tensorflow==1.5
ankit338841 commented Jun 24, 2018 •
i am getting the same issue with tensorflow 1.8.0 on windows 10.
can anybody help me with this issue?
as mentioned @thuojb i degraded the version and then its working but i want to work on tensorflow 1.8.0
MDShahrouq commented May 21, 2018
@thuojb Thanks man, it still works.
But can you tell me how can we switch to tensorflow 1.8 without any errors while running
samuelprince77 commented May 18, 2018
@thuojb thanks mate. This solution still works till this day running tensorflow 1.8. Life saver
katamit commented May 28, 2018
@thuojb, thanks, yes it works with version 1.5.0
@Abdulr-intija conda install tensorflow worked for me too. able to install 1.8.0 successfully. thanks
bejo2018 commented Oct 30, 2018
i have same problem, when i import show error like this
ImportError Traceback (most recent call last)
c:\python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in
57
---> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import version
c:\python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in
27 return _mod
---> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper
c:\python\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:
c:\python\lib\imp.py in load_module(name, file, filename, details)
241 else:
--> 242 return load_dynamic(name, filename, file)
243 elif type_ == PKG_DIRECTORY:
c:\python\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 with error code -1073741795
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
in
----> 1 import tensorflow as tf
ImportError: Traceback (most recent call last):
File "c:\python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "c:\python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "c:\python\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:\python\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "c:\python\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed with error code -1073741795
- windows 7 64 bit
- python 3.5.2rc1
- intel core 2 due e8400
Vini-S commented Apr 12, 2019
ImportError Traceback (most recent call last)
~\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in
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
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 with error code -1073741795
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
in
1 import pandas as pd
----> 2 from keras.models import Sequential
3 from keras.layers import Dense
4 import numpy as np
5 from sklearn.model_selection import train_test_split
~\Anaconda3\lib\site-packages\keras_init_.py in
1 from future import absolute_import
2
----> 3 from . import utils
4 from . import activations
5 from . import applications
~\Anaconda3\lib\site-packages\keras\utils\conv_utils.py in
7 from six.moves import range
8 import numpy as np
----> 9 from .. import backend as K
10
11
~\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py in
3 from future import print_function
4
----> 5 import tensorflow as tf
6 from tensorflow.python.framework import ops as tf_ops
7 from tensorflow.python.training import moving_averages
ImportError: Traceback (most recent call last):
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\admin\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\admin\Anaconda3\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\admin\Anaconda3\lib\imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: DLL load failed with error code -1073741795
Failed to load the native TensorFlow runtime.
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
vinod270989verma commented Jan 24, 2019
Facing the same issue on my machine after some trials found a solution which worked for me.
Steps to solve the issue:
- Re-Install Cuda(Till Date Tensorflow only supports Cuda V9.0 so install Cuda9.0 only)
- Add Cuda library, bin paths to system variables
- Add Cudnn(Any Version is Ohkey) library to Cuda9.0
- Restart PC
- Install "pip install tensorflow-gpu==1.8"(I tried with higher version also but not supported in my case but 1.8 easily got installed)
gunan commented Mar 3, 2018
Mdelaf commented Jul 5, 2018
Same issue here. It worked with version 1.5.
This problem could occur when the CPU lacks AVX instruction. Using a wheel built without AVX also fix problem.
na6an commented Nov 28, 2018
Win 10 64bit. python 3.5.2, CUDA 8.0, cuDNN v5.1 still having DLL load failed on both tensorflow-gpu 1.10 and 1.12. Other setups tested including python 3.6.7, CUDA 9.0/10.0, cuDNN 7.4.1 for 10.0, 7.4.1/7.3.1 for 9.0. Confirmed msvcp140.dll, added cuda/bin, include, lib paths, made a copy for both cudnn64_5.dll and cudnn64_6.dll, reinstalled python with Tcl/Tk, etc. Nothing worked so far.
I even tried ProcessMonitor @testlump posted above, and last two dlls were "C:\Windows\System32\nvcuda.dll" and "C:\Windows\System32\setupapi.dll" However, it didn't fail. Does anyone have a clue?
Naladchik commented Jul 5, 2018
thuojb, thank you so much! I am so happy I got it working.
na6an commented Nov 28, 2018
@testlump I appreciate the detailed help. I actually attempted to compile from source first because the original pip install didn't work. Then, I soon realized fixing pip install could be easier than setting up the environment to build from source. Now it's circling back to source compiling again. I didn't want to run this on Ubuntu because the package dependency is pretty messed up there already and it keeps crashing, but perhaps I should try on Ubuntu. I will try source compiling as the last resort if that doesn't work either. Thanks for the help anyways.
testlump commented Nov 23, 2018
IverBand commented May 26, 2018
@Abdulr-intija conda install tensorflow worked for me in an identical situation. Many thanks for ending my struggle!
DanS2003 commented Apr 16, 2018
@thuojb, thanks. it fixed my problem
XuanxuanGao commented May 24, 2018
@thuojb It really works! Thank you~
Abdulr-intija commented May 25, 2018
Have in mind that downgrading to tensorflow 1.5 might not be the best solution because for instance, you won't have access to some of the new features of tensorflow like the 'eager execution' feature for example.
What i did in my case was to install tensorflow 1.8 with conda instead of pip. From my little experience with conda and pip, conda seems to perform better when it comes to placing required files in their proper location.
In summary, Instead of pip3 install --upgrade tensorflow , i used conda install tensorflow which will install the latest version properly.
rboughani commented Nov 12, 2018
i got this message with tenserflow 1.10.0,
solution ?
Читайте также: