我首先在我的图形处理器上用python创建了我的TensorFlow代码,使用:
import tensorflow-gpu as tf我把它用于训练目的,一切都进行得很顺利。但是现在,我想在没有GPU的设备上部署我的python脚本。所以,我用pip卸载了tensorflow-gpu,并导入了普通的TensorFlow:
import tensorflow as tf但是当我运行脚本时,它仍然在使用gpu:

我试过这段代码:
try:
# Disable all GPUS
tf.config.set_visible_devices([], 'GPU')
visible_devices = tf.config.get_visible_devices()
print(visible_devices)
for device in visible_devices:
assert device.device_type != 'GPU'
except Exception as e:
# Invalid device or cannot modify virtual devices once initialized.
print(e)但仍然不能工作(即使gpu似乎禁用,正如您在屏幕截图上看到的白色)。
我只想回到默认的TensorFlow安装,没有图形处理器的功能。我试图卸载并安装tensorflow,删除虚拟环境并创建一个新的虚拟环境,但没有起作用。
感谢您的帮助!
发布于 2021-02-11 11:40:39
Tensorflow > 2.x具有默认的GPU支持。要了解更多信息,请访问Tensorflow网站。
根据上面的屏幕截图,它只显示CPU。同时也要观察Adding visible GPU devices: 0
如果您仍然只想使用CPU,启用Tensorflow,请使用Tensorflow==1.15
https://stackoverflow.com/questions/65862827
复制相似问题