【发布时间】:2017-04-09 02:20:50
【问题描述】:
我的 GPU 的风扇有问题。所以运行 tensorflow 一段时间后 GPU 的温度会过高。而且在gpu过热之前我无法完成训练。所以我写了一个脚本来检测温度并尝试暂停程序让gpu冷却下来。代码是这样的(阈值设置为45进行测试):
for batch in batches:
temp = int(os.popen("nvidia-smi | awk '{if(NR == 12)print $3}' | cut -c 1,2").readline().strip())
x_batch,y_batch,user_batch,item_batch = zip(*batch)
train_step(x_batch, y_batch, user_batch, item_batch)
current_step = tf.train.global_step(sess, self.global_step)
if temp>=45:
path = saver.save(sess, checkpoint_prefix, global_step=current_step)
print("temperature of GPU is over 45! Saved model checkpoint to {}\n".format(path))
sess.close()
return (-1,path,batches)
我把tensorflow的代码打包在一个文件中,在另一个文件中调用:
result = 1000
restore = False
path = None
batches = None
while result != 1:
result, path, batches = main(FLAGS,restore, path, batches)
if result == -1:
import gc
gc.collect()
time.sleep(300)
restore = True
现在,程序可以在温度过高时暂停,但 gpu 仍然被占用,不会冷却。所以我想知道如何停止 tensorflow 并清除 vgram。
温度过高时程序暂停:
但是gpu仍然被占用,无法降温:
【问题讨论】:
-
GPU 不应过热。我猜你有一个无风扇特斯拉插入一个不是为它设计的系统。
标签: tensorflow gpu nvidia