一、确认tensorflow的版本:
接上一条tensorflow的安装,注意版本不匹配会出现很多问题!:【吴恩达课程使用】anaconda (python 3.7) win10安装 tensorflow 1.8
源网址:https://docs.floydhub.com/guides/environments/
Below is the list of Deep Learning environments supported by FloydHub. Any of these can be specified in the floyd run command using the --env
option.
If no --env
is provided, it uses the tensorflow-1.9
image by default, which comes with Python 3.6, Keras 2.2.0 and TensorFlow 1.9.0 pre-installed.
Framework | Env name (--env parameter) | Description | Docker Image | Packages and Nvidia Settings |
---|---|---|---|---|
TensorFlow 1.14 | tensorflow-1.14 | TensorFlow 1.14.0 + Keras 2.2.5 on Python 3.6. | floydhub/tensorflow | TensorFlow-1.14 |
TensorFlow 1.13 | tensorflow-1.13 | TensorFlow 1.13.0 + Keras 2.2.4 on Python 3.6. | floydhub/tensorflow | TensorFlow-1.13 |
TensorFlow 1.12 | tensorflow-1.12 | TensorFlow 1.12.0 + Keras 2.2.4 on Python 3.6. | floydhub/tensorflow | TensorFlow-1.12 |
tensorflow-1.12:py2 | TensorFlow 1.12.0 + Keras 2.2.4 on Python 2. | floydhub/tensorflow | ||
TensorFlow 1.11 | tensorflow-1.11 | TensorFlow 1.11.0 + Keras 2.2.4 on Python 3.6. | floydhub/tensorflow | TensorFlow-1.11 |
tensorflow-1.11:py2 | TensorFlow 1.11.0 + Keras 2.2.4 on Python 2. | floydhub/tensorflow | ||
TensorFlow 1.10 | tensorflow-1.10 | TensorFlow 1.10.0 + Keras 2.2.0 on Python 3.6. | floydhub/tensorflow | TensorFlow-1.10 |
tensorflow-1.10:py2 | TensorFlow 1.10.0 + Keras 2.2.0 on Python 2. | floydhub/tensorflow | ||
TensorFlow 1.9 | tensorflow-1.9 | TensorFlow 1.9.0 + Keras 2.2.0 on Python 3.6. | floydhub/tensorflow | TensorFlow-1.9 |
tensorflow-1.9:py2 | TensorFlow 1.9.0 + Keras 2.2.0 on Python 2. | floydhub/tensorflow | ||
TensorFlow 1.8 | tensorflow-1.8 | TensorFlow 1.8.0 + Keras 2.1.6 on Python 3.6. | floydhub/tensorflow | TensorFlow-1.8 |
tensorflow-1.8:py2 | TensorFlow 1.8.0 + Keras 2.1.6 on Python 2. | floydhub/tensorflow | ||
TensorFlow 1.7 | tensorflow-1.7 | TensorFlow 1.7.0 + Keras 2.1.6 on Python 3.6. | floydhub/tensorflow | TensorFlow-1.7 |
tensorflow-1.7:py2 | TensorFlow 1.7.0 + Keras 2.1.6 on Python 2. | floydhub/tensorflow | ||
TensorFlow 1.5 | tensorflow-1.5 | TensorFlow 1.5.0 + Keras 2.1.6 on Python 3.6. | floydhub/tensorflow | TensorFlow-1.5 |
tensorflow-1.5:py2 | TensorFlow 1.5.0 + Keras 2.1.6 on Python 2. | floydhub/tensorflow | ||
TensorFlow 1.4 | tensorflow-1.4 | TensorFlow 1.4.0 + Keras 2.0.8 on Python 3.6. | floydhub/tensorflow | |
tensorflow-1.4:py2 | TensorFlow 1.4.0 + Keras 2.0.8 on Python 2. | floydhub/tensorflow | ||
TensorFlow 1.3 | tensorflow-1.3 | TensorFlow 1.3.0 + Keras 2.0.6 on Python 3.6. | floydhub/tensorflow | |
tensorflow-1.3:py2 | TensorFlow 1.3.0 + Keras 2.0.6 on Python 2. | floydhub/tensorflow | ||
TensorFlow 1.2 | tensorflow-1.2 | TensorFlow 1.2.0 + Keras 2.0.6 on Python 3.5. | floydhub/tensorflow | |
tensorflow-1.2:py2 | TensorFlow 1.2.0 + Keras 2.0.6 on Python 2. | floydhub/tensorflow | ||
TensorFlow 1.1 | tensorflow | TensorFlow 1.1.0 + Keras 2.0.6 on Python 3.5. | floydhub/tensorflow | |
tensorflow:py2 | TensorFlow 1.1.0 + Keras 2.0.6 on Python 2. | floydhub/tensorflow | ||
TensorFlow 1.0 | tensorflow-1.0 | TensorFlow 1.0.0 + Keras 2.0.6 on Python 3.5. | floydhub/tensorflow | |
tensorflow-1.0:py2 | TensorFlow 1.0.0 + Keras 2.0.6 on Python 2. | floydhub/tensorflow | ||
TensorFlow 0.12 | tensorflow-0.12 | TensorFlow 0.12.1 + Keras 1.2.2 on Python 3.5. | floydhub/tensorflow | |
tensorflow-0.12:py2 | TensorFlow 0.12.1 + Keras 1.2.2 on Python 2. | floydhub/tensorflow |
二、激活之前tensorflow安装环境
\\1. 查看Python环境
conda info --env可以看到所有python环境,前面有个‘*’的代表当前环境:
\\2.激活环境
使用如下命令即可激活创建的虚拟环境
Linux: source activate your_env_name(虚拟环境名称)
Windows: activate your_env_name(虚拟环境名称)
例如我的:activate tensorflow10
三、安装keras 2.1.6
推荐使用pip:pip install keras==2.1.6 -i https://pypi.tuna.tsinghua.edu.cn/simple/ 【成功】
也可以使用anaconda:conda install -c anaconda keras==2.1.6 【失败】
四、安装慢-anaconda pip 换源
源地址:conda和pip常用方法,更换源,包的安装、更新、删除、查看
conda和pip可以说各有优劣。pip的模块更全更多,而conda使用更方便,安装模块时会检查环境,自动下载。conda 特别是在数据分析方面,会对某些常用的包做了专门的优化。
更换源
pip
临时更换 【http开头会出现 not a trusted or secure host 问题】
pip install <包名> -i https://pypi.douban.com/simple
上面使用的是豆瓣源,下面是其他国内源,替换上面的地址即可,都很快,随便用哪个。
阿里云 http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban) http://pypi.douban.com/simple/
清华大学 https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学 http://pypi.mirrors.ustc.edu.cn/simple/
永久更换
Windows
user目录中创建一个pip目录,如:C:\\Users\\xx\\pip,新建文件pip.ini,内容如下:
[global]
index-url = http://pypi.douban.com/simple/
[install]
trusted-host=pypi.douban.com
Linux
修改 ~/.pip/pip.conf (没有就创建一个), 添加内容与上面代码一致。
mkdir ~/.pip/
vim ~/.pip/pip.conf
conda
Windows / Linux
Windows 和 Linux方法一致,并且是永久更换。
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
包管理
安装
pip
pip install <包名>
conda
conda install <包名>
更新自己
pip
python -m pip install --upgrade pip
conda
conda update conda
查看过期的包
pip两种方法均可
pip list --outdated
pip list -o
#conda 查看所有包及其版本
conda list
单个更新包
pip 两种均可
pip install --upgrade <包名>
pip install -U <包名>
conda
conda update <包名>
批量更新包
pip
以下是python代码,需要打开Python后运行
import pip
from subprocess import call
from pip._internal.utils.misc import get_installed_distributions
for dist in get_installed_distributions():
call("pip install --upgrade " + dist.project_name, shell=True)
conda
conda update --all