Python Tensorflow under Windows 10 - python

I am trying to get Tensorflow GPU support going in Python under Windows 10.
What does work;
Download and install Python v3.7.3
pip3 install --ignore-installed --upgrade tensorflow
pip3 install --ignore-installed --upgrade scipy
Run Python from a command prompt and then type import tensorflow
Works and returns no errors
I can run tensorflow Python programs on the CPU (https://github.com/cysmith/neural-style-tf if it matters)
What doesn't work;
I now uninstall CPU tensorflow and install GPU tensorflow
pip3 uninstall tensorflow
pip3 install --ignore-installed --upgrade tensorflow-gpu
Both uninstall and install finish without errors.
I download and install Cuda Toolkit 9.0 and patches.
I download and extract cuDNN and copy the relevant DLLs to the folders under C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\extras\demo_suite\oceanFFT.exe runs as expected, so I am now assuming Cuda is installed correctly
Run Python from a command prompt window
Type import tensorflow
fails with these errors...
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "C:\Users\Username\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\Username\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\Username\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\Username\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\Username\AppData\Local\Programs\Python\Python37\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 "<stdin>", line 1, in <module>
File "C:\Users\Username\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\Username\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\Username\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\Username\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\Username\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\Username\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\Username\AppData\Local\Programs\Python\Python37\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\Username\AppData\Local\Programs\Python\Python37\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.
>>>
The path corrctly has the Cuda entries at the start, ie
PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\libnvvp;
I tried uninstalling Cuda v9 and tried v8 and newest v10. Same errors.
Any ideas what I need to do to get tensorflow GPU working under Python in Windows 10?
Also tried older Python v3.6.8 after seeing some posts saying v3.7 not supported.
Same errors
Python 3.6.8 (tags/v3.6.8:3c6b436a57, Dec 24 2018, 00:16:47) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "C:\Users\Username\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Username\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Username\AppData\Local\Programs\Python\Python36\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\Username\AppData\Local\Programs\Python\Python36\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\Username\AppData\Local\Programs\Python\Python36\lib\imp.py", line 343, 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 "<stdin>", line 1, in <module>
File "C:\Users\Username\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\Username\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Username\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Username\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Username\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Username\AppData\Local\Programs\Python\Python36\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\Username\AppData\Local\Programs\Python\Python36\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\Username\AppData\Local\Programs\Python\Python36\lib\imp.py", line 343, 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.
>>>
I also went back to Python v3.5.2, installed tensorflow-gpu and got the same errors...
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "C:\Users\Username\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Username\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Username\AppData\Local\Programs\Python\Python35\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\Username\AppData\Local\Programs\Python\Python35\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\Username\AppData\Local\Programs\Python\Python35\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 "<stdin>", line 1, in <module>
File "C:\Users\Username\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\Username\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Username\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\Username\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Username\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Username\AppData\Local\Programs\Python\Python35\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\Username\AppData\Local\Programs\Python\Python35\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\Username\AppData\Local\Programs\Python\Python35\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.
>>>
So before I go mad from trying every combo of Python, Cuda and cuDNN hoping to get a working match, is there any actual steps of which version(s) to install and what sequence to make this work?
Edit: The versions I needed/used to make this work were;
Installed Python v3.6.4
pip3 install --no-cache-dir --ignore-installed --upgrade tensorflow-gpu==1.12.0
pip3 install --no-cache-dir --ignore-installed --upgrade scipy
pip3 install --no-cache-dir --ignore-installed --upgrade opencv_python-3.4.5-cp36-cp36m-win_amd64.whl
Cuda 9.0
cuDNN needs to be "Download cuDNN v7.2.1 (August 7, 2018), for CUDA 9.2"

From Tensorflow install
Windows setup
See the hardware requirements and software requirements listed above.
Read the CUDA® install guide for Windows.
Make sure the installed NVIDIA software packages match the versions
listed above. In particular, TensorFlow will not load without the
cuDNN64_7.dll file. To use a different version, see the Windows build
from source guide.
Maybe you don't have the specified file cuDNN64_7.dll
Please check if the file is present in C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0\bin
Where 9.0 is the version of CUDA
Actually I have this setup working in Windows 10
Python 3.6.4
Tensorflow 1.12.0
CUDA 9.0
Edit: Some research I found this related links to the issue
Search for DLL: Tensorflow install errors
Issues related:
https://github.com/tensorflow/tensorflow/issues/22512
https://github.com/tensorflow/tensorflow/issues/22794

For all those with the „DLL load failed“ problem under Windows 10/Python 3.6.x/RTX20xx.
The combination of CUDA 10.0 (not 10.1!), cuDNN 7.5.0 works fine for me (as of 12 April 2019). I also have Visual Studio 2015 installed (but not sure if needed).
Don‘t forget to add the location of the cuDNN *.dll file (it‘s the /bin/ dir in your CUDA dir) to your PATH.
If you have CUDA 10.1, just uninstall it, install 10.0, add the cuDNN files to the 10.0 dir, and reboot.
Tensorflow can be installed using pip install tensorflow-gpu

Related

Can't run tensorflow on Win10

I am trying to run Gpt2 on my machine, i am following this guide : https://lambdalabs.com/blog/run-openais-new-gpt-2-text-generator-code-with-your-gpu/
I created a new environment on Conda to make sure it would be isolated and all, and downloaded the correct versions of the libs.
My environment is :
Windows 10
Python 3.6
tensorflow-gpu 1.12 (installed with pip)
CUDA v9, v10, v11
cuDNN for v9 and for v11 (i first installe dht elatest, but then i was told tensorflow was only happy with version 9 so i installed it)
Whenever i try to import tensorflow, either with from tensorflow import * or import tensorflow as tf
I get :
Traceback (most recent call last):
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\theo1\Anaconda3\envs\gpt2\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\theo1\Anaconda3\envs\gpt2\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\imp.py", line 343, 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 "<stdin>", line 1, in <module>
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\theo1\Anaconda3\envs\gpt2\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\theo1\Anaconda3\envs\gpt2\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\theo1\Anaconda3\envs\gpt2\lib\imp.py", line 343, 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.
This error isn't helping at all, and i'm stuck there. Any ideas ?
Thank you.
EDIT :
For those running in the same problem, follow the github link, install everything with conda. I also ran into this problem : Tensorflow has no Attribute "sort" in GPT 2 Git Release? that was solved as well by udating tensorflow. Thanks everyone
Please try to install tensorflow with conda with below command.
conda install -c conda-forge tensorflow //tensorflow package
or for specific version
conda install -c conda-forge tensorflow=1.13.1

tensorflow.python.pywrap_tensorflow_internal no module windows 10 tensorflow gpu

"tensorflow-cpu" works fine on my device with windows 10.
I was trying to install tensorflow-gpu and after installing it fails to import showing the following error.
tensorflow.python.pywrap_tensorflow_internal no module
I have installed the following
CUDA 10.1
Nvidia graphics driver Version 419
CUDnn for CUDA 10.1
VC++ 2015 REDIST
Could anyone say what am i missing here is complete error message.
Traceback (most recent call last):
File "D:\Program Files\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "D:\Program Files\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "D:\Program Files\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 "D:\Program Files\Python\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "D:\Program Files\Python\lib\imp.py", line 343, 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 "<stdin>", line 1, in <module>
File "D:\Program Files\Python\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "D:\Program Files\Python\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "D:\Program Files\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "D:\Program Files\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "D:\Program Files\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "D:\Program Files\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 "D:\Program Files\Python\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "D:\Program Files\Python\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
If your are sure you have Visual C++ 2015 Redist installed on your Windows machine then probably it is the version conflict between CUDA version and the Tensorflow version. Because newer versions have some conflicts and more over tensorflow requires the exact version of CUDA and the CUDnn Library for it to work properly.
The best way to get it configured correctly is using Anaconda for installing and configuring tensorflow-gpu as conda will automatically download all the necessary versions of CUDA and CUDnn for the corresponding tensorflow
The problem is that the new Anaconda uses Python 3.7.x by default which is not supported by tensorflow or tensorflow-gpu
So install Anaconda You can download it here
Now create a virtual environment using conda with python 3.6.x configured by typing the following in Anaconda Prompt
conda create -n yourenvname python=3.6 anaconda
Now change switch to your environment by typing in
conda activate yourenvname
Now Check the python version by using which should show you something like this
> python --version
Python 3.6.7 :: Anaconda custom (64-bit)
Now finally install tensorflow-gpu
conda install tensorflow-gpu
Now open python and try importing tensorflow
>>> import tensorflow as tf
>>> sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
Congrats ! You are all set.

How to setup virtual environment to run tensorflow benchmarks

My purpose is setting up virtual environment to run tensorflow benchmark but I am getting an error at last statement after running following code. May I ask what I should do to resolve this issue? FYI: I am using Python 3.6.7 with only pip and virtualenv packages and CUDA 9.2/cuDNN7 installed (all dlls in system path).
virtualenv venv
venv\scripts\activate
#now you should be in virtual environment
#install using pip
pip install tf-nightly-gpu
python
import tensorflow
Error message:
>>> import tensorflow
Traceback (most recent call last):
File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\MyWork\testarea\testvirtualenv\venv\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:\MyWork\testarea\testvirtualenv\venv\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\MyWork\testarea\testvirtualenv\venv\lib\imp.py", line 343, 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 "<stdin>", line 1, in <module>
File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\MyWork\testarea\testvirtualenv\venv\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\MyWork\testarea\testvirtualenv\venv\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:\MyWork\testarea\testvirtualenv\venv\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\MyWork\testarea\testvirtualenv\venv\lib\imp.py", line 343, 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.
>
Found an answer just after writing the question.
Downgrading CUDA 9.2 to 9.0 before copying cudnn64_7.dll (cuDNN 7.3.1 for CUDA 9.0) to CUDA bin directory made it work.
In the end, following script produced two different results from two different machines.
virtualenv venv
venv\scripts\activate
pip install tf-nightly-gpu
python tf_cnn_benchmarks.py --num_gpus=1 --batch_size=32 --model=resnet50 --variable_update=parameter_server
7th gen quad-core i7 with GTX 970
total images/sec: 78.16
AMD 1920X with GTX 1080
total images/sec: 147.77

Tensorflow: Import failed with "Failed to load the native TensorFlow runtime."

I'm trying to install the CPU version of tensorflow in a virtualenv on Mac OS 10.6.8 (all I've got for now) with Python 3.6, using the package url as described here. It seems to work fine:
Ms-MacBook:tensorflow User$ source tfvenv/bin/activate
(tfvenv) Ms-MacBook:tensorflow User$ python --version
Python 3.6.1
(tfvenv) Ms-MacBook:tensorflow User$ pip --version
pip 9.0.1 from /Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages (python 3.6)
(tfvenv) Ms-MacBook:tensorflow User$ pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.1.0-py3-none-any.whl
[...]
Successfully installed numpy-1.12.1 protobuf-3.3.0 tensorflow-1.1.0 werkzeug-0.12.2
However, when I try to import tensorflow in a Python interpreter I get this error:
(tfvenv) Ms-MacBook:tensorflow User$ python
Python 3.6.1 (v3.6.1:69c0db5050, Mar 21 2017, 01:21:04)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/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 "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: dlopen(/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 10): Library not loaded: /usr/lib/libc++.1.dylib
Referenced from: /Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
Reason: image not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/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 "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: dlopen(/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 10): Library not loaded: /usr/lib/libc++.1.dylib
Referenced from: /Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
Reason: image not found
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.
Unfortunately there is now mention of this among the common installation problems. Can anybody tell me what's going wrong here?
ImportError: dlopen(/Users/M/Developer/tensorflow/tfvenv/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 10): Library not loaded: /usr/lib/libc++.1.dylib
libc++ was not included in MacOS 10.6 because Apple had not switched to Clang and libc++ yet. That's your problem.
Refer to this.

Failed to load the native TensorFlow runtime : error while importing tensorflow

I built TensorFlow from source on my Ubuntu 17.04 32bit
I got this message while importing tensorflow
palash#ash:~$ python
Python 3.6.0 |Anaconda 4.3.1 (32-bit)| (default, Dec 23 2016, 12:22:10)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
Traceback (most recent call last):
File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 61, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
File "/home/palash/anaconda3/lib/python3.6/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/palash/anaconda3/lib/python3.6/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /home/palash/anaconda3/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow.so)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 61, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "/home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
File "/home/palash/anaconda3/lib/python3.6/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/home/palash/anaconda3/lib/python3.6/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: /home/palash/anaconda3/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /home/palash/anaconda3/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow.so)
Failed to load the native TensorFlow runtime.
See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
my bazel info:
palash#ash:~$ bazel version
Build label: 0.4.5- (#non-git)
Build target: bazel-out/local-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri May 19 01:31:26 2017 (1495157486)
Build timestamp: 1495157486
Build timestamp as int: 1495157486
my TensorFlow version : 1.0.1
I found the solution in sense that perhaps it seems to be some compatibility error in tensorflow version 1.6 or above.
Downgrading the tensorflow to version 1.5 solved my problem.
To do this , I recommend to uninstall tensorflow version 1.8 by using pip uninstall tensorflow and again installing the version 1.5 by using pip install tensorflow==1.5.
In addition i would recommend that uninstall and reinstall keras library as well.
It is possibly because of compatibility issues. For my Ubuntu 18 server, I had to use tensorflow==1.12 and it works now.
Try downgrading from latest version (1.12, now 26 Mar 2019) and see which version works.
This script tries a version (trytfver.sh):
pip uninstall tensorflow -y
pip install --user tensorflow==$1
python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
Try it as following:
bash trytfver.sh 1.12
bash trytfver.sh 1.11
bash trytfver.sh 1.10
bash trytfver.sh 1.9
bash trytfver.sh 1.8
bash trytfver.sh ...
And see if any 'undefined symbol' errors appear, for example, I have error on 1.11.

Categories

Resources