2021
02-21
02-21
详解tf.device()指定tensorflow运行的GPU或CPU设备实现
在tensorflow中,我们可以使用tf.device()指定模型运行的具体设备,可以指定运行在GPU还是CUP上,以及哪块GPU上。设置使用GPU使用tf.device('/gpu:1')指定Session在第二块GPU上运行:importtensorflowastfwithtf.device('/gpu:1'):v1=tf.constant([1.0,2.0,3.0],shape=[3],name='v1')v2=tf.constant([1.0,2.0,3.0],shape=[3],name='v2')sumV12=v1+v2withtf.Session(config=tf.ConfigProto(log_...
继续阅读 >