!45789 only linux need to pre-load libgomp.so

Merge pull request !45789 from zhoufeng/xiu-ba-ge
This commit is contained in:
i-robot 2022-11-23 07:45:31 +00:00 committed by Gitee
commit b54a977468
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 9 additions and 8 deletions

View File

@ -491,14 +491,15 @@ def set_env(device, library_path):
def check_version_and_env_config():
"""check version and env config"""
# Note: pre-load libgomp.so to solve error like "cannot allocate memory in statis TLS block"
try:
import ctypes
ctypes.cdll.LoadLibrary("libgomp.so.1")
except OSError:
logger.warning(
"Pre-Load Lirary libgomp.so.1 failed, this might cause cannot allocate TLS memory problem, "
"if so find solution in FAQ in https://www.mindspore.cn/docs/en/master/faq/installation.html.")
if platform.system().lower() == 'linux':
# Note: pre-load libgomp.so to solve error like "cannot allocate memory in statis TLS block"
try:
import ctypes
ctypes.cdll.LoadLibrary("libgomp.so.1")
except OSError:
logger.warning(
"Pre-Load Lirary libgomp.so.1 failed, this might cause cannot allocate TLS memory problem, "
"if so find solution in FAQ in https://www.mindspore.cn/docs/en/master/faq/installation.html.")
if not os.getenv("MS_DEV_CLOSE_VERSION_CHECK") is None:
return
MSContext.get_instance().register_check_env_callback(check_env)