我正在使用Tensorflow 1.14和两个GPU,但它们都被另一个同事占用了20天。有没有办法在CPU上运行我的代码?我试过了
config123 = tf.ConfigProto(device_count = {'GPU': 0})
with tf.Session(config=config123) as sess:和
os.environ['CUDA_VISIBLE_DEVICES'] = '-1'
但他们仍然给出了标题中提到的错误。任何帮助都将不胜感激!
发布于 2021-07-12 17:14:22
如果您希望特定操作在您选择的设备上运行,而不是在自动为您选择的设备上运行,您可以使用with tf.device来创建设备上下文,该上下文中的所有操作都将在同一指定设备上运行。
tf.debugging.set_log_device_placement(True)
# Place tensors on the CPU
with tf.device('/CPU:0'):
a = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
b = tf.constant([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])
c = tf.matmul(a, b)https://stackoverflow.com/questions/68184283
复制相似问题