共計(jì) 1407 個(gè)字符,預(yù)計(jì)需要花費(fèi) 4 分鐘才能閱讀完成。
這篇“ubuntu 中怎么測(cè)試 gpu 性能”文章的知識(shí)點(diǎn)大部分人都不太理解,所以丸趣 TV 小編給大家總結(jié)了以下內(nèi)容,內(nèi)容詳細(xì),步驟清晰,具有一定的借鑒價(jià)值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來看看這篇“ubuntu 中怎么測(cè)試 gpu 性能”文章吧。
1. 測(cè)試系統(tǒng)自動(dòng)分配設(shè)備示例:
#-*- coding:utf-8 -*-
import tensorflow as tf
# 新建一個(gè) graph.
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name= a )
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name= b )
c = tf.matmul(a, b)
# 新建 session with log_device_placement 并設(shè)置為 True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# 運(yùn)行這個(gè) op.
print(sess.run(c))
輸出如下:
Device mapping:
/job:localhost/replica:0/task:0/gpu:0 - device: 0, name: Tesla K40c, pci bus
id: 0000:05:00.0
b: /job:localhost/replica:0/task:0/gpu:0
a: /job:localhost/replica:0/task:0/gpu:0
MatMul: /job:localhost/replica:0/task:0/gpu:0
[[22. 28.][49. 64.]]
2. 測(cè)試手動(dòng)指定分配設(shè)備示例:
#-*- coding:utf-8 -*-
import tensorflow as tf
# 新建一個(gè) graph.
with tf.device(/cpu:0):
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name= a )
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name= b )
c = tf.matmul(a, b)
# 新建 session with log_device_placement 并設(shè)置為 True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
# 運(yùn)行這個(gè) op.
print(sess.run(c))
a 和 b 操作都被指派給了 cpu:0,輸出如下:
Device mapping:
/job:localhost/replica:0/task:0/gpu:0 - device: 0, name: Tesla K40c, pci bus
id: 0000:05:00.0
b: /job:localhost/replica:0/task:0/cpu:0
a: /job:localhost/replica:0/task:0/cpu:0
MatMul: /job:localhost/replica:0/task:0/gpu:0
[[22. 28.][49. 64.]]
以上就是關(guān)于“ubuntu 中怎么測(cè)試 gpu 性能”這篇文章的內(nèi)容,相信大家都有了一定的了解,希望丸趣 TV 小編分享的內(nèi)容對(duì)大家有幫助,若想了解更多相關(guān)的知識(shí)內(nèi)容,請(qǐng)關(guān)注丸趣 TV 行業(yè)資訊頻道。