Spaces:
Build error
Build error
File size: 574 Bytes
5bd179e |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import os
def set_affinity_mask(affinity_mask = None):
if affinity_mask is None:
cpu_count = os.cpu_count()
affinity_mask = set(range(cpu_count))
os.sched_setaffinity(0, affinity_mask)
def set_affinity_list(affinity_list = None):
if affinity_list is None: set_affinity_mask(None)
else: set_affinity_mask(set(affinity_list))
def set_affinity_str(affinity_str = None):
if affinity_str is None or affinity_str.isspace(): set_affinity_mask(None)
aff = [int(alloc) for alloc in affinity_str.split(",")]
set_affinity_list(aff)
|