關(guān)于Tensorflow和Keras版本對(duì)照及環(huán)境安裝
在安裝tensorflow環(huán)境的時(shí)候,一定要先弄清楚對(duì)應(yīng)的版本對(duì)應(yīng)的情況,不要上來就 pip install tensorflow
, pip install keras
。
最后發(fā)現(xiàn)全是坑。
下面就列一下,tensorflow和keras以及對(duì)應(yīng)的python版本,然后再列一下我成功安裝的流程。
一、Tensorflow、Keras和python版本對(duì)照
二者對(duì)應(yīng)版本號(hào)如表所示(Keras新版本對(duì)Tensorflow老版本不兼容,需注意安裝版本號(hào))
Framework | Env name | Description |
---|---|---|
TensorFlow 2.2 | tensorflow-2.2 | TensorFlow 2.2.0 + Keras 2.3.1 on Python 3.7. |
TensorFlow 2.1 | tensorflow-2.1 | TensorFlow 2.1.0 + Keras 2.3.1 on Python 3.6. |
TensorFlow 2.0 | tensorflow-2.0 | TensorFlow 2.0.0 + Keras 2.3.1 on Python 3.6. |
TensorFlow 1.15 | tensorflow-1.15 | TensorFlow 1.15.0 + Keras 2.3.1 on Python 3.6. |
TensorFlow 1.14 | tensorflow-1.14 | TensorFlow 1.14.0 + Keras 2.2.5 on Python 3.6. |
TensorFlow 1.13 | tensorflow-1.13 | TensorFlow 1.13.0 + Keras 2.2.4 on Python 3.6. |
TensorFlow 1.12 | tensorflow-1.12 | TensorFlow 1.12.0 + Keras 2.2.4 on Python 3.6. |
tensorflow-1.12:py2 | TensorFlow 1.12.0 + Keras 2.2.4 on Python 2. | |
TensorFlow 1.11 | tensorflow-1.11 | TensorFlow 1.11.0 + Keras 2.2.4 on Python 3.6. |
tensorflow-1.11:py2 | TensorFlow 1.11.0 + Keras 2.2.4 on Python 2. | |
TensorFlow 1.10 | tensorflow-1.10 | TensorFlow 1.10.0 + Keras 2.2.0 on Python 3.6. |
tensorflow-1.10:py2 | TensorFlow 1.10.0 + Keras 2.2.0 on Python 2. | |
TensorFlow 1.9 | tensorflow-1.9 | TensorFlow 1.9.0 + Keras 2.2.0 on Python 3.6. |
tensorflow-1.9:py2 | TensorFlow 1.9.0 + Keras 2.2.0 on Python 2. | |
TensorFlow 1.8 | tensorflow-1.8 | TensorFlow 1.8.0 + Keras 2.1.6 on Python 3.6. |
tensorflow-1.8:py2 | TensorFlow 1.8.0 + Keras 2.1.6 on Python 2. | |
TensorFlow 1.7 | tensorflow-1.7 | TensorFlow 1.7.0 + Keras 2.1.6 on Python 3.6. |
tensorflow-1.7:py2 | TensorFlow 1.7.0 + Keras 2.1.6 on Python 2. | |
TensorFlow 1.5 | tensorflow-1.5 | TensorFlow 1.5.0 + Keras 2.1.6 on Python 3.6. |
tensorflow-1.5:py2 | TensorFlow 1.5.0 + Keras 2.0.8 on Python 2. | |
TensorFlow 1.4 | tensorflow-1.4 | TensorFlow 1.4.0 + Keras 2.0.8 on Python 3.6. |
tensorflow-1.4:py2 | TensorFlow 1.4.0 + Keras 2.0.8 on Python 2. | |
TensorFlow 1.3 | tensorflow-1.3 | TensorFlow 1.3.0 + Keras 2.0.6 on Python 3.6. |
tensorflow-1.3:py2 | TensorFlow 1.3.0 + Keras 2.0.6 on Python 2. |
安裝的時(shí)候按照對(duì)應(yīng)的版本進(jìn)行安裝。
二、Tensorflow和Keras安裝流程
這里安裝python=3.6,Tensorflow=2.0,Keras=2.3.1
1. anaconda安裝python環(huán)境
1)在Anaconda Prompt中輸入命令,創(chuàng)建conda環(huán)境
conda create -n tensorflow python=3.6
2)激活環(huán)境
activate tensorflow
2. 安裝Tensorflow
pip install tensorflow==2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
3. 安裝Keras
pip install keras==2.3.1 -i https://pypi.tuna.tsinghua.edu.cn/simple
結(jié)果查看(切換到python環(huán)境):
注意:
如果開始你安裝的時(shí)候沒有注意版本問題,直接使用 pip install tensorflow
安裝,安裝過程中不會(huì)出現(xiàn)問題
在import會(huì)報(bào)錯(cuò):
W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcudart.so.10.1'; dlerror: libcudart.so.10.1: cannot open shared object file: No such file or directory
I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
這就是版本不匹配的問題,你需要安裝對(duì)應(yīng)版本的tensorflow。
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Python技巧之實(shí)現(xiàn)批量統(tǒng)一圖片格式和尺寸
大家在工作的時(shí)候基本都會(huì)接觸到很多的圖片,有時(shí)為了不同的工作需求需要修改圖片的尺寸或者大小。本文為大家整理了Python批量轉(zhuǎn)換圖片格式和統(tǒng)一圖片尺寸,希望對(duì)大家有所幫助2023-05-05Python爬蟲實(shí)戰(zhàn)之爬取某寶男裝信息
網(wǎng)絡(luò)爬蟲是一種按照一定的規(guī)則自動(dòng)瀏覽、檢索網(wǎng)頁信息的程序或者腳本。網(wǎng)絡(luò)爬蟲能夠自動(dòng)請(qǐng)求網(wǎng)頁,并將所需要的數(shù)據(jù)抓取下來。本文將為大家介紹如何利用爬蟲獲取某寶男裝信息,感興趣的小伙伴可以了解一下2021-12-12Django實(shí)現(xiàn)auth模塊下的登錄注冊(cè)與注銷功能
這篇文章主要介紹了Django實(shí)現(xiàn)auth模塊下的登錄注冊(cè)與注銷功能,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-10-10python實(shí)現(xiàn)轉(zhuǎn)圈打印矩陣
這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)轉(zhuǎn)圈打印矩陣,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2019-03-03python for循環(huán)remove同一個(gè)list過程解析
這篇文章主要介紹了python for循環(huán)remove同一個(gè)list過程解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-08-08詳解pycharm連接不上mysql數(shù)據(jù)庫的解決辦法
這篇文章主要介紹了詳解pycharm連接不上mysql數(shù)據(jù)庫的解決辦法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-01-01