一、確認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