windows 10 64bit下安装Tensorflow+Keras

windows 10 下 pip,conda 换国内源,安装Tensorflow,Keras

修改pip源 参考 Python pip 国内镜像大全及使用办法

官方文档 Config file

windows 全部用户需要在%APPDATA%\pip\pip.ini,当前用户在%HOME%\pip\pip.ini

[global]
index-url=http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host=mirrors.aliyun.com复制代码

安装Tensorflow

参考 Installing TensorFlow on Windows

# 切换到 python3.5 参考 详见另外一篇博文 https://anjia.ml/2017/07/02/anaconda-install-and-configurating-jupyter/#切换python版本

#打开Anaconda Prompt
(python35) C:\Users\xx> activate python35

#因为电脑无独显,所以安装`CPU-only`版本
(python35) C:\Users\xx> pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.2.1-cp35-cp35m-win_amd64.whl 

(python35) C:\Users\xx>python复制代码
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow')
>>> sess = tf.Session()
2017-07-03 16:44:16.082952: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2017-07-03 16:44:16.085175: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-03 16:44:16.085590: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-03 16:44:16.085952: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-03 16:44:16.086312: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-03 16:44:16.086634: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-07-03 16:44:16.087014: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-07-03 16:44:16.087363: W c:\tf_jenkins\home\workspace\release-win\m\windows\py\35\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
>>> print(sess.run(hello))
b'Hello, TensorFlow'复制代码

如果要去掉4-12的警告信息,需要自己编译。详见 "The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations" in "Hello, TensorFlow!" program #7778

安装Keras

参考 官方文档 Installation 中文文档 Keras安装和配置指南(Windows)

(python35) C:\Users\xx>pip install keras -U --pre复制代码

但是我安装一直报错,

Running setup.py bdist_wheel for scipy ... error
  Complete output from command {Anaconda3_home}\envs\python35\python.exe -u -c "import setuptools, tokenize;__file__='{AppData}\\Local\\Temp\\pip-build-mgdjtt1d\\scipy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d {AppData}\Local\Temp\tmpb_od_dlvpip-wheel- --python-tag cp35:
  lapack_opt_info:
  lapack_mkl_info:
    libraries mkl_rt not found in ['{Anaconda3_home}\\envs\\python35\\lib', 'C:\\', '{Anaconda3_home}\\envs\\python35\\libs']
    NOT AVAILABLE

## ...

Command "{Anaconda3_home}\envs\python35\python.exe -u -c "import setuptools, tokenize;__file__='{AppData}\\Local\\Temp\\pip-build-mgdjtt1d\\scipy\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record {AppData}\Local\Temp\pip-htcraop7-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in {AppData}\Local\Temp\pip-build-mgdjtt1d\scipy\复制代码

网上有建议通过 pip install git+git://github.com/Theano/Theano.git 从github直接下最新代码安装的,但是也是安装失败

我成功的方式

(python35) C:\Users\xx>conda install mingw libpython theano -y
(python35) C:\Users\xx>pip install keras复制代码

天朝网络不稳定,挺慢的,可以参考 另外一篇博文切换清华源 anjia.ml/2017/07/02/…

(python35) C:\Users\xx>python
Python 3.5.3 |Continuum Analytics, Inc.| (default, May 15 2017, 10:43:23) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import keras
Using TensorFlow backend.复制代码

安装成功,默认后端是TensorFlow

博客 anjia.ml/2017/07/03/…
掘金 juejin.im/post/595a24…
简书 www.jianshu.com/p/e0d9fa795…

安装TensorFlowKeras在Anaconda中,请按照以下步骤进行操作: 1. 首先,从Anaconda官网下载并安装Anaconda。请确保选择适用于你操作系统的版本。 2. 打开Anaconda Prompt(Windows)或命令行终端(Mac和Linux)。 3. 创建一个新的Python环境,可以使用以下命令: ``` conda create -n your_env_name python=X.X ``` 将`your_env_name`替换为你想要的环境名称,`X.X`替换为你想要的Python版本号(例如2.7或3.6)。 4. 激活新创建的环境,使用以下命令: ``` conda activate your_env_name ``` 5. 安装TensorFlowKeras,可以使用以下命令: ``` conda install tensorflow-gpu keras ``` 这将安装TensorFlow GPU版本和Keras。 6. 安装完成后,你可以使用以下命令来验证安装: ``` conda list tensorflow-gpu keras ``` 这将显示已安装TensorFlowKeras的版本号。 7. 如果你想在Jupyter Notebook中使用新创建的环境,请确保在激活环境的状态下安装Jupyter Notebook,并在激活环境的状态下启动Jupyter Notebook。 ``` conda install jupyter jupyter notebook ``` 这将启动Jupyter Notebook,并在默认浏览器中打开它。 请注意,这里提供的步骤仅适用于Anaconda环境中安装TensorFlowKeras。确保按照上述步骤进行操作,以便正确安装所需的库和环境。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [手把手 Ubuntu16.04+cuda9.0+cudnn 7.1+Anaconda+tensorflow-gpu+keras-附件资源](https://download.csdn.net/download/weixin_42185419/15595517)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [Anaconda安装Tensorflow+keras](https://blog.csdn.net/daodanxiansheng/article/details/88132980)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [【避坑指南】Windows10中使用Anaconda安装tensorflow+keras](https://blog.csdn.net/hutianle/article/details/126426446)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值