Ubuntu 18.04 搭建帶GPU的TensorFlow、Keras、Pytorch深度學習開發環境(不用手動安裝cudnn和cuda)
阿新 • • 發佈:2018-12-09
Ubuntu 18.04 搭建帶GPU的TensorFlow、Keras、Pytorch深度學習開發環境(不用手動安裝cudnn和cuda)
對學習深度學習的新手來說,環境搭建沒有大神指導會比較麻煩,今天介紹一種簡單、簡單、非常簡單的環境搭建方法。
1.安裝Anaconda
在Anaconda下載Linux版本的開發環境,可以參考網上例程安裝。
2.通過Anaconda安裝帶GPU的框架
安裝Anaconda成功後使用 anaconda-navigator 啟動導航視窗,該視窗環境特別好用,簡直就是用慣了Windows的福音。如下如:【Environment】中選擇uninstall 輸入TensorFlow會出現帶GPU的TensorFlow環境,點選安裝即可,安裝後關於GPU相關的cuda和cudnn都順帶安裝了,不用再單獨安裝(之前花了大量的時間安裝cuda和cudnn)
3.環境測試
利用如下程式碼進行測試:
import tensorflow as tf
a = tf.constant([1.,2.,3.,4.,5.,6.], shape=[2,3], name='a')
b = tf.constant([1.,2.,3.,4.,5.,6.], shape=[3,2], name='b')
c = tf.matmul(a,b)
with tf.Session(config= tf.ConfigProto(log_device_placement=True)) as sess:
print(sess.run(c))
輸出結果如下,顯示GPU:0表示安裝成功!!
同樣Keras Pytorch也使用相同的方法安裝!
享受深度學習程式設計吧!!