Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tensorflow 2.1.0 - DLL load failed #35618

Closed
ReinforcedMan opened this issue Jan 6, 2020 · 36 comments
Closed

Tensorflow 2.1.0 - DLL load failed #35618

ReinforcedMan opened this issue Jan 6, 2020 · 36 comments
Assignees
Labels
stat:awaiting response Status - Awaiting response from author subtype:windows Windows Build/Installation Issues TF 2.1 for tracking issues in 2.1 release type:build/install Build and install issues

Comments

@ReinforcedMan
Copy link

ReinforcedMan commented Jan 6, 2020

System information

  • OS Platform and Distribution: Windows 10
  • TensorFlow installed from (source or binary): pip install tensorflow-gpu==2.1.0rc2
  • TensorFlow version (use command below): 2.1.0rc2
  • Python version: 3.7.4
  • CUDA/cuDNN version: CUDA 10.1, cuDNN 7.6.5 associated with CUDA 10.1
  • GPU model and memory: GTX 1060 6GB

Describe the problem

I installed the pre-release using pip install tensorflow-gpu==2.1.0rc2. I installedCUDA 10.1 with cuDNN 7.6.5. When running import tensorflow, I get a

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

It probably means there is an issue with the CUDA installation, or a bug somewhere. Tensorflow 2.1.0 is supposed to be compatible with CUDA 10.1.

In my system environment variables, path contains:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\extras\CUPTI\lib64
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\include

Source code / logs

File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.2.3\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
  module = self._system_import(name, *args, **kwargs)
File "C:\Users\johndoe\AppData\Local\Continuum\anaconda3\envs\dummy_env_name\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
  _pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\johndoe\AppData\Local\Continuum\anaconda3\envs\dummy_env_name\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\johndoe\AppData\Local\Continuum\anaconda3\envs\dummy_env_name\lib\imp.py", line 242, in load_module
  return load_dynamic(name, filename, file)
File "C:\Users\johndoe\AppData\Local\Continuum\anaconda3\envs\dummy_env_name\lib\imp.py", line 342, in load_dynamic
  return _load(spec)
ImportError: DLL load failed: The specified module could not be found.

@geetachavan1 geetachavan1 added the TF 2.1 for tracking issues in 2.1 release label Jan 6, 2020
@ravikyram ravikyram self-assigned this Jan 7, 2020
@ravikyram
Copy link
Contributor

@ReinforcedMan
Did you follow the instruction from TensorFlow website. You can have a look on similar issue #22794 and #10033 . let us know if that helps. Looks like you need to add path for CUDA and CuDNN.Thanks!

@ravikyram ravikyram added type:build/install Build and install issues stat:awaiting response Status - Awaiting response from author labels Jan 7, 2020
@ReinforcedMan
Copy link
Author

ReinforcedMan commented Jan 7, 2020

@ravikyram
I did not follow the instructions to build the package. I installed the 2.1.0rc2 version from pipy, and couldn't get it to work with any cuda version (neither 10.0 or 10.1), even though it is supposed to support cuda 10.1 as stated in the release notes.

When trying to build the package like you linked, I get an error in the c++ code when building with bazel.

I don't have any more days to allocate to this and am thus giving up. I'll wait for a clean 2.1.0 release. Thank you for your help.

@tensorflow-bot
Copy link

tensorflow-bot bot commented Jan 7, 2020

Are you satisfied with the resolution of your issue?
Yes
No

@ReinforcedMan ReinforcedMan reopened this Jan 8, 2020
@ReinforcedMan
Copy link
Author

ReinforcedMan commented Jan 8, 2020

I'm reopening since the problem still appears with the version of tensorflow 2.1.0 on pipy that you get with

pip install tensorflow

I have cuda 10.1 and cudnn 7.6.5 for cuda 10.1.
In my system path I have bin/, libnvvp/ and CUPTI\lib64. It worked perfectly for tensorflow 2.0.0, and I adapted the paths for the new cuda version.

@mihaimaruseac
Copy link
Collaborator

Can you try using tensorflow instead of tensorflow-gpu? It should have the GPU build too (and if it works it will point out a failure in the way we release these two)

@ReinforcedMan
Copy link
Author

I tried both

pip install tensorflow
pip install tensorflow-gpu

but neither seem to be working for me ...

Also: Maybe something of note is that in the test build of the pipy version the CUPTI path is set as pointing to 10.1/../libx64, where it seems to have been renamed to 10.1/../lib64 without the x in the cuda installation.

@tensorflowbutler tensorflowbutler removed the stat:awaiting response Status - Awaiting response from author label Jan 9, 2020
@CuspMe
Copy link

CuspMe commented Jan 9, 2020

i fix this by downgrading to

pip install tensorflow=2.0

@mihaimaruseac
Copy link
Collaborator

@ReinforcedMan can you make a symlink from CUPT/libx64 to CUPT/lib64?

@ReinforcedMan
Copy link
Author

@mihaimaruseac I already added the two versions in my Path variable, I don't think that's the cause of it. I was just saying that in the tensorflow test build I think you guys might have the wrong path, but it still works as you also give the CUDA/v10.0/../libx64 in addition to the 10.1.

Sorry for being unclear.

@nectario
Copy link

I am having the same issue when I pip install tensorflow. I do not have an nvidia graphics card and want to use a CPU tensorflow, NOT GPU. I get:

ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.

@nectario
Copy link

I am using an HP laptop from 2 years ago.

@nectario
Copy link

Is there a workaround for this issue??

@mihaimaruseac
Copy link
Collaborator

@nectario try tensorflow-cpu package? If the issue still persists, I would recommend opening a new one and filling in the template as it looks like you have a different issue.

@nectario
Copy link

This happens even when I install tensorflow-cpu. Below is the complete stack trace:

Traceback (most recent call last):
File "C:\Development\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Development\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Development\Python\Python37\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:\Development\Python\Python37\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Development\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 "C:/Development/Projects/TensorFlow_2.0_Hierarchical_Attention/QuestionAnswerContextAttention.py", line 8, in
import tensorflow as tf
File "C:\Development\Python\Python37\lib\site-packages\tensorflow_init_.py", line 101, in
from tensorflow_core import *
File "C:\Development\Python\Python37\lib\site-packages\tensorflow_core_init_.py", line 40, in
from tensorflow.python.tools import module_util as module_util
File "C:\Development\Python\Python37\lib\site-packages\tensorflow_init
.py", line 50, in getattr
module = self.load()
File "C:\Development\Python\Python37\lib\site-packages\tensorflow_init
.py", line 44, in _load
module = importlib.import_module(self.name)
File "C:\Development\Python\Python37\lib\importlib_init
.py", line 127, in import_module
return _bootstrap.gcd_import(name[level:], package, level)
File "C:\Development\Python\Python37\lib\site-packages\tensorflow_core\python_init
.py", line 49, in
from tensorflow.python import pywrap_tensorflow
File "C:\Development\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 74, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Development\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Development\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Development\Python\Python37\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:\Development\Python\Python37\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "C:\Development\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.

@nectario
Copy link

The issue seems to be the same and it happens on two completely different computers of mine.

@mihaimaruseac
Copy link
Collaborator

Please identify which DLL fails to load and please open a different issue as they look to be different

@nectario
Copy link

Done.
Issue: #35749

@galocen
Copy link

galocen commented Jan 11, 2020

I posted my solution in the @nectario post.
#35749 (comment)

@ID-ao
Copy link

ID-ao commented Jan 11, 2020

The solution proposed by @galocen in #35749 seems to resolve the issue for me.

I solved it today downloading and installing visual studio 2015-2019 x86 and x64 from here

@ravikyram ravikyram added the subtype:windows Windows Build/Installation Issues label Jan 13, 2020
@ravikyram
Copy link
Contributor

@ReinforcedMan

Please, let us know if the issue still persists. Thanks!

@ravikyram ravikyram added the stat:awaiting response Status - Awaiting response from author label Jan 13, 2020
@jingweimo
Copy link

@ReinforcedMan Are you using vs2015 or a higher version?

@jingweimo
Copy link

@ravikyram @mihaimaruseac

The solution proposed by @galocen in #35749 solves the issue for me. So if anyone has this issue,
make sure to download the latest microsoft visual c++ redistributable from here.

Thank you all for your help, this issue is now solved, closing it.

@aeropia: Your issue seems different, feel free to open a new one describing it in more details.

It also solved my problem!!

@Ansreng360
Copy link

Installing the redistributable didn't solve the error for me. Does anyone else have the same problem?

@mihaimaruseac
Copy link
Collaborator

@Ansreng360

There are at least 4 possible scenarios:

  • You need to install the MSVC 2019 redistributable
  • 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 identify which is your case and open a new issue only if there is a fifth case

@bduan007
Copy link

bduan007 commented Feb 8, 2020

I had similar DLL load failed error when I was importing tensorflow 2.1 in my latest Anaconda environment. I tried several times from creating the virtual environment to installation tensorflow 2.1 without success. The installation process went through fine without any error message. The tensorflow 2.0 works fine but not tensorflow 2.1. Thanks for any insight!

@ravikyram
Copy link
Contributor

@bduan007

Can you please raise a new issue by filling build/installation issue template.Thanks!

@bduan007
Copy link

bduan007 commented Feb 10, 2020 via email

@1vecera
Copy link

1vecera commented Feb 11, 2020

@ravikyram @mihaimaruseac
The solution proposed by @galocen in #35749 solves the issue for me. So if anyone has this issue,
make sure to download the latest microsoft visual c++ redistributable from here.
Thank you all for your help, this issue is now solved, closing it.
@aeropia: Your issue seems different, feel free to open a new one describing it in more details.

It also solved my problem!!

@ravikyram @mihaimaruseac

The solution proposed by @galocen in #35749 solves the issue for me. So if anyone has this issue,
make sure to download the latest microsoft visual c++ redistributable from here.

Thank you all for your help, this issue is now solved, closing it.

@aeropia: Your issue seems different, feel free to open a new one describing it in more detail.

I don't think this is closed. Tensorflow PyPI distribution should not rely on a manual install of some Microsoft software utility that needs admin rights to install. (Scalability and so)

@mihaimaruseac
Copy link
Collaborator

We cannot bundle everything ourselves (especially so since some packages have licenses prohibiting bundling together). So you have to install dependencies out of bound.

@YumainOB
Copy link

I ran through this issue too during an update of mt TF environment. The installation of latest Visual C redistribuable tools solved the issue for me too obviously.
This solution is well documented in build from source for windows https://www.tensorflow.org/install/source_windows#install_visual_c_build_tools_2019
BUT it should also be documented as a requirement in the PIP based installation process and even better checked during the pip install if it is possible to echoe an explicite warning if msvcp140_1.dll has not been found. It would save time and nerves on many people that are not building from sources.

@Zaaachary
Copy link

i fix this by downgrading to

pip install tensorflow=2.0

problem solved!

@mihaimaruseac
Copy link
Collaborator

Solution is to download the latest microsoft visual c++ redistributable from here.

Locking conversation to prevent spammy "works for me" and fake solutions of "downgrade to TF 2.0"

@tensorflow tensorflow locked as resolved and limited conversation to collaborators Mar 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
stat:awaiting response Status - Awaiting response from author subtype:windows Windows Build/Installation Issues TF 2.1 for tracking issues in 2.1 release type:build/install Build and install issues
Projects
None yet
Development

No branches or pull requests