OMP: Error #34: System unable to allocate necessary resources for OMP thread

用TensorFlow训练时有时候会出现这种错误:

OMP: Error #34: System unable to allocate necessary resources for OMP thread:
OMP: System error #11: Resource temporarily unavailable
OMP: Hint: Try decreasing the value of OMP_NUM_THREADS.
Aborted (core dumped) 

 

这种情况往往是因为正在运行的程序开了太多GPU线程,占用了太多cpu资源。这样反倒使得运行效率降低,还影响新的程序运行。可以在训练脚本的开头加上这几行限制线程数:

import os
os.environ["MKL_NUM_THREADS"] = '4'
os.environ["NUMEXPR_NUM_THREADS"] = 4'
os.environ["OMP_NUM_THREADS"] = '4'

你可能感兴趣的:(OMP: Error #34: System unable to allocate necessary resources for OMP thread)