1.可以尝试
export MKL_NUM_THREADS=1
export NUMEXPR_NUM_THREADS=1
export OMP_NUM_THREADS=1
2.可以在import numpy前设置
import os
os.environ[“MKL_NUM_THREADS”] = “1”
os.environ[“NUMEXPR_NUM_THREADS”] = “1”
os.environ[“OMP_NUM_THREADS”] = “1”
参看文献:
https://stackoverflow.com/questions/30791550/limit-number-of-threads-in-numpy