Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: non-numeric kernel_version on the OVH platform #16679

Closed
nejib1 opened this issue Jun 24, 2020 · 5 comments · Fixed by #16708
Closed

BUG: non-numeric kernel_version on the OVH platform #16679

nejib1 opened this issue Jun 24, 2020 · 5 comments · Fixed by #16708
Labels
00 - Bug Priority: high High priority, also add milestones for urgent issues

Comments

@nejib1
Copy link

nejib1 commented Jun 24, 2020

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.

@pistach3
Copy link

Hi,

I'm having the same issue with the kernel shipped with OVH.
I see you are making the pull request. Thanks !

@seberg
Copy link
Member

seberg commented Jun 24, 2020

Hmmm, my error, why didn't I use looseversion here?

@seberg seberg added 00 - Bug Priority: high High priority, also add milestones for urgent issues labels Jun 24, 2020
@seberg seberg added this to the 1.19.1 release milestone Jun 24, 2020
@mattip mattip changed the title Issue in usr\local\lib\python3.8\site-packages\numpy\__init__.py BUG: non-numeric kernel_version on the OVH platform Jun 24, 2020
@seberg
Copy link
Member

seberg commented Jun 24, 2020

Oh, looking again (sorry missing things a bit more today), that is a strange version string, dropping the micro-release. But, it seems that LooseVersion does handle it correctly, so I think we can just use that here. Although I guess importing distutils may be slow, so maybe just add a try:/except: its not very important to begin with.

@charris charris added the 09 - Backport-Candidate PRs tagged should be backported label Jun 25, 2020
@anirudh2290
Copy link
Member

I couldnt find the pull request, @nejib1 do you happen to be working on it.

@charris
Copy link
Member

charris commented Jun 29, 2020

@anirudh2290 There isn't a PR, could you make one? There seem to be two fixes, one given in the report and @seberg use of LooseVersion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug Priority: high High priority, also add milestones for urgent issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants