I am attempting to install tensorflow and tensorflow-gpu as per the following instructions:
https://www.tensorflow.org/install/install_windows#CommonInstallationProblems
I think I'm following them correctly, but I can't seem to get it to work. Both seem to install successfully if I run it from CMD prompt as Admin. And if I stop after installing just tensorflow, it works. But once I also install tensorflow-gpu (even though it seems to install successfully) I then get an error when I try to use tensorflow.
Here is the error I get:
Traceback (most recent call last):
File "D:\Anaconda3\envs\Keras\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "D:\Anaconda3\envs\Keras\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 919, 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 "D:\Anaconda3\envs\Keras\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.1.4\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "D:\Anaconda3\envs\Keras\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "D:\Anaconda3\envs\Keras\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "D:\Anaconda3\envs\Keras\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 "<input>", line 1, in <module>
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.1.4\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "D:\Anaconda3\envs\Keras\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.1.4\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "D:\Anaconda3\envs\Keras\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.1.4\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "D:\Anaconda3\envs\Keras\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "D:\Anaconda3\envs\Keras\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "D:\Anaconda3\envs\Keras\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 919, 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 "D:\Anaconda3\envs\Keras\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Program Files\JetBrains\PyCharm Community Edition 2017.1.4\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
File "D:\Anaconda3\envs\Keras\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "D:\Anaconda3\envs\Keras\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "D:\Anaconda3\envs\Keras\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_problems
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
I am doing this install via a CMD prompt running as administrator with activate running. I've also tried this in PyCharm to similar results.
The instructions say I should install regular tensorflow even if I plan to use tensorflow-gpu.
However I tried just installing tensorflow-gpu, and while the install says it succeeds, I still get the above error upon running "import tensorflow as tf".
So the only way I can seem to get this to work is if I do not install tensorflow-gpu. However, the whole reason I'm doing this is so I can utilize my NVIDIA GPU with Keras/Tensorflow.
Note: I did install CUDA Toolkit 8.0 and cuDNN v5.1, though that process is messy so it's possible I did something wrong. I see no easy way to verify it.
For kicks, I tried installing tensorflow-gpu first and then I get the following error when installing just tensorflow -- a permission error despite being admin:
Exception:
Traceback (most recent call last):
File "D:\Anaconda3\envs\Keras\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "D:\Anaconda3\envs\Keras\lib\site-packages\pip\commands\install.py", line 342, in run
prefix=options.prefix_path,
File "D:\Anaconda3\envs\Keras\lib\site-packages\pip\req\req_set.py", line 784, in install
**kwargs
File "D:\Anaconda3\envs\Keras\lib\site-packages\pip\req\req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "D:\Anaconda3\envs\Keras\lib\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "D:\Anaconda3\envs\Keras\lib\site-packages\pip\wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "D:\Anaconda3\envs\Keras\lib\site-packages\pip\wheel.py", line 323, in clobber
shutil.copyfile(srcfile, destfile)
File "D:\Anaconda3\envs\Keras\lib\shutil.py", line 121, in copyfile
with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: 'D:\\Anaconda3\\envs\\Keras\\Lib\\site-packages\\numpy\\core\\multiarray.cp35-win_amd64.pyd'
This question is a similar problem: Tensorflow GPU installation Error Windows 10 Anaconda
However, I did make sure my path was pointing to the correct place.
Well, I fixed it, though to be honest, I'm not quite sure which of the things I tried worked.
I carefully went through the steps again. This still didn't work, though it may have fixed some precursor problems. Then I went into the Path Environment Variable and started adding new paths so that it would be easier for Tensorflow to find stuff in my Conda environment for Keras/Tensorflow. In particularly, I looked up the file "pywrap_tensorflow" (the file that it couldn't find) and found it and added a specific path. I have no idea if this was necessary or not. But in the end, it worked and I can now run tensorflow gpu.