溫馨提示×

ubuntu如何測試gpu性能

小新
999
2021-02-02 12:37:43
欄目: 智能運維

ubuntu如何測試gpu性能

ubuntu測試gpu性能的方法:

1.測試系統自動分配設備示例:

#-*- coding:utf-8 -*-

import tensorflow as tf

# 新建一個 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并設置為True.

sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

# 運行這個 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.測試手動指定分配設備示例:

#-*- coding:utf-8 -*-

import tensorflow as tf

# 新建一個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并設置為True.

sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

# 運行這個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.]]

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女