如何在没有GPU的情况下运行tensorflow?

4

我的系统有GPU。

当我在其上运行Tensorflow时,TF会自动检测到GPU,并在GPU上启动线程运行。

我该如何更改这一设置?

即如何在没有GPU的情况下运行Tensorflow?


1
就配置而言,我不太清楚,但你可以使用Google Colab。 - raviraj
1
你有关注过这个帖子吗? - Kalana
1个回答

5

它应该可以正常工作。主要是禁用了CUDA设备,因此代码会寻找其他源(CPU)来运行代码。

import os
import tensorflow as tf
#os.environ["CUDA_DEVICE_ORDER"]="PCI_BUS_ID" #If the line below doesn't work, uncomment this line (make sure to comment the line below); it should help.
os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
#Your Code Here

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接