ubuntu中怎么测试gpu性能

59次阅读
没有评论

共计 1407 个字符,预计需要花费 4 分钟才能阅读完成。

这篇“ubuntu 中怎么测试 gpu 性能”文章的知识点大部分人都不太理解,所以丸趣 TV 小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“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.]]

以上就是关于“ubuntu 中怎么测试 gpu 性能”这篇文章的内容,相信大家都有了一定的了解,希望丸趣 TV 小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注丸趣 TV 行业资讯频道。

正文完
 
丸趣
版权声明:本站原创文章,由 丸趣 2023-07-13发表,共计1407字。
转载说明:除特殊说明外本站除技术相关以外文章皆由网络搜集发布,转载请注明出处。
评论(没有评论)