简体   繁体   English

如何在keras / tensorflow挂起时重置GPU?

[英]How to reset GPU on keras / tensorflow hang?

Sometimes I have to kill my python application which use GPU with Keras or Tensorflow and after that I can't run them anymore. 有时,我必须杀死在Keras或Tensorflow上使用GPU的python应用程序,之后我无法再运行它们。 This is probably because GPU is still used by something. 这可能是因为GPU仍被某些人使用。

How to free GPU by force without machine reboot? 如何在不重启机器的情况下强制释放GPU?


I tried the following shell script 我尝试了以下shell脚本

$ cat ~/bin/nvidia-reset
#!/bin/sh

sudo rmmod nvidia_uvm

sudo rmmod nvidia_drm

sudo rmmod nvidia_modeset

sudo rmmod nvidia

sudo nvidia-smi

But often it is unable to do the job saying nvidia_uvm is busy. 但是通常说nvidia_uvm很忙,无法完成这项工作。

尝试这个:

keras.backend.clear_session()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM