Numpy: BUG:OVH平台上的非数字kernel_version

创建于 2020-06-24  ·  5评论  ·  资料来源: numpy/numpy

您好,当检测内核版本时,__ini__.py(Python3.8)的代码中有错误。
我找到了解决方案,但在此详细说明问题以帮助其他用户。

    # We usually use madvise hugepages support, but on some old kernels it
    # is slow and thus better avoided.
    # Specifically kernel version 4.6 had a bug fix which probably fixed this:
    # https://github.com/torvalds/linux/commit/7cf91a98e607c2f935dbcc177d70011e95b8faff
    import os
    use_hugepage = os.environ.get("NUMPY_MADVISE_HUGEPAGE", None)
    if sys.platform == "linux" and use_hugepage is None:
        use_hugepage = 1
        kernel_version = os.uname().release.split(".")[:2]
        kernel_version = tuple(int(v) for v in kernel_version)
        if kernel_version < (4, 6):
            use_hugepage = 0
    elif use_hugepage is None:
        # This is not Linux, so it should not matter, just enable anyway
        use_hugepage = 1
    else:
        use_hugepage = int(use_hugepage)

    # Note that this will currently only make a difference on Linux
    core.multiarray._set_madvise_hugepage(use_hugepage)

错误信息:

# usr\local\lib\python3.8\site-packages\numpy\__init__.py

 #python3.8 test.py
['4', '19-ovh-xxxx-std-ipv6-64']
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    kernel_version = tuple(int(v) for v in kernel_version)
  File "test.py", line 4, in <genexpr>
    kernel_version = tuple(int(v) for v in kernel_version)
ValueError: invalid literal for int() with base 10: '19-ovh-xxxx-std-ipv6-64'

Numpy / Python版本信息:

要解决此错误,以下是解决方法:

python kernel_version = tuple(int(v[0:2]) for v in kernel_version)

int (v [0: 2] )截断字符串以正确恢复INT。

00 - Bug high

所有5条评论

你好

OVH随附的内核出现相同的问题。
我看到您正在提出拉取请求。 谢谢 !

嗯,我的错误,为什么我在这里不使用松动版本?

哦,再看一遍(很抱歉今天丢失了更多东西),那是一个奇怪的版本字符串,删除了微发行版。 但是,似乎LooseVersion确实可以正确处理它,所以我认为我们可以在这里使用它。 尽管我猜想导入distutils可能很慢,所以也许只添加try:/except:并不是很重要。

我找不到拉取请求, @ nejib1您是否正在处理它。

@ anirudh2290没有公关,你能做一个吗? 似乎有两个修复,报告中给出了一个修复,以及@seberg使用LooseVersion

此页面是否有帮助?
0 / 5 - 0 等级