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.

debug_param.py 1.9 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # -*- coding: utf-8 -*-
  2. # MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  3. #
  4. # Copyright (c) 2014-2020 Megvii Inc. All rights reserved.
  5. #
  6. # Unless required by applicable law or agreed to in writing,
  7. # software distributed under the License is distributed on an
  8. # "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. import os
  10. _conv_execution_strategy = os.getenv("MEGENGINE_CONV_EXECUTION_STRATEGY", "HEURISTIC")
  11. def get_conv_execution_strategy() -> str:
  12. """Returns the execuation strategy of :class:`~.Conv2d`.
  13. See :func:`~.set_conv_execution_strategy` for possible return values
  14. """
  15. return _conv_execution_strategy
  16. def set_conv_execution_strategy(option: str):
  17. """Sets the execuation strategy of :class:`~.Conv2d`.
  18. :param option: Decides how :class:`~.Conv2d` algorithm is chosen.
  19. Available values:
  20. * 'HEURISTIC' uses heuristic to choose the fastest algorithm.
  21. * 'PROFILE' runs possible algorithms on real device to find the best one.
  22. * 'PROFILE_HEURISTIC' uses profiling result and heuristic to choose the fastest algorithm.
  23. * 'PROFILE_REPRODUCIBLE' uses the fastest of profiling result that is also reproducible.
  24. * 'HEURISTIC_REPRODUCIBLE' uses heuristic to choose the fastest algorithm that is also reproducible.
  25. The default strategy is 'HEURISTIC'.
  26. It can also be set through the environment variable 'MEGENGINE_CONV_EXECUTION_STRATEGY'.
  27. """
  28. valid_option = (
  29. "HEURISTIC",
  30. "PROFILE",
  31. "PROFILE_HEURISTIC",
  32. "PROFILE_REPRODUCIBLE",
  33. "HEURISTIC_REPRODUCIBLE",
  34. )
  35. if not option in valid_option:
  36. raise ValueError("Valid option can only be one of {}".format(valid_option))
  37. global _conv_execution_strategy # pylint: disable=global-statement
  38. _conv_execution_strategy = option

MegEngine 安装包中集成了使用 GPU 运行代码所需的 CUDA 环境,不用区分 CPU 和 GPU 版。 如果想要运行 GPU 程序,请确保机器本身配有 GPU 硬件设备并安装好驱动。 如果你想体验在云端 GPU 算力平台进行深度学习开发的感觉,欢迎访问 MegStudio 平台