Skip to content

Commit

Permalink
MAINT: Disable use_hugepages in case of ValueError
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudh2290 committed Jun 30, 2020
1 parent 76924ed commit e29f5d8
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions numpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,11 +338,18 @@ def _mac_os_check():
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
# If there is an issue with parsing the kernel version,
# set use_hugepages to 0. Usage of LooseVersion will handle
# the kernel version parsing better, but avoided since it
# will increase the import time. See: #16679 for related discussion.
try:
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
except ValueError:
use_hugepages = 0
elif use_hugepage is None:
# This is not Linux, so it should not matter, just enable anyway
use_hugepage = 1
Expand Down

0 comments on commit e29f5d8

Please sign in to comment.