tensorflow 制定 CPU 或GPU

tensorflow 制定 CPU 或GPU

CPU

with tf.Session() as sess:
    ...:     with tf.device("/cpu:0"):
    ...:         m1=tf.constant([[3,3]])
    ...:         m2=tf.constant([[2],[2]])
    ...:         product=tf.matmul(m1,m2)
    ...:         result=sess.run(product)
    ...:         print(result)

GPU

 with tf.Session() as sess:
    ...:     with tf.device("/gpu:0"):
    ...:         m1=tf.constant([[3,3]])
    ...:         m2=tf.constant([[2],[2]])
    ...:         product=tf.matmul(m1,m2)
    ...:         result=sess.run(product)
    ...:         print(result)

posted on 2018-10-01 10:17 luoganttcc 阅读(...) 评论(...) 编辑 收藏

posted @ 2022-08-19 22:56  luoganttcc  阅读(4)  评论(0)    收藏  举报