Windows 10 下 TensorFlow,Anaconda的安装
来源:互联网 发布:php 获取url中的参数 编辑:程序博客网 时间:2024/05/22 06:31
由于项目需要,最近开始学习深度学习,计划用TensorFlow来做。刚开始接触遇到很多问题,写篇博文将方法记录下来,也希望给后来的人有所帮助。下面详细讲解Windows下TensorFlow的安装:
1.官网下载 Anaconda,TensorFlow当前只支持Python3.5版本,因此直接下载anaconda3-4.2.0对应版本。标准的Windows程序,一路安装即可,安装完在cmd命令行输入“Python”确认一下是不是3.5版本的。
2.接下来安装TensorFlow,cmd输入:
# GPU版本pip3 install --upgrade tensorflow-gpu# CPU版本pip3 install --upgrade tensorflow
根据笔者安装经验,在执行上面命令前最好先更新一下pip版本,命令如下:
python -m pip install --upgrade pip
安装过程视网速而定,如果中间出现错误:Cannot remove entries from nonexistent file c:\users\li\anaconda3\lib\site-packages\easy-install.pth,更新一下setuptools,代码如下:
pip install --upgrade --ignore-installed setuptools
安装成功后,会有successfully的字样。至此,TensorFlow安装完成,下面安装CUDA。
3.安装CUDA时如果安装失败,一般是由于vistual stdio integration的原因,所以建议分两步安装:
第一步,安装时选择“自定义”,把CUDA中的vistual stdio integration这一项取消安装,安装完成即可。
第二步,显然,只选择刚才那一项,其他的取消,安装完即可。命令行输入以下代码,如果看到NVDIA版本信息,说明安装成功
nvcc -v
4.安装cuDNN 5.0 ,下载安装包,解压到任意目录即可,解压完是一个名为“cuda”的文件夹。笔者解压到了c盘根目录,接下来添加环境变量“C:\cuda”,按说这一步基本就算完了,在python中导入TensorFlow测试一下:
import tensorflow as tf
如果没有报错,则成功。如果出现一下错误:
Traceback (most recent call last):File "C:\Users\test\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helperreturn importlib.import_module(mname)File "C:\Users\test\AppData\Local\Programs\Python\Python35\lib\importlib_init_.py", line 126, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)File "", line 986, in _gcd_importFile "", line 969, in _find_and_loadFile "", line 958, in _find_and_load_unlockedFile "", line 666, in _load_unlockedFile "", line 577, in module_from_specFile "", line 906, in create_moduleFile "", line 222, in _call_with_frames_removedImportError: 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\test\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python_init_.py", line 66, in from tensorflow.python import pywrap_tensorflowFile "C:\Users\test\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 21, in _pywrap_tensorflow = swig_import_helper()File "C:\Users\test\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helperreturn importlib.import_module('pywrap_tensorflow')File "C:\Users\test\AppData\Local\Programs\Python\Python35\lib\importlib_init.py", line 126, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)ImportError: No module named '_pywrap_tensorflow'During handling of the above exception, another exception occurred:Traceback (most recent call last):File "C:\Users\test\Desktop\firstp.py", line 1, in import tensorflow as tfFile "C:\Users\test\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow_init_.py", line 24, in from tensorflow.python import *File "C:\Users\test\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python_init_.py", line 72, in raise ImportError(msg)ImportError: Traceback (most recent call last):File "C:\Users\test\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helperreturn importlib.import_module(mname)File "C:\Users\test\AppData\Local\Programs\Python\Python35\lib\importlib_init_.py", line 126, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)File "", line 986, in _gcd_importFile "", line 969, in _find_and_loadFile "", line 958, in _find_and_load_unlockedFile "", line 666, in _load_unlockedFile "", line 577, in module_from_specFile "", line 906, in create_moduleFile "", line 222, in _call_with_frames_removedImportError: 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\test\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python_init_.py", line 66, in from tensorflow.python import pywrap_tensorflowFile "C:\Users\test\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 21, in _pywrap_tensorflow = swig_import_helper()File "C:\Users\test\AppData\Local\Programs\Python\Python35\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helperreturn importlib.import_module('pywrap_tensorflow')File "C:\Users\test\AppData\Local\Programs\Python\Python35\lib\importlib_init.py", line 126, in import_modulereturn _bootstrap._gcd_import(name[level:], package, level)ImportError: No module named '_pywrap_tensorflow'Failed to load the native TensorFlow runtime.See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_errorfor some common reasons and solutions. Include the entire stack traceabove this error message when asking for help.
在环境变量的path路径中再添加“C:\cuda\bin”(根据自己的解压目录来确定),重启cmd终端,再次在Python中import TensorFlow,应该就会成功了。
%%%
补充:
1.如果用上述方法安装TensorFlow网速慢的话,可以到TensorFlow官网的GitHub页面下载离线包,再进行安装。
TensorFlow官方github主页:https://github.com/tensorflow/tensorflow
2.如果安装的是py3.5版本的,但出现“pip3不是内部或外部命令”时,可能是由于以前装过Python2,没有卸载干净(卸载失败时,可能需要下载对应的Python安装包先修复,再卸载),卸载完成后还需要到环境变量的path中把有关以前的Python2有关的删除,重启电脑,再输入pip3,则不会报错。
%%%
以上就是我安装TensorFlow过程中出现的所有问题及解决方法,特此记录下来。第一次写博客,排版做的很差,忘见谅!如果有什么不明白的,可以留言,我会尽量帮助您!
- Windows 10 下 TensorFlow,Anaconda的安装
- windows 下 Anaconda 安装 TensorFlow
- windows 下 Anaconda 安装 TensorFlow
- windows下用anaconda安装tensorflow的步骤
- windows下基于Anaconda+python3.6的tensorflow-GPU安装
- Windows下Anaconda中安装tensorflow
- Windows下通过Anaconda安装TensorFlow
- Windows下通过Anaconda安装tensorflow
- windows下配置安装Anaconda+tensorflow
- Windows 7下通过anaconda安装tensorflow
- Windows下Anaconda环境安装Tensorflow
- windows环境下Anaconda安装Tensorflow
- Windows 7下通过anaconda安装tensorflow
- Windows 7下通过anaconda安装tensorflow
- windows下通过Anaconda安装tensorflow
- windows下安装Anaconda及tensorflow
- Windows下用Anaconda安装TensorFlow
- Windows Anaconda Tensorflow 安装
- Gamma函数 & Beta分布 & Dirichlet分布 & Symmetric Dirichlet
- js继承方式
- ReactiveCocoa的简单用法
- Kafka之Java API操作
- 理解Spark包中闭包
- Windows 10 下 TensorFlow,Anaconda的安装
- matlab中的length函数
- js创建对象的几种方式
- VS2010 编写JS方法后无法调用
- android全屏/沉浸式状态栏下,各种键盘挡住输入框解决办法
- 【LeetCode】48. Rotate Image
- PHP中多线程的实例
- jquery checkbox勾选/取消勾选的诡异问题
- 解决struts中404.do问题