-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Closed
Labels
00 - BugPriority: highHigh priority, also add milestones for urgent issuesHigh priority, also add milestones for urgent issues
Description
Hello, there is an error in the code of ini.py (Python3.8) , when detecting the version of the Kernel.
I found the solution but I detail the problem here to help other users.
# 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)Error message:
# 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 version information:
To fix this error, here is the solution:
kernel_version = tuple(int(v[0:2]) for v in kernel_version) The int (v [0: 2] ) truncate the string to recover the INT correctly.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
00 - BugPriority: highHigh priority, also add milestones for urgent issuesHigh priority, also add milestones for urgent issues