0

我正在尝试按照以下说明安装 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 提示符进行此安装。我也在 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 GPU installation Error Windows 10 Anaconda

但是,我确实确保我的路径指向正确的位置。

4

1 回答 1

0

好吧,我修复了它,但老实说,我不太确定我尝试过的哪些方法有效。

我又小心翼翼地完成了这些步骤。这仍然不起作用,尽管它可能已经解决了一些前兆问题。然后我进入路径环境变量并开始添加新路径,以便 Tensorflow 更容易在我的 Conda 环境中为 Keras/Tensorflow 找到东西。特别是,我查找了文件“pywrap_tensorflow”(它找不到的文件)并找到了它并添加了一个特定的路径。我不知道这是否有必要。但最后,它成功了,我现在可以运行 tensorflow gpu。

于 2017-07-24T05:51:38.310 回答