You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

_check_deps_version.py 3.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # Copyright 2020 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ============================================================================
  15. """dependency package version check"""
  16. from argparse import ArgumentParser
  17. import sys
  18. def parse_args():
  19. """
  20. parse args .
  21. Args:
  22. Returns:
  23. args.
  24. Examples:
  25. >>> parse_args()
  26. """
  27. parser = ArgumentParser(description="MindSpore dependency packages version checker.")
  28. parser.add_argument("--mindspore_version", type=str, help="MindSpore version.")
  29. parser.add_argument("--supported_version", type=str, action='append', help="Supported environment version.")
  30. args = parser.parse_args()
  31. return args
  32. def check_deps_version(mindspore_version, supported_version):
  33. """
  34. check te/hccl/topi version
  35. Args:
  36. mindspore_version (str): this mindspore package version
  37. supported_version (str list): supported Ascend 910 AI software package version by this mindspore package
  38. Returns:
  39. void
  40. """
  41. try:
  42. from hccl import sys_version as hccl_version
  43. v = hccl_version.__sys_version__
  44. if v not in supported_version:
  45. print(f"MindSpore version {mindspore_version} and \"hccl\" wheel package version {v} does not "
  46. "match, reference to the match info on: https://www.mindspore.cn/install")
  47. import te
  48. v = te.__version__
  49. if v not in supported_version:
  50. print(f"MindSpore version {mindspore_version} and \"te\" wheel package version {v} does not "
  51. "match, reference to the match info on: https://www.mindspore.cn/install")
  52. import topi
  53. v = topi.__version__
  54. if v not in supported_version:
  55. print(f"MindSpore version {mindspore_version} and \"topi\" wheel package version {v} does not "
  56. "match, reference to the match info on: https://www.mindspore.cn/install")
  57. # pylint: disable=broad-except
  58. except Exception as e:
  59. print("CheckFailed: ", e.args)
  60. print("Minspore relies on the 3 whl packages of \"te\", \"topi\" and \"hccl\" in the \"fwkacllib\" "
  61. "folder of the Ascend 910 AI software package, please check whether they are installed "
  62. "correctly or not, reference to the match info on: https://www.mindspore.cn/install")
  63. def main():
  64. args = parse_args()
  65. check_deps_version(args.mindspore_version, args.supported_version)
  66. if __name__ == "__main__":
  67. sys.path = sys.path[1:] # avoid the impact of relative path env, only affect this process
  68. main()