!46338 Time-consuming optimization of import mindspore
Merge pull request !46338 from jiaorui/check-version
This commit is contained in:
commit
2acf7eaa47
|
@ -1,83 +0,0 @@
|
|||
# Copyright 2020 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ============================================================================
|
||||
"""dependency package version check"""
|
||||
from __future__ import absolute_import
|
||||
|
||||
from argparse import ArgumentParser
|
||||
import sys
|
||||
|
||||
|
||||
def parse_args():
|
||||
"""
|
||||
parse args .
|
||||
|
||||
Args:
|
||||
|
||||
Returns:
|
||||
args.
|
||||
|
||||
Examples:
|
||||
>>> parse_args()
|
||||
"""
|
||||
parser = ArgumentParser(description="MindSpore dependency packages version checker.")
|
||||
parser.add_argument("--mindspore_version", type=str, help="MindSpore version.")
|
||||
parser.add_argument("--supported_version", type=str, action='append', help="Supported environment version.")
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
|
||||
def check_deps_version(mindspore_version, supported_version):
|
||||
"""
|
||||
check te/hccl/topi version
|
||||
|
||||
Args:
|
||||
mindspore_version (str): this mindspore package version
|
||||
supported_version (str list): supported Ascend AI software package version by this mindspore package
|
||||
|
||||
Returns:
|
||||
void
|
||||
"""
|
||||
try:
|
||||
from hccl import sys_version as hccl_version
|
||||
v = '.'.join(hccl_version.__sys_version__.split('.')[0:2])
|
||||
if v not in supported_version:
|
||||
print(f"MindSpore version {mindspore_version} and \"hccl\" wheel package version {v} does not "
|
||||
"match, reference to the match info on: https://www.mindspore.cn/install")
|
||||
from te import version as tever
|
||||
v = '.'.join(tever.version.split('.')[0:2])
|
||||
if v not in supported_version:
|
||||
print(f"MindSpore version {mindspore_version} and \"te\" wheel package version {v} does not "
|
||||
"match, reference to the match info on: https://www.mindspore.cn/install")
|
||||
from topi import version as topiver
|
||||
v = '.'.join(topiver.version.split('.')[0:2])
|
||||
if v not in supported_version:
|
||||
print(f"MindSpore version {mindspore_version} and \"topi\" wheel package version {v} does not "
|
||||
"match, reference to the match info on: https://www.mindspore.cn/install")
|
||||
|
||||
except ImportError as e:
|
||||
print("CheckFailed: ", e.args)
|
||||
print("MindSpore relies on the 3 whl packages of \"te\", \"topi\" and \"hccl\" in the \"latest\" "
|
||||
"folder of the Ascend AI software package (Ascend Data Center Solution), please check whether they "
|
||||
"are installed correctly or not, reference to the match info on: https://www.mindspore.cn/install")
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
check_deps_version(args.mindspore_version, args.supported_version)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.path = sys.path[1:] # avoid the impact of relative path env, only affect this process
|
||||
main()
|
|
@ -334,22 +334,40 @@ class AscendEnvChecker(EnvChecker):
|
|||
te, topi, hccl wheel package version check
|
||||
in order to update the change of 'LD_LIBRARY_PATH' env, run a sub process
|
||||
"""
|
||||
input_args = ["--mindspore_version=" + __version__]
|
||||
for v in self.version:
|
||||
input_args.append("--supported_version=" + v)
|
||||
deps_version_checker = os.path.join(os.path.split(os.path.realpath(__file__))[0],
|
||||
"_check_deps_version.py")
|
||||
call_cmd = [sys.executable, deps_version_checker] + input_args
|
||||
|
||||
mindspore_version = __version__
|
||||
supported_version = self.version
|
||||
attention_warning = False
|
||||
try:
|
||||
process = subprocess.run(call_cmd, timeout=30, text=True, capture_output=True, check=False)
|
||||
if process.stdout.strip() != "":
|
||||
logger.warning(process.stdout.strip())
|
||||
warning_countdown = 3
|
||||
for i in range(warning_countdown, 0, -1):
|
||||
logger.warning(f"Please pay attention to the above warning, countdown: {i}")
|
||||
time.sleep(1)
|
||||
except subprocess.TimeoutExpired:
|
||||
logger.info("Package te, topi, hccl version check timed out, skip.")
|
||||
from te import version as tever
|
||||
v = '.'.join(tever.version.split('.')[0:2])
|
||||
if v not in supported_version:
|
||||
attention_warning = True
|
||||
logger.warning(f"MindSpore version {mindspore_version} and \"te\" wheel package version {v} does not "
|
||||
"match, reference to the match info on: https://www.mindspore.cn/install")
|
||||
from topi import version as topiver
|
||||
v = '.'.join(topiver.version.split('.')[0:2])
|
||||
if v not in supported_version:
|
||||
attention_warning = True
|
||||
logger.warning(f"MindSpore version {mindspore_version} and \"topi\" wheel package version {v} does not "
|
||||
"match, reference to the match info on: https://www.mindspore.cn/install")
|
||||
from hccl import sys_version as hccl_version
|
||||
v = '.'.join(hccl_version.__sys_version__.split('.')[0:2])
|
||||
if v not in supported_version:
|
||||
attention_warning = True
|
||||
logger.warning(f"MindSpore version {mindspore_version} and \"hccl\" wheel package version {v} does not "
|
||||
"match, reference to the match info on: https://www.mindspore.cn/install")
|
||||
except ImportError as e:
|
||||
logger.error("CheckFailed:", e.args)
|
||||
logger.error("MindSpore relies on the 3 whl packages of \"te\", \"topi\" and \"hccl\" in the \"latest\" "
|
||||
"folder of the Ascend AI software package (Ascend Data Center Solution), please check whether"
|
||||
" they are installed correctly or not, reference to the match info on: "
|
||||
"https://www.mindspore.cn/install")
|
||||
if attention_warning:
|
||||
warning_countdown = 3
|
||||
for i in range(warning_countdown, 0, -1):
|
||||
logger.warning(f"Please pay attention to the above warning, countdown: {i}")
|
||||
time.sleep(1)
|
||||
|
||||
def set_env(self):
|
||||
plugin_dir = os.path.dirname(self.library_path)
|
||||
|
|
Loading…
Reference in New Issue