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

ImportError: DLL load failed & ImportError: No module named '_pywrap_tensorflow_internal' #8161

Closed
ghost opened this issue Mar 7, 2017 · 19 comments
Assignees

Comments

@ghost
Copy link

@ghost ghost commented Mar 7, 2017

Dear friends:

import tensorflow as tf
Traceback (most recent call last):
File "D:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_intern
al.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "D:\Python35\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
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: 找不到指定的模块。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", l
ine 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "D:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_intern
al.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "D:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_intern
al.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow_internal')
File "D:\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 "", line 1, in
File "D:\Python35\lib\site-packages\tensorflow_init_.py", line 24, in
from tensorflow.python import *
File "D:\Python35\lib\site-packages\tensorflow\python_init_.py", line 51, i
n
from tensorflow.python import pywrap_tensorflow
File "D:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", l
ine 52, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "D:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_intern
al.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "D:\Python35\lib\importlib_init_.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 986, in _gcd_import
File "", line 969, in _find_and_load
File "", line 958, in _find_and_load_unlocked
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: 找不到指定的模块。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", l
ine 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "D:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_intern
al.py", line 21, in
_pywrap_tensorflow_internal = swig_import_helper()
File "D:\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow_intern
al.py", line 20, in swig_import_helper
return importlib.import_module('pywrap_tensorflow_internal')
File "D:\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://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_st
arted/os_setup.md#import_error

for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.


previous trying:

  1. installing Microsoft Visual C++ 2015 Redistributable Update 3 (x64 version);
  2. check the env variables path of CUDA and cudnn is C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5 and D:\software\caffe\caffe-installer\cuda;
  3. C:\Windows\System32 has MSVCP140.dll;

Environment info

Operating System: win7 + python3.5
install tensorflow command is

python35 -m pip install --upgrade D:\downloads\tensorflow_gpu-1.0.0-cp35-cp35m-win_amd64.whl

Installed version of CUDA and cuDNN:
CUDA 7.5
cuDNN 7.0

Thand you very much:-)

@mrry

This comment has been minimized.

Copy link
Member

@mrry mrry commented Mar 7, 2017

Can you try upgrading to CUDA 8.0? We don't support CUDA 7.5 in TensorFlow 1.0.

@ghost

This comment has been minimized.

Copy link
Author

@ghost ghost commented Mar 9, 2017

Dear Mr. mrry, you perfectly solved my problem, thank you very very much!

@mrry

This comment has been minimized.

Copy link
Member

@mrry mrry commented Mar 9, 2017

You're welcome, and I'm glad to hear it!

@mrry mrry closed this Mar 9, 2017
@jiayi-wei

This comment has been minimized.

Copy link

@jiayi-wei jiayi-wei commented Apr 7, 2017

@ry I also met the same problem "No module named pywrap_tensorflow_internal".
I cannot update CUDA7.5 to 8.0 due to some reasons. Hence, have to install with sources. I have done everything as this Page say. However, when i import tensorflow I have this. Can I install TF1.0 or solve this problem?
Really appreciate for any advises!

@anonym24

This comment has been minimized.

Copy link

@anonym24 anonym24 commented Apr 20, 2017

but if I didn't install gpu version of tensorflow why this error happens
https://www.tensorflow.org/install/install_linux says we don't require cuda if don't install tensorflow gpu version

@anonym24

This comment has been minimized.

Copy link

@anonym24 anonym24 commented Apr 20, 2017

anyway I have 8, but it still gives that error

@nwertzberger

This comment has been minimized.

Copy link

@nwertzberger nwertzberger commented Apr 24, 2017

+1 installing cpu only version gives me the same issue on Windows.

ImportError: Traceback (most recent call last):
  File "C:\Users\XXXX\AppData\Roaming\Python\Python35\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\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 914, 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\XXXX\AppData\Roaming\Python\Python35\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\XXXX\AppData\Roaming\Python\Python35\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\XXXX\AppData\Roaming\Python\Python35\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\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'
@zeka0

This comment has been minimized.

Copy link

@zeka0 zeka0 commented Jun 2, 2017

Happens to me as well.
I have installed CUDA8, CuDNN 5.1.
Any solutions?

EDIT:
I found this excellent guide:
https://nitishmutha.github.io/tensorflow/2017/01/22/TensorFlow-with-gpu-for-windows.html
solves my problem.

@mrry

This comment has been minimized.

Copy link
Member

@mrry mrry commented Jun 2, 2017

Hi folks! We've posted a script that you can run, and it will give you some suggestions about how to fix your TensorFlow on Windows installation. It's available here:

https://gist.github.com/mrry/ee5dbcfdd045fa48a27d56664411d41c

@bansankit

This comment has been minimized.

Copy link

@bansankit bansankit commented Jun 16, 2017

Hi Mrry,

i am NOT using GPU version on windows 7.
Then WHY am i getting these error related to CUDA??

Is my system not compatible to run tensorflow??
Please update.
awaiting ur respose..

1 similar comment
@bansankit

This comment has been minimized.

Copy link

@bansankit bansankit commented Jun 16, 2017

Hi Mrry,

i am NOT using GPU version on windows 7.
Then WHY am i getting these error related to CUDA??

Is my system not compatible to run tensorflow??
Please update.
awaiting ur respose..

@erinjerri

This comment has been minimized.

Copy link

@erinjerri erinjerri commented Jul 9, 2017

I have the same errorss as @nwertzberger . I also have these errors related to Anaconda that keep coming up during a Windows installation with the latest version of CUDA on Windows 10. From writing source activate envname because (activate tensorflow-gpu won't work) it prompts me with the other command, I get this trace:

Traceback (most recent call last): File "C:\Program Files\Anaconda3\Scripts\conda-script.py", line 5, in <module> sys.exit(conda.cli.main()) File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\main.py", line 15 4, in main activate.main() File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\activate.py", lin e 160, in main prefix = prefix_from_arg(sys.argv[3], shelldict=shelldict) File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\activate.py", lin e 60, in prefix_from_arg prefix = locate_prefix_by_name(context, arg.replace('/', os.path.sep)) File "C:\Program Files\Anaconda3\lib\site-packages\conda\base\context.py", lin e 538, in locate_prefix_by_name raise CondaEnvironmentNotFoundError(name) conda.exceptions.CondaEnvironmentNotFoundError: Could not find environment: envn ame . You can list all discoverable environments with conda info --envs.

I get this trace when running in python shell import tensorflow as tf
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\XXXX\AppData\Roaming\Python\Python36\site-packages\tensorflow\__init__.py", line 24, in <module> from tensorflow.python import * File "C:\Users\XXXX\AppData\Roaming\Python\Python36\site-packages\tensorflow\python\__init__.py", line 47, in <module> import numpy as np

Thoughts on how to fix? I always seem to have problems with Anaconda, whether on Mac or PC.

@erinjerri

This comment has been minimized.

Copy link

@erinjerri erinjerri commented Jul 9, 2017

@mrry any thoughts? It seems to be a common problem with the roaming Python error. I also tried using other pip installs to no avail: https://stackoverflow.com/questions/44991377/trouble-installing-tensorflow-on-windows-10-error-trace-related-to-anaconda

@cloudqi1024

This comment has been minimized.

Copy link

@cloudqi1024 cloudqi1024 commented Jul 13, 2017

Hi all, I just want to thank this thread that save the day! My env is Windows 10x64 with tensorflow-gpu version, downgrading cuDNN from V6.0 to V5.1 did the job exactly! I

@shivam04

This comment has been minimized.

Copy link

@shivam04 shivam04 commented Aug 7, 2017

ile "C:\Users\xxx\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\p
ython\pywrap_tensorflow.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\xxx\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\p
ython\pywrap_tensorflow_internal.py", line 35, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\xxx\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\p
ython\pywrap_tensorflow_internal.py", line 30, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, descript
ion)
File "C:\Users\xxx\Anaconda3\envs\tensorflow\lib\imp.py", line 242, in load
_module
return load_dynamic(name, filename, file)
File "C:\Users\xxx\Anaconda3\envs\tensorflow\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 "", line 1, in
File "C:\Users\xxx\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow_
init_.py", line 24, in
from tensorflow.python import *
File "C:\Users\xxx\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\p
ython_init_.py", line 51, in
from tensorflow.python import pywrap_tensorflow
File "C:\Users\xxx\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\p
ython\pywrap_tensorflow.py", line 52, in
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\xxx\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\p
ython\pywrap_tensorflow.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\xxx\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\p
ython\pywrap_tensorflow_internal.py", line 35, in
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\xxx\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\p
ython\pywrap_tensorflow_internal.py", line 30, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, descript
ion)
File "C:\Users\xxx\Anaconda3\envs\tensorflow\lib\imp.py", line 242, in load
_module
return load_dynamic(name, filename, file)
File "C:\Users\xxx\Anaconda3\envs\tensorflow\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/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.

@mrry

This comment has been minimized.

Copy link
Member

@mrry mrry commented Aug 8, 2017

@shivam04 Did you try running this script to diagnose common issues?

https://gist.github.com/mrry/ee5dbcfdd045fa48a27d56664411d41c

If it doesn't point to a solution, please open a new issue with the details!

@vinuvish

This comment has been minimized.

Copy link

@vinuvish vinuvish commented Sep 16, 2017

@mrry hi
after installing the DLL file still im getting the error

@riturajsoni

This comment has been minimized.

Copy link

@riturajsoni riturajsoni commented Feb 8, 2018

I have installed Anaconda + tensor flow + CUDA on my system

Anaconda version installed : Anaconda3-4.2.0-Windows-x86_64
tensorflow for gpu is installed using pip install command.
Cuda version installed as: cuda_9.0.176_win10 and its patch is also installed
Then files from cudnn like bin, include, lib copied to installation path
The graphics card is NVIDIA GeForce 820M
but when I run simple python scsript
import tensorflow as tf
with tf.device('/gpu:0'):
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)

with tf.Session() as sess:
print (sess.run(c))

This error appears:

runfile('C:/Users/rituraj/Desktop/New folder/check.py', wdir='C:/Users/rituraj/Desktop/New folder')
Traceback (most recent call last):

File "", line 1, in
runfile('C:/Users/rituraj/Desktop/New folder/check.py', wdir='C:/Users/rituraj/Desktop/New folder')

File "C:\Users\rituraj\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)

File "C:\Users\rituraj\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/rituraj/Desktop/New folder/check.py", line 17, in
print (sess.run(c))

File "C:\Users\rituraj\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 895, in run
run_metadata_ptr)

File "C:\Users\rituraj\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1128, in _run
feed_dict_tensor, options, run_metadata)

File "C:\Users\rituraj\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1344, in _do_run
options, run_metadata)

File "C:\Users\rituraj\Anaconda3\lib\site-packages\tensorflow\python\client\session.py", line 1363, in _do_call
raise type(e)(node_def, op, message)

InvalidArgumentError: Cannot assign a device for operation 'MatMul_9': Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0 ]. Make sure the device specification refers to a valid device.
[[Node: MatMul_9 = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/device:GPU:0"](a_9, b_9)]]

Caused by op 'MatMul_9', defined at:
File "C:\Users\rituraj\Anaconda3\lib\site-packages\spyder\utils\ipython\start_kernel.py", line 223, in
main()
File "C:\Users\rituraj\Anaconda3\lib\site-packages\spyder\utils\ipython\start_kernel.py", line 219, in main
kernel.start()
File "C:\Users\rituraj\Anaconda3\lib\site-packages\ipykernel\kernelapp.py", line 474, in start
ioloop.IOLoop.instance().start()
File "C:\Users\rituraj\Anaconda3\lib\site-packages\zmq\eventloop\ioloop.py", line 162, in start
super(ZMQIOLoop, self).start()
File "C:\Users\rituraj\Anaconda3\lib\site-packages\tornado\ioloop.py", line 887, in start
handler_func(fd_obj, events)
File "C:\Users\rituraj\Anaconda3\lib\site-packages\tornado\stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "C:\Users\rituraj\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 440, in _handle_events
self._handle_recv()
File "C:\Users\rituraj\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 472, in _handle_recv
self._run_callback(callback, msg)
File "C:\Users\rituraj\Anaconda3\lib\site-packages\zmq\eventloop\zmqstream.py", line 414, in _run_callback
callback(*args, **kwargs)
File "C:\Users\rituraj\Anaconda3\lib\site-packages\tornado\stack_context.py", line 275, in null_wrapper
return fn(*args, **kwargs)
File "C:\Users\rituraj\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 276, in dispatcher
return self.dispatch_shell(stream, msg)
File "C:\Users\rituraj\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 228, in dispatch_shell
handler(stream, idents, msg)
File "C:\Users\rituraj\Anaconda3\lib\site-packages\ipykernel\kernelbase.py", line 390, in execute_request
user_expressions, allow_stdin)
File "C:\Users\rituraj\Anaconda3\lib\site-packages\ipykernel\ipkernel.py", line 196, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "C:\Users\rituraj\Anaconda3\lib\site-packages\ipykernel\zmqshell.py", line 501, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "C:\Users\rituraj\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2717, in run_cell
interactivity=interactivity, compiler=compiler, result=result)
File "C:\Users\rituraj\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2827, in run_ast_nodes
if self.run_code(code, result):
File "C:\Users\rituraj\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
runfile('C:/Users/rituraj/Desktop/New folder/check.py', wdir='C:/Users/rituraj/Desktop/New folder')
File "C:\Users\rituraj\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "C:\Users\rituraj\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/rituraj/Desktop/New folder/check.py", line 12, in
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
File "C:\Users\rituraj\Anaconda3\lib\site-packages\tensorflow\python\ops\math_ops.py", line 2022, in matmul
a, b, transpose_a=transpose_a, transpose_b=transpose_b, name=name)
File "C:\Users\rituraj\Anaconda3\lib\site-packages\tensorflow\python\ops\gen_math_ops.py", line 2799, in _mat_mul
name=name)
File "C:\Users\rituraj\Anaconda3\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "C:\Users\rituraj\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 3160, in create_op
op_def=op_def)
File "C:\Users\rituraj\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py", line 1625, in init
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access

InvalidArgumentError (see above for traceback): Cannot assign a device for operation 'MatMul_9': Operation was explicitly assigned to /device:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0 ]. Make sure the device specification refers to a valid device.
[[Node: MatMul_9 = MatMul[T=DT_FLOAT, transpose_a=false, transpose_b=false, _device="/device:GPU:0"](a_9, b_9)]]

It is not detecting the gpu.
Please suggest solution for it.

@pilo21

This comment has been minimized.

Copy link

@pilo21 pilo21 commented Nov 18, 2018

i had similar problem
343, in load_dynamic
return _load(spec)
ImportError: DLL load failed with error code -1073741795

Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

why if i use cpu tensor i need cuda etc?
By the way,i tryed to install cuda and cudnn and nothing changed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
You can’t perform that action at this time.