Python multiprocessing: restrict number of cores used

后端 未结 5 1419
忘掉有多难
忘掉有多难 2020-12-25 08:46

I want to know how to distribute N independent tasks to exactly M processors on a machine that has L cores, where L>M. I don\'t want to use all the processors because I sti

5条回答
  •  半阙折子戏
    2020-12-25 09:23

    You might want to look into the following package:

    http://pypi.python.org/pypi/affinity

    It is a package that uses sched_setaffinity and sched _getaffinity.

    The drawback is that it is highly Linux-specific.

提交回复
热议问题