zl程序教程

您现在的位置是:首页 >  其他

当前栏目

测试tensorflow-gpu

测试 Tensorflow GPU
2023-09-14 09:05:38 时间
import tensorflow as tf 
with tf.device('/gpu: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)  
    with tf.Session() as sess:    
        print (sess.run(c))