PytLab / gaft

A Genetic Algorithm Framework in Python (not for production level)
http://gaft.readthedocs.io/
GNU General Public License v3.0
739 stars 218 forks source link

多进程运行时,请问如何仅仅让主程序执行一些log文件? #56

Closed TheSilverLinings closed 4 years ago

TheSilverLinings commented 4 years ago

如题,请问博主是如何让主进程执行 创建文件,创建log文件,而其他进程不执行这些操作?如果将MPI封装到另一个类中,又要怎么运行程序?还是用mpiexec -n 5 python xx.py 吗?

PytLab commented 4 years ago

你可以使用定义 analysis callback的时候设置master_only=1来强制只在主进程执行,参考: https://github.com/PytLab/gaft/blob/master/examples/ex01/ex01.py#L47