tensorflow-gpu on Windows: No module named '_pywrap_tensorflow_internal' - python

I am trying to install Tensorflow with GPU support on Windows 10 according to the following guide: https://nitishmutha.github.io/tensorflow/2017/01/22/TensorFlow-with-gpu-for-windows.html
However, I got the following error when I import tensorflow in Conda Python 3.5.2:
How I fix this dll-not-found error? 'pip install tensorflow-gpu' did not give any errors.
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 906, in create_module
File "", line 222, in _call_with_frames_removed
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 "C:\ProgramData\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41,
in from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\ProgramData\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in _pywrap_tensorflow_internal = swig_import_helper() File "C:\ProgramData\Anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\ProgramData\Anaconda3\envs\tensorflow-gpu\lib\importlib__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'
Failed to load the native
TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.

Tensorflow installation with pip did not give any errors, but I fixed my problem by installing CuDNN V6 instead of CuDNN V5.1. It appears that tensorflow V1.3.0 now uses CuDNN V6.

You have the option of installing Tensorflow with native pip on windows.
https://www.tensorflow.org/install/install_windows
You may use the python script (tensorflow_self_check.py) to check the problems during the installation.

Related

Tensorflow 2.1.0 - DLL load failed - windows cpu

Installation of TensorFlow 2.1.0 was successful, but TensorFlow import failed.
Open question:
Is there a library that is in a different location/not installed on the system that cannot be loaded?
Procedure for reproduction:
1) create environment
conda create --name tensorflow21_env
2) activate environment
conda activate tensorflow21_env
3) install
conda install python=3.7
pip install tensorflow-cpu #install tensorflow=2.1.0;
4) test
python -c "import tensorflow as tf"
Stacktrace:
Traceback (most recent call last):
File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Anaconda3\envs\tensorflow21_env\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:\Anaconda3\envs\tensorflow21_env\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Anaconda3\envs\tensorflow21_env\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 "<string>", line 1, in <module>
File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow\__init__.py", line 101, in <module>
from tensorflow_core import *
File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
module = self._load()
File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow\__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "C:\Anaconda3\envs\tensorflow21_env\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow_core\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Anaconda3\envs\tensorflow21_env\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Anaconda3\envs\tensorflow21_env\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:\Anaconda3\envs\tensorflow21_env\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Anaconda3\envs\tensorflow21_env\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.
Installation Output:
Output: conda install python=3.7
Collecting package metadata (current_repodata.json): done
Solving environment: done
## Package Plan ##
environment location: C:\Anaconda3\envs\tensorflow21_env
added / updated specs:
- python=3.7
The following NEW packages will be INSTALLED:
ca-certificates pkgs/main/win-64::ca-certificates-2020.1.1-0
certifi pkgs/main/win-64::certifi-2019.11.28-py37_0
openssl pkgs/main/win-64::openssl-1.1.1d-he774522_4
pip pkgs/main/win-64::pip-20.0.2-py37_1
python pkgs/main/win-64::python-3.7.6-h60c2a47_2
setuptools pkgs/main/win-64::setuptools-45.2.0-py37_0
sqlite pkgs/main/win-64::sqlite-3.31.1-he774522_0
vc pkgs/main/win-64::vc-14.1-h0510ff6_4
vs2015_runtime pkgs/main/win-64::vs2015_runtime-14.16.27012-hf0eaf9b_1
wheel pkgs/main/win-64::wheel-0.34.2-py37_0
wincertstore pkgs/main/win-64::wincertstore-0.2-py37_0
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
The dependency walker confirms that all DLLs could be loaded (download dependency walker).
dependency_trace
Addon:
path for dependency walker
C:\Anaconda3\envs\tensorflow21_env\Lib\site-packages\tensorflow_core\python\_pywrap_tensorflow_internal.pyd
Update:
My processor supports neither AVX nor AVX2 and therefore the tensorflow pip package could not be installed or to be more precise the tensorflow package could not be imported.
Interim solution:
The interim solution for legacy & low-end CPU without AVX support is to install SSE-prebuild-binaries for tensorflow.
Go to tensorflow-windows-wheel and follow instruction to install either tensorflow 2.0.0 or 2.1.0.
Try this method:
Uninstall the TensorFlow package that you installed using pip and reinstall using conda install tensorflow this may work! Now you can import TensorFlow without problems. I hope this can help you.
If you need more detailed steps. Here, you can do the following below.
Run the anaconda prompt as an administrator. (right click-> run as administrator).
pip uninstall tensorflow
Close anaconda prompt.
Again run anaconda prompt as administrator.
type:
conda install tensorflow
It will ask for some y / n
Type y.
Now after all done, change your python interpreter's environment to anaconda environment where you installed tensorflow.
Now try importing tensorflow.
I hope this helps.

cannot import tensorflow-gpu dll load failed

I couldn't solve my problem with previous similar questions.
I installed tensorflow-gpu 2.0.0 along python 3.6, cuda 10 and cudnn 7.4.2.
now according to this page, these are compatible and tested:
https://www.tensorflow.org/install/source_windows#tested_build_configurations
when importing, this is the error its returning:
>>> import tensorflow
2020-02-05 15:17:43.900905: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\p6\lib\site-packages\tensorflow\__init__.py", line 98, in <module>
from tensorflow_core import *
File "C:\p6\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\p6\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
module = self._load()
File "C:\p6\lib\site-packages\tensorflow\__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "C:\p6\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\p6\lib\site-packages\tensorflow_core\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\p6\lib\site-packages\tensorflow_core\core\framework\graph_pb2.py", line 7, in <module>
from google.protobuf import descriptor as _descriptor
File "C:\p6\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.
I have already tried reinstalling all of them. i've also checked and the PATH is also added in environment variables. got these errors on latest version of python, tensorflow-gpu, cuda, cudnn too.
could someone please help me with this?
There are 4 possible reasons for Tensorflow installation issues in windows
You need to install the MSVC 2019 redistributable from here
Your CPU does not support AVX2 instructions
Your CPU/Python is on 32 bits
There is a library that is in a different location/not installed on your system that cannot be loaded.

python tensorflow import dll load failed

I installed latest python 3.6.4 x64 version
and then installed tensorflow for cpu-only with pip3
C:\>pip3 install tensorflow
however when I tried to import tensorflow in python
it showed me the error below
I am sure that I have installed Microsoft Visual C++ 2015 Redistributable(x64)
so it wll not be the problem of dll msvcp140.dll lost
it say that "DLL load failed with error code -1073741795"
so what is exactly the problem here
i cannot find any other information about this error code
my os : windows 7 enterprise with service pack 1 / 64 bit / intel core i5 M 540
>>> import tensorflow
Traceback (most recent call last):
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\importlib\__ini
t__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed with error code -1073741795
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\importlib\__ini
t__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\importlib\__ini
t__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed with error code -1073741795
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\site-packages\t
ensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\Alan\AppData\Local\Programs\Python\Python36\lib\importlib\__ini
t__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_probl
ems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
I got same problem with tensorflow1.6-CPU on win7 64bit(Intel Core 2 Duo Cpu T6670 2.2GHz)
After I found this, and it solved my problem.
Reference this issue: https://github.com/tensorflow/tensorflow/issues/17386
Re-installed by this tensorflow-1.6.0-cp36-cp36m-win_amd64.whl: https://github.com/fo40225/tensorflow-windows-wheel/tree/master/1.6.0/py36/CPU/sse2
Hope this .whl may help you.
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!
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):
tensorflow-windows-wheel
I had the same issue.
I upgraded pip version with:
python -m pip install --upgrade pip
also, downgraded with
pip install tensorflow==2.0
and it worked
ImportError: DLL load failed
for
windows 10
python 3.6
pip install protobuf==3.6.0
or
pip3 install protobuf==3.6.0
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.
Hope it helps.
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
pip install tensorflow
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
pip install tensorflow==1.5
Install Microsoft Visual C++ 2019 Redistributable & reboot the PC, it will work with tensorflow 2.3.1 in python 3.7

Tensorflow cannot use GPU

I have installed CUDA because I need to run some Deep Neural Network models, but Tensorflow is still unable to see the gpu
from tensorflow.python.client import device_lib
print(device_lib.list_local_devices())
It shows only the CPU.
How can I get Tensorflow to use my gpu?
error log I get when I import keras with tensorflow-gpu installed
ImportError: Traceback (most recent call last):
File "C:\Users\Monviso\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Monviso\Anaconda3\lib\importlib__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 978, in _gcd_import
File "", line 961, in _find_and_load
File "", line 950, in _find_and_load_unlocked
File "", line 648, in _load_unlocked
File "", line 560, in module_from_spec
File "", line 922, in create_module
File "", line 205, in _call_with_frames_removed
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 "C:\Users\Monviso\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Monviso\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Monviso\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\Monviso\Anaconda3\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
Your Cuda version is the problem. Only the tensorflow version 1.5 supports CUDA 9 and cuDNN 7. The previous versions of the Tensorflows support only CUDA 8 and cuDNN 6. If you have installed using anaconda it is very likely that you have not installed version 1.5. Use pip or pip3 to install.
Since you are using a windows machine check this link to install tensorflow with gpu support.
Check this link to see which version require what Cuda and Cudnn
I recommend you to uninstall both the CPU and GPU version of tensorflow and install afresh.
If you wanna keep your cuda version to 9 then install tensorflow version 1.5. If you install using anaconda it is likely you will get version 1.4 which supports only Cuda 8

Failed to load the native TensorFlow runtime. Python 3.5.2

I'm trying to install Tensorflow in my PC, i installed Python 3.5.2 64-bit, cuda_8.0.61 for windows 10 and cudnn-8.0-windows10-x64-v6.0
I used "native" pip to install GPU version of Tensorflow, then i open IDLE and testing with "import tensorflow as tf" and i got the error bellow
How can i fix this ? Thanks you in advance <3
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
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 "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import tensorflow as tf
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
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 "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\Admin\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
I managed to run Tensorflow on Windows following these steps. Hope it helps! It may change depending in which folder you installed Python.
Download and install Python 3.5.x
Download and install Nvidia CUDA Toolkit
Download CuDNN 5.1
Copy CuDNN files to Nvidia CUDA toolkit folder when 2. has completed (usually is located on C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0)
copy cudnn\bin\cudnn64_5.dll to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\
copy cudnn\include\cudnn.h to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include\
copy cudnn\lib\x64\cudnn.lib to C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64\
Install Tensorflow via pip command prompt
'pip install --upgrade tensorflow-gpu'
5.1 TensorFlow dependencies
make sure that Visual C++ Redistributate 2015 x64 is installed. If not, download it
move _curses_curses.cp35-win_amd64.pyd and _curses_panel.cp35-win_amd64.pyd to
C:\Users\Username\AppData\Local\Programs\Python\Python35\Lib\site-packages (or you may need to download them as the next packages. just Ctrl+f for 'curses')
download and install these packages via pip (move to the directory where they were
downloaded, open a command prompt and make 'pip install package_name')
numpy+mkl (http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy)
download numpy‑1.12.1+mkl‑cp35‑cp35m‑win_amd64.whl
pip install numpy‑1.12.1+mkl‑cp35‑cp35m‑win_amd64.whl
scipy (http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy)
download scipy‑0.19.0‑cp35‑cp35m‑win_amd64.whl
pip install scipy‑0.19.0‑cp35‑cp35m‑win_amd64.whl
open command prompt and make 'pip install matplotlib'
Try:
pip install https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0rc0-cp35-cp35m-win_amd64.whl
to install tensorflow instead of:
pip install --upgrade tensorflow-gpu
My computer is Windows with CPU and I have had same issues. I uninstall tensorflow 1.9 and install 1.5 instead. It works right now.
Why don't try Anaconda?
conda create -n gpu_env tensorflow-gpu
conda activate gpu_env
As easy as that. All the packages and runtime needed (Visual Studio included) will be brought together while you watch in awe :). Give it a try!
Caveat: You need to run Keras from inside tensorflow in order for it to detect and use your GPU. Otherwise if you use just keras and tensorflow as a backend, Keras will use plain tensorflow and not tensorflow-gpu. Boths are installed side by side.
Meaning you should code it this way:
import tensorflow as tf
from tensorflow.keras.models import Sequential, load_model
from tensorflow.keras.layers import Dense,Dropout
from tensorflow.keras.callbacks import ModelCheckpoint, EarlyStopping,CSVLogger
from tensorflow.keras.utils import plot_model
.............
.............
Hope this help.
If the problem persists check the version numbering and make sure cuda and TF are compatible.
Check the version numbering here
or for a simpler way, use Anaconda
conda create --name new_env_name tensorflow-gpu
activate new_env_name
I successfully installed TensorFlow GPU version 1.12 (latest until the date of writing) with Cuda 9.0, GeForce 1050 Ti, Windows 10 and Python 3.6.7
Note: You have installed the CUDA Toolkit (version 9) for TensorFlow to recognize your GPU
The problem for me was with a package named protobuf, It was solved by using
pip install https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-0.12.0rc0-cp35-cp35m-win_amd64.whl
which upgraded protobuf to 3.6.1 and solved the error.
I have the same problem with you.
The problem is that Anaconda automatically updates the python version when installing ipython and spyder, which becomes version 3.6.
You can change the python version to version 3.5 by entering the tensorflow environment via Anaconda.
enter image description here
Everything could be installed from the console:
conda create --name tf-gpu
conda install -c aaronzs tensorflow-gpu
conda install -c anaconda cudatoolkit
conda install -c anaconda cudnn
conda install keras-gpu
Let’s solve this issue in a simplified way…
I do hope that you are going through some problems when trying to import TensorFlow or maybe when importing other libraries which use TensorFlow in the backend.
I solved the above problem by installing Visual C++ distribution.
Click to download visual C++ version.
Now, It ran successfully.

Categories