网络编程
位置:首页>> 网络编程>> Python编程>> 在tensorflow中设置使用某一块GPU、多GPU、CPU的操作

在tensorflow中设置使用某一块GPU、多GPU、CPU的操作

作者:MachineLP  发布时间:2023-07-22 11:37:28 

标签:tensorflow,GPU,CPU

tensorflow下设置使用某一块GPU(从0开始编号):


import os
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = "1"

多GPU:


num_gpus = 4

for i in range(num_gpus):
 with tf.device('/gpu:%d',%i):
   。。。

只是用cpu的情况


with tf.device("/cpu:0"):

来源:https://blog.csdn.net/u014365862/article/details/78292475

0
投稿

猜你喜欢

手机版 网络编程 asp之家 www.aspxhome.com