浏览代码

Fixing CPU resource allocation for new CI (#4525)

* Fixing CPU resource allocation for new CI

* Update ml-agents/mlagents/torch_utils/cpu_utils.py

Co-authored-by: Ervin T. <ervin@unity3d.com>

* [skip ci] testing

* use shares only if on kubernetes

Co-authored-by: Ervin T. <ervin@unity3d.com>
/MLA-1734-demo-provider
GitHub 4 年前
当前提交
28950f55
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7
      ml-agents/mlagents/torch_utils/cpu_utils.py

7
ml-agents/mlagents/torch_utils/cpu_utils.py


"""
period = _read_in_integer_file("/sys/fs/cgroup/cpu/cpu.cfs_period_us")
quota = _read_in_integer_file("/sys/fs/cgroup/cpu/cpu.cfs_quota_us")
share = _read_in_integer_file("/sys/fs/cgroup/cpu/cpu.shares")
is_kubernetes = os.getenv("KUBERNETES_SERVICE_HOST") is not None
elif period > 0 and share > 0 and is_kubernetes:
# In kubernetes, each requested CPU is 1024 CPU shares
# https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#how-pods-with-resource-limits-are-run
return int(share // 1024)
else:
return os.cpu_count()

正在加载...
取消
保存