Missing dll tensorflow-gpu - tensorflow

I have anaconda and python installed and I am trying to use tensorflow through command prompt. Can someone help?
(venv)
C:\Users\NeravDOSHI>.\venv\Scripts\activate
(venv)
C:\Users\NeravDOSHI>python --version
Python 3.7.6
(venv)
C:\Users\NeravDOSHI>pip3 --version
pip 20.1 from C:\Users\NeravDOSHI\venv\lib\site-packages\pip (python 3.7)
(venv)
C:\Users\NeravDOSHI>virtualenv --version
virtualenv 20.0.20 from c:\programdata\anaconda3\lib\site-packages\virtualenv\__init__.py
(venv)
C:\Users\NeravDOSHI>pip install --ignore-installed --upgrade
https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.13.1-cp36-cp36m-win_amd64.whl
ERROR: tensorflow-1.13.1-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.
(venv)
C:\Users\NeravDOSHI>python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "c:\programdata\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:\programdata\anaconda3\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "c:\programdata\anaconda3\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 "<string>", line 1, in <module>
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 50, in <module>
from tensorflow.python import pywrap_tensorflow
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 69, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "c:\programdata\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "c:\programdata\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:\programdata\anaconda3\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "c:\programdata\anaconda3\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.

Please follow the instructions from TensorFlow website. I recommend please install Tensorflow 2, if you are using lower versions.
You need to download and install/update the Microsoft Visual C++ 2015-2019 Redistributable (x64) from here.
If you are facing any other issues possible reasons are
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.
Please refer tested build configurations for windows CPU and GPU.

Related

Keras the specified module could not be found

I am getting this error on Keras.
ImportError: DLL load failed: The specified module could not be found while importing Keras
What I tried?
-initially "conda install -c conda-forge keras"
-then i also followed the tensorflow install instructions on tensorflow website
-I tried installing Microsoft Visual C++ that did not solve
-Also downloaded a msvcp140_1.dll file and pasted it in the sys32 and syswow64 of windows folder,did not help
-while importing the tensorflow it is reflecting the same problem
-OS-MSW-8.1
import keras
Error in callback <bound method AutoreloadMagics.post_execute_hook of <autoreload.AutoreloadMagics object at 0x0000006394266548>> (for post_execute):
Traceback (most recent call last):
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\admin\Anaconda3\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\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: The specified module could not be found.
As confirmed in comments, the OP was missing some of the Visual Studio redistributables. After installing appropriate (in terms of architecture) vc_redist from here everything worked fine.

Tensorflow 2.0.: ImportError: DLL load failed: The specified module could not be found

I just installed tensorflow 2.0 using the pip command:
pip install tensorflow-gpu==2.0.0-alpha0
The import error is shown as follows:
import tensorflow as tf
Traceback (most recent call last):
File "<ipython-input-1-64156d691fe5>", line 1, in <module>
import tensorflow as tf
File "C:\Anaconda\Anaconda3.7\lib\site-packages\tensorflow\__init__.py", line 27, in <module>
from tensorflow._api.v2 import audio
File "C:\Anaconda\Anaconda3.7\lib\site-packages\tensorflow\_api\v2\audio\__init__.py", line 8, in <module>
from tensorflow.python.ops.gen_audio_ops import decode_wav
File "C:\Anaconda\Anaconda3.7\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Anaconda\Anaconda3.7\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Anaconda\Anaconda3.7\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Anaconda\Anaconda3.7\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Anaconda\Anaconda3.7\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:\Anaconda\Anaconda3.7\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Anaconda\Anaconda3.7\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.
The installation was done on the Windows 10 with python 3.7.1, and cuda 9.0.
I have successfully installed tensorflow-gpu 1.13 on my pc in the python 3.5 environment. It seems tensorflow 2.0 is compatible with python 3.7 Ultimate Guide to TensorFlow 2.0 in Python?
TF2.0 was built with CUDA 10 in mind. source
You either can install CUDA 10.0 with cuDNN SDK (>= 7.4.1) or build Tensorflow from sourse.

How to fix 'ImportError: DLL load failed: The specified procedure could not be found.' while importing tensorflow-gpu?

I cannot import tensorflow-gpu==1.13.1 on python 3.6.0.
What i have already done:
Nvidia's drivers (i have GEFORCE 840M which is cuda supported with compute capability 5.0).
I installed Visual Studio 2017 Professional (did not select any specifications in workload).
I installed CUDA 10.1 (was having issues with Visual studio integration so i disabled it during the installation).
I pasted Cudnn 7.5.0 onto cuda's folders.
Restarted.
Pip installed tensorflow-gpu==1.13.1 on python 3.6.0.
but then i cannot import tensorflow at all it shows the error below.
>>> import tensorflow as tf
Traceback (most recent call last):
File "C:\Users\BenBouali\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\BenBouali\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\BenBouali\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\BenBouali\AppData\Local\Programs\Python\Python36\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\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\BenBouali\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\BenBouali\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\BenBouali\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\BenBouali\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\BenBouali\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\BenBouali\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\BenBouali\AppData\Local\Programs\Python\Python36\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\BenBouali\AppData\Local\Programs\Python\Python36\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.
>>>
Goal:
Obviously being able to import tensorflow and to import keras from the tensorflow library.
In my case this was an issue with detecting the correct CUDA Toolkit/cuDNN version with tensorflow-gpu==1.13.1.
After spending 2 hours on this I installed CUDA Toolkit 10.0 and set TF_CUDA_VERSION environment variable explicitly to 10 in the user env settings (Windows 10).

Tensorflow-alpha-gpu issue ImportError: DLL load failed: The specified module could not be found

I previously had cuda9.0_0 and cudnn7.1.4, I wanted to run tf-alpha in gpu,from this tf guide:https://www.tensorflow.org/install/gpu I found I need cuDNN SDK (>= 7.4.1) and cuda10.so I uninstalled previous versions from control panel and installed Cuda compilation tools, release 10.1, V10.1.105.So, I should have imported tf succesfully,but not,I got the error.
And if I had
conda list cudnn
I got
# packages in environment at F:\Anaconda:
#
# Name Version Build Channel
cudnn 7.1.4 cuda9.0_0 anaconda
Though I installed cuda 10 and cudnn succesfully verified by running
nvcc --version
I have anaconda installed and had previous cuda and I used tf 1.12.0 gpu ago and my gpu is nvidia 1050ti
import tensorflow as tf
I expected it to import tensorflow 2.0 alpha gpu version
The error I got:
Traceback (most recent call last):
File "F:\Anaconda\lib\site-packages\tensorflow\python
\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "F:\Anaconda\lib\site-packages\tensorflow\python
\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "F:\Anaconda\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 "F:\Anaconda\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "F:\Anaconda\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 "F:\Anaconda\lib\site-packages\tensorflow\__init__.py", line 27, in
<module>
from tensorflow._api.v2 import audio
File "F:\Anaconda\lib\site-packages\tensorflow\_api\v2\audio
\__init__.py", line 8, in <module>
from tensorflow.python.ops.gen_audio_ops import decode_wav
File "F:\Anaconda\lib\site-packages\tensorflow\python\__init__.py", line
49, in <module>
from tensorflow.python import pywrap_tensorflow
File "F:\Anaconda\lib\site-packages\tensorflow\python
\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "F:\Anaconda\lib\site-packages\tensorflow\python
\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "F:\Anaconda\lib\site-packages\tensorflow\python
\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "F:\Anaconda\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 "F:\Anaconda\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "F:\Anaconda\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.
my python version is 3.6.6
Note:
TensorFlow Version >= 1.13 requires CUDA 10.0 and TensorFlow Version < 1.13 (till TF 1.5) requires CUDA 9.0.
See Software requirements to know more https://www.tensorflow.org/install/gpu#software_requirements
Also requires NVIDIA® GPU card with CUDA® Compute Capability 3.5 or higher.
See Hardware requirements to know more
https://www.tensorflow.org/install/gpu#hardware_requirements
Hope this helps.

Tensorflow: ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory

I'm having problems in importing tensorflow in python3:
>>> import tensorflow as tf
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python3.5/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "/usr/lib/python3.5/imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "/usr/lib/python3.5/imp.py", line 342, in load_dynamic
return _load(spec)
ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory
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 am using Nvidia drivers version 381.09 beta, as version 375 has this bug: https://askubuntu.com/questions/896221/strange-artifacts-along-window-borders-after-waking-computer-from-sleep-mode?noredirect=1&lq=1
I have install CUDA 8.0 and cuDNN-v6.0:
rharish#rharish-GL552VW:~$ cd /usr/local
rharish#rharish-GL552VW:/usr/local$ ls
bin cuda etc include man share
computecpp cuda-8.0 games lib sbin src
Also, libcusolver.so.8.0 exists in /usr/local/cuda/lib64/:
libcusolver.so.8.0 in 'ls' output
I have uninstalled and reinstalled CUDA, cuDNN, and built tensorflow from sources. This problem has been occuring since updating the Nvidia drivers to version 381.09 beta. Any help?
Found the solution:
I reinstalled nvidia-381, CUDA-8.0 (using the runfile) and cuDNN 6.0. Then I added the following in my .bashrc:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64/
No need for reinstallation. Install nvidia-cuda-dev:
sudo apt install nvidia-cuda-dev
Install cuDNN (which you download from https://developer.nvidia.com/cudnn), and set LD_LIBRARY_PATH accordingly (to cuda/lib64).
You could be having this problem if you installed the latest version of CUDA (9.0). If this is the case, you'll have the libcusolver.so.9.0 file or directory on your computer, but not 8.0, so python can't find it to import. Tensorflow doesn't yet support CUDA 9.0 (as of Oct 18th 2017).
To fix this, install CUDA 8.0, which can be found here. You can find all their legacy releases at the bottom of the main download page.
I faced this error due to incompatibility between Tensorflow version with CUDA.
I had tensorflow_gpu-1.3.0, CUDA 9 and cuDNN 7 which are incompatible as per this https://www.tensorflow.org/install/source#tested_build_configurations
so I uninstalled tensorflow_gpu-1.3.0 and installed tensorflow_gpu-1.5.0 and it worked fine
In addition to having the paths correctly set, the version of Tensorflow you have installed must be compatible with the CUDA driver version you have in your system otherwise it won't work.
See the link