安装 Tensorflow-GPU 时出错
Error installing Tensorflow-GPU
我正尝试按照以下说明安装 tensorflow 和 tensorflow-gpu:
https://www.tensorflow.org/install/install_windows#CommonInstallationProblems
我认为我正确地遵循了它们,但我似乎无法让它发挥作用。如果我以管理员身份从 CMD 提示符 运行 它,两者似乎都安装成功。如果我在安装 tensorflow 后停止,它就可以工作。但是一旦我也安装了 tensorflow-gpu(即使它似乎安装成功),当我尝试使用 tensorflow 时我会收到错误消息。
这是我得到的错误:
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.
我正在通过 CMD 提示符 运行ning 以管理员身份执行此安装并激活 运行ning。我也在 PyCharm 中尝试过类似的结果。
说明说即使我打算使用 tensorflow-gpu,我也应该安装常规的 tensorflow。
但是我尝试只安装 tensorflow-gpu,虽然安装说它成功了,但我在 运行 宁 "import tensorflow as tf" 时仍然收到上述错误。
所以我似乎唯一能让它工作的方法就是不安装 tensorflow-gpu。然而,我这样做的全部原因是我可以利用我的 NVIDIA GPU Keras/Tensorflow。
注意:我确实安装了 CUDA Toolkit 8.0 和 cuDNN v5.1,尽管这个过程很混乱,所以我可能做错了什么。我认为没有简单的方法来验证它。
为了好玩,我尝试先安装 tensorflow-gpu,然后在仅安装 tensorflow 时出现以下错误——尽管是管理员权限错误:
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'
这个问题是类似的问题:
但是,我确实确保我的路径指向正确的位置。
好吧,我修复了它,但老实说,我不太确定我尝试过的哪些方法有效。
我又仔细的把步骤做了一遍。这仍然没有用,尽管它可能已经解决了一些先兆问题。然后我进入路径环境变量并开始添加新路径,这样 Tensorflow 就可以更容易地在我的 Keras/Tensorflow 的 Conda 环境中找到东西。特别是,我查找了文件 "pywrap_tensorflow"(它找不到的文件)并找到了它并添加了一个特定的路径。我不知道这是否有必要。但最后,它奏效了,我现在可以 运行 tensorflow gpu。
我正尝试按照以下说明安装 tensorflow 和 tensorflow-gpu:
https://www.tensorflow.org/install/install_windows#CommonInstallationProblems
我认为我正确地遵循了它们,但我似乎无法让它发挥作用。如果我以管理员身份从 CMD 提示符 运行 它,两者似乎都安装成功。如果我在安装 tensorflow 后停止,它就可以工作。但是一旦我也安装了 tensorflow-gpu(即使它似乎安装成功),当我尝试使用 tensorflow 时我会收到错误消息。
这是我得到的错误:
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.
我正在通过 CMD 提示符 运行ning 以管理员身份执行此安装并激活 运行ning。我也在 PyCharm 中尝试过类似的结果。
说明说即使我打算使用 tensorflow-gpu,我也应该安装常规的 tensorflow。
但是我尝试只安装 tensorflow-gpu,虽然安装说它成功了,但我在 运行 宁 "import tensorflow as tf" 时仍然收到上述错误。
所以我似乎唯一能让它工作的方法就是不安装 tensorflow-gpu。然而,我这样做的全部原因是我可以利用我的 NVIDIA GPU Keras/Tensorflow。
注意:我确实安装了 CUDA Toolkit 8.0 和 cuDNN v5.1,尽管这个过程很混乱,所以我可能做错了什么。我认为没有简单的方法来验证它。
为了好玩,我尝试先安装 tensorflow-gpu,然后在仅安装 tensorflow 时出现以下错误——尽管是管理员权限错误:
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'
这个问题是类似的问题:
但是,我确实确保我的路径指向正确的位置。
好吧,我修复了它,但老实说,我不太确定我尝试过的哪些方法有效。
我又仔细的把步骤做了一遍。这仍然没有用,尽管它可能已经解决了一些先兆问题。然后我进入路径环境变量并开始添加新路径,这样 Tensorflow 就可以更容易地在我的 Keras/Tensorflow 的 Conda 环境中找到东西。特别是,我查找了文件 "pywrap_tensorflow"(它找不到的文件)并找到了它并添加了一个特定的路径。我不知道这是否有必要。但最后,它奏效了,我现在可以 运行 tensorflow gpu。