神通情人夢的願望6(TensorFlow+GPU第一次試Run成功)
GeForce GT730 可以跑 TensorFlow 囉 |
話說前天才從露天下單購買二手GeForce GT730 GPU (參考此篇 : 神通情人夢的願望5(尋找千元以下可跑TensorFlow的GPU)) , 結果今天就到貨 ! Σ( ° △ °|||)︴, 這賣家也太有效率 , 值得推一下!
露天"小江~柑仔店" 賣場首頁 , 而且包裝保護的很好 , 似乎真有清洗過 , 有想找二手實驗零件的話 , 下次可以考慮再跟他買 , 出貨超快 ~
包裝保護的很好 , 似乎有清洗過 還用密封袋 |
迫不及待的換裝上去 開機測試 (風扇很小聲 Good !) |
這塊不曉得是什麼廠牌 !? 不過沒差 , 主要央喜是需晶片 Nvidia GeForce GT 730 且能符合Compute Capability 3.5 以上 , 以下開始來測試筆記 :
$nvidia-detect -v
Probing for supported NVIDIA devices...
[10de:1287] NVIDIA Corporation GK208B [GeForce GT 730]
This device requires the current 418.43 NVIDIA driver kmod-nvidia
WARNING: Xorg log file /var/log/Xorg.0.log does not exist
WARNING: Unable to determine Xorg ABI compatibility
WARNING: The driver for this device does not support the current Xorg version
$nvidia-detect -v 出現GT730 看來driver也相同 |
$nvidia-smi 基本的指令都檢測一下 |
#再用CUDA的deviceQuery測一下 (參考這篇 : 神通情人夢的願望4 )
$ cd /usr/local/cuda-10.0/samples/1_Utilities/deviceQuery
$ make
$ ./deviceQuery
deviceQuery 可看到 GeForce GT730 相關資訊 (Compute Capability 3.5 ) |
趕緊來 test script 一下 (參考 ) 顯示如下訊息 , YES!! 應該是PASS :
# tensorflow GPU test script import tensorflow as tf sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))//========================================================
Found device 0 with properties:
name: GeForce GT 730 major: 3 minor: 5 memoryClockRate(GHz): 0.9015
pciBusID: 0000:01:00.0
totalMemory: 1.95GiB freeMemory: 1.93GiB
//========================================================
GeForce GT 730 major: 3 minor: 5 |
最後迫不及待地再來跑跑看 DCGAN in Tensorflow ( 什麼是DCGAN !? 你一定沒看前面 , 參考: 神通情人夢的願望(第一步自創美女頭像) )
# 跑DCGAN 測試一下 (epoch 25)
$ python main.py --input_height=96 --output_height=96 --dataset face --train --epoch 25 --batch_size 50 --input_fname_pattern "*.jpg"
StreamExecutor device (0): GeForce GT 730, Compute Capability 3.5 |
successfully opened CUDA library libcublas.so.10.0 locally |
後記 : 測試跑25個 Epoch 花約6分鐘 , 還是感覺不盡理想 XD (不過已經比原本CPU跑又快了許多 也許還需研究調校或是更高階的GPU吧 XD ) , 後續再來研究筆記 ...
看網路人家CPU原本跑3分鐘 用GPU只跑4秒 , 不知是怎麼tuning的 !?
參考 : 使用tensorflow-gpu版本测试下学习速度,cpu(3分钟) vs gpu(4秒),还是gpu快
不過他GPU是GeForce 940MX Capability5.0 (SPEC) , 下次再來找找相同等級的測測看!
# === Sample code === # Usage: $python matmul.py gpu 1500 or $python matmul.py cpu 1500 import sys import numpy as np import tensorflow as tf from datetime import datetime device_name = sys.argv[1] # Choose device from cmd line. Options: gpu or cpu shape = (int(sys.argv[2]), int(sys.argv[2])) if device_name == "gpu": device_name = "/gpu:0" else: device_name = "/cpu:0" with tf.device(device_name): random_matrix = tf.random_uniform(shape=shape, minval=0, maxval=1) dot_operation = tf.matmul(random_matrix, tf.transpose(random_matrix)) sum_operation = tf.reduce_sum(dot_operation) startTime = datetime.now() with tf.Session(config=tf.ConfigProto(log_device_placement=True)) as session: result = session.run(sum_operation) print(result) # It can be hard to see the results on the terminal with lots of output -- add some newlines to improve readability. print("\n" * 5) print("Shape:", shape, "Device:", device_name) print("Time taken:", datetime.now() - startTime) print("\n" * 5)
補充 (2019-03-20 23:30) :
分別測試GPU & CPU 跑 DCGAN in TensorFlow (25 epoch) , 得出結果 :
# Tensorflow禁用GPU的方法 import os os.environ["CUDA_VISIBLE_DEVICES"]="-1" #加入此行 import tensorflow as tf
//=====================================
[DCGAN in TensorFlow use only CPU] ( 4 core CPU almost 100%)
real 8m24.324s
user 29m48.819s
sys 0m26.709s
[DCGAN TensorFlow use with GPU] (CPU 耗用如下圖)
real 5m14.560s
user 3m37.071s
sys 1m49.786s
//=====================================實測DCGAN in TensorFlow use GPU時 , CPU耗用少 , 時間的確有縮短 看來必須得提升GPU等級才行了 XD |
Ref:
确定自己的TensorFlow是CPU还是GPU的版本
Compute processes: not supported
Nvidia顯卡查看Compute Capability(官網)
使用tensorflow-gpu版本测试下学习速度,cpu(3分钟) vs gpu(4秒),还是gpu快
GeForce 940MX Compute Capability5.0 spec
DCGAN in Tensorflow
tensorflow禁用GPU
TensorFlow測試GPU and CPU
留言
張貼留言