-1
我的GPU的粉絲有問題。因此,在運行張量流一段時間後,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不應該過熱。我猜你有一臺無風扇的特斯拉插入一個不是爲它設計的系統。 –