安装tensorflow GPU

问题描述 投票:0回答:4

我正在尝试在win10上安装tensorflow gpu。我的步骤:

  1. 安装Python 3.5.2
  2. 安装Nvidia CUDA(v9)+ cudnn
  3. 在prog.files目录下复制cudnn文件NVIDIA GPU Computing Toolkit
  4. 安装tensorflow gpu(pip3 install --upgrade tensorflow-gpu) C:\ Python> python Python 3.5.2(v3.5.2:4def2a2901a5,2016年6月25日,22:18:55)[MSC v.1900 64 bit(AMD64)]在win32上输入“help”,“copyright”,“信用“或”许可“以获取更多信息。 跟踪tensorflow为tf Traceback(最近一次调用last):文件“C:\ Python \ lib \ site-packages \ tensorflow \ python \ pywrap_tensorflow_internal.py”,第18行,在swig_import_helper中返回importlib.import_module(mname)文件“C: \ Python \ lib \ importlib__init __。py“,第126行,在import_module中返回_bootstrap._gcd_import(name [level:],package,level)文件”“,第986行,在_gcd_import文件”“,第969行,在_find_and_load文件中” “,第958行,_find_and_load_unlocked文件”“,第666行,在_load_unlocked文件”“,第577行,在module_from_spec文件”“,第906行,在create_module文件”“,第222行,在_call_with_frames_removed中ImportError:DLL加载失败:Не найденуказанныймодуль。 During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module> from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module> _pywrap_tensorflow_internal = swig_import_helper() File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper return importlib.import_module('_pywrap_tensorflow_internal') File "C:\Python\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 "<stdin>", line 1, in <module> File "C:\Python\lib\site-packages\tensorflow\__init__.py", line 24, in <module> from tensorflow.python import * File "C:\Python\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module> from tensorflow.python import pywrap_tensorflow File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in <module> raise ImportError(msg) ImportError: Traceback (most recent call last): File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper return importlib.import_module(mname) File "C:\Python\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 906, in create_module File "<frozen importlib._bootstrap>", 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 "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module> from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module> _pywrap_tensorflow_internal = swig_import_helper() File "C:\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper return importlib.import_module('_pywrap_tensorflow_internal') File "C:\Python\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.

如果我在没有GPU的情况下安装tensorflow-一切正常。

python tensorflow tensorflow-gpu
4个回答
2
投票

遵循TensorFlow install instructions非常重要,从而选择正确的版本:

  • CUDA®Toolkit8.0。有关详细信息,请参阅NVIDIA的文档确保将相关的Cuda路径名附加到%PATH%环境变量,如NVIDIA文档中所述。
  • 与CUDA Toolkit 8.0相关的NVIDIA驱动程序。
  • cuDNN v6或v6.1。有关详细信息,请参阅NVIDIA的文档。请注意,cuDNN通常安装在与其他CUDA DLL不同的位置。确保将安装cuDNN DLL的目录添加到%PATH%环境变量中。
  • 具有CUDA Compute Capability 3.0或更高版本的GPU卡。有关支持的GPU卡列表,请参阅NVIDIA文档。

目前,CUDA Toolkit的最新版本是9.0,但对于Tensorflow,您需要版本8,可在CUDA toolkit archive上找到:https://developer.nvidia.com/cuda-80-ga2-download-archive

对于cuDNN(深度神经网络库),您需要选择cuDNN v6,而不是最新版本的v7:https://developer.nvidia.com/rdp/cudnn-download

最后,确保将Windows %PATH%变量放入CUDA bin目录(dll库所在的位置)。

然后,您可以安装tensorflow:

pip3 install --upgrade tensorflow-gpu

如果它还不起作用,您可能需要先重新启动。


0
投票

目前,支持这些版本。不要尝试安装更新的版本。

Visual Studio 2015. CUDA 9.0。 cuDNN 7.0(确保将dll复制到正确的目录)。 Python 3.5。

然后你可以安装tf


0
投票

这就是我如何解决它,如果你使用pip或pip3,你第一次成功的机会就会减少。

  • 卸载Python,CUDA,CuNN,Tensorflow-gpu(如果已安装)
  • 安装ANACONDA或MINICONDA
  • 打开ANACONDA提示符并运行以下命令: conda create --name tf_gpu tensorflow-gpu
  • 这将创建一个环境tf_gpu,它将安装Python,CUDA,CuNN和Tensorflow的所有兼容版本
  • 安装完所有软件包后,打开ANACONDA提示符并输入以下命令 conda激活tf_gpu
  • 这会将conda'(base)'更改为'(tf_gpu)'环境
  • 然后像往常一样键入python以激活python提示符
  • 如果要停用'tf_gpu'环境 conda停用

-1
投票

如果您使用的是anaconda,请在anaconda提示符下运行此命令

conda install -c anaconda tensorflow-gpu

这也将为你安装cuda toolkitcudnn你很高兴去网站它提到这个命令是针对linux所以我不确定它是否可以在窗口上工作,但你可以试试

© www.soinside.com 2019 - 2024. All rights reserved.