Tensorflow1.x跟2.x版本透過anaconda去跑各自不同執行環境

 

TensorFlow 是為了能輕鬆實現深度學習與機器學習演算法而開發的函式庫。因此,在任何可以使用機器學習、深度學習的領域,都可以使用 TensorFlow。深度學習演算法的優點在於其通用性,能廣泛應用於多種不同領域。

雖然僅使用 TensorFlow 函式庫也能編寫深度學習程式碼,但為了能更輕鬆地實現深度學習演算法,存在許多將 TensorFlow 函式庫進階抽象化 Abstraction 的多樣化高階 High-Level 函式庫。利用這些函式庫,可以比直接使用 TensorFlow 以更簡潔的程式碼實現深度學習演算法。

Keras 這是由 François Chollet 建立的深度學習抽象化函式庫。除了 TensorFlow 之外,還支援 CNTK、Theano、MXNet 等其他深度學習函式庫。
Keras 是深度學習抽象化函式庫中擁有最多使用者群體的。憑藉這種人氣,Google 將 Keras 的創始人 François Chollet 招募進公司,並將 Keras 合併到 TensorFlow 的主程式碼庫中。因此,可以混合使用 TensorFlow 函式庫與 Keras 函式庫來編寫程式碼。


Tensorflow1.x
conda create -n tf1 python=3.7 -y
conda activate tf1
pip install --upgrade pip
pip install tensorflow==1.15.5
pip install "protobuf<3.20"
python -m pip install notebook ipykernel
python -m ipykernel install --user --name tf1 --display-name "Python (tf1)"
jupyter notebook --notebook-dir="E:\PyProjects\TF1_Project"
pip install tensorflow-gpu==1.15


如果想要安裝 GPU 版本,早期教學影片、文件會跟你說必須先安裝 CUDA 和 cuDNN*,然後可以使用以下指令安裝 TensorFlow GPU 版本:
pip install tensorflow-gpu

不過要注意!! 自從 TensorFlow 2.1 版本之後,官方已經將 tensorflow 和 tensorflow-gpu 兩個套件合併。
現在只要安裝 pip install tensorflow,系統就會自動支援 CPU 與 GPU(前提是 CUDA 環境已設定正確)。
若是練習跑Tensorflow1.x版本要指定板號才會下載成功
pip install tensorflow-gpu==1.15

Tensorflow2.x
conda create -n tf2 python=3.10 -y
conda activate tf2
pip install --upgrade pip
pip install tensorflow

python -m pip install notebook ipykernel
python -m ipykernel install --user --name tf2 --display-name "Python (tf2)"
jupyter notebook --notebook-dir="E:\PyProjects\TF2_Project"


要確認目前tensorflow版本與pip套件版本陳列請多加利用以下腳本指令

import tensorflow as tf;
print(tf.__version__)

pip show tensorflow


測試




Ref:
TensorFlow vs PyTorch – A Detailed Comparison
TensorFlow 2.0 与 1.0 的区别与联系
Keras 創辦人 Francois Chollet 離開 Google,成立 AGI 新創公司

留言

這個網誌中的熱門文章

何謂淨重(Net Weight)、皮重(Tare Weight)與毛重(Gross Weight)

外貿Payment Term 付款條件(方式)常見的英文縮寫與定義

鼎新ERP_會計系統_總帳管理_財務參數設定_傳票處理