- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正尝试按照 Why does multiprocessing use only a single core after I import numpy? 中的建议,使用“os.sched_getaffinity”方法检查我的脚本使用的核心数.但是当我运行时
import os
os.sched_getaffinity(0)
我明白了
AttributeError
Traceback (most recent call last) <ipython-input-1-895d9c252fd1> in <module>()
1 import os
----> 2 os.sched_getaffinity(0)
AttributeError: module 'os' has no attribute 'sched_getaffinity'
这里出了什么问题? “os”模块中的其他标准方法似乎有效。我正在使用 Python 3.6.0 运行 Anaconda 4.3.0。我在 Mac 和 Linux 上都试过了。检查和更改任务亲和性的任何替代方法?
最佳答案
文档说“它们仅在某些 Unix 平台上可用。”我想您的平台不是这些功能集受支持的平台之一。您可以通过键入检查提供的内容
>>> import os
>>> print(dir(os))
该功能在我的 Debian Linux 机器上确实存在,但在 Windows 和 OSX 上也没有。我不知道为什么它不在你的 Linux 机器上。也许您的 Linux 太旧了?
还有一个简单的谷歌“python process affinity”给出了几种选择
关于 python 3.6.0 : 'os' module does not have 'sched_getaffinity' method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42538153/
我正尝试按照 Why does multiprocessing use only a single core after I import numpy? 中的建议,使用“os.sched_getaff
我正在尝试: 与处理器固定同时运行 16 个副本(每个内核 2 个副本) 与处理器固定(每个内核 2 个副本)并发运行 8 个副本,并在某些功能说功能 1 完成后将处理器内核翻转到最远的内核。 我面临
我是一名优秀的程序员,十分优秀!