rich-agent-87730
02/24/2023, 4:34 PM/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_us I get -1.straight-shampoo-11124
02/24/2023, 4:41 PMrich-agent-87730
02/24/2023, 4:41 PMvictorious-lawyer-58417
02/24/2023, 4:43 PMrich-agent-87730
02/24/2023, 4:43 PMvictorious-lawyer-58417
02/24/2023, 4:43 PMrich-agent-87730
02/24/2023, 4:44 PMvictorious-lawyer-58417
02/24/2023, 4:44 PM@resourcesrich-agent-87730
02/24/2023, 4:45 PMvictorious-lawyer-58417
02/24/2023, 4:50 PMfrom metaflow import FlowSpec, current, resources, Parameter, step, Task
class CPUCountFlow(FlowSpec):
@resources(cpu=8)
@step
def start(self):
print('cpu count', self.cpu_count())
self.next(self.end)
@step
def end(self):
print("done!")
def cpu_count(self):
decos = self._graph_info['steps'][current.step_name]['decorators']
for deco in decos:
if deco['name'] == 'resources':
return deco['attributes']['cpu']
if __name__ == '__main__':
CPUCountFlow()victorious-lawyer-58417
02/24/2023, 4:50 PM@batchvictorious-lawyer-58417
02/24/2023, 4:53 PM@resources explicitly and this simple example doesn't grab the count from @batch but that's easy to fix)rich-agent-87730
02/24/2023, 4:55 PM/sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_usrich-agent-87730
02/24/2023, 4:56 PMos.cpu_count() to determine how many parallel processes to run. when I execute this on batch, I run more processes than whats been constricted by @resourcevictorious-lawyer-58417
02/24/2023, 4:57 PMos.cpu_count() and multiprocessing.cpu_count() return all available cores on Batch, which is often too highvictorious-lawyer-58417
02/24/2023, 4:58 PMvictorious-lawyer-58417
02/24/2023, 4:58 PMrich-agent-87730
02/24/2023, 4:59 PMvictorious-lawyer-58417
02/24/2023, 4:59 PM@resources match instance sizes, so min==max, which effectively disables burstingrich-agent-87730
02/24/2023, 5:00 PMcpu_count() function to grab the minimum amount in batch?victorious-lawyer-58417
02/24/2023, 5:03 PMrich-agent-87730
02/24/2023, 5:06 PM--cpu I can look at /sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_us to figure out how much cpu I have.
this would probably be more of a batch/ecs question but do you know of a way that I can determine the constrained cpu count from within the container if I’m using batch. when I look at /sys/fs/cgroup/cpu,cpuacct/cpu.cfs_quota_us from batch, I get -1victorious-lawyer-58417
02/24/2023, 5:08 PMvictorious-lawyer-58417
02/24/2023, 5:11 PM@kubernetes if you need more control over itrich-agent-87730
02/24/2023, 5:26 PMvictorious-lawyer-58417
02/24/2023, 7:25 PM