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.

device_options.h 1.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * \file lite/load_and_run/src/options/device_options.h
  3. *
  4. * This file is part of MegEngine, a deep learning framework developed by
  5. * Megvii.
  6. *
  7. * \copyright Copyright (c) 2020-2021 Megvii Inc. All rights reserved.
  8. */
  9. #pragma once
  10. #include <gflags/gflags.h>
  11. #include "models/model.h"
  12. #include "option_base.h"
  13. DECLARE_bool(cpu);
  14. #if MGE_WITH_CUDA
  15. DECLARE_bool(cuda);
  16. #endif
  17. DECLARE_bool(cpu_default);
  18. DECLARE_int32(multithread);
  19. DECLARE_int32(multithread_default);
  20. DECLARE_string(multi_thread_core_ids);
  21. namespace lar {
  22. class XPUDeviceOption final : public OptionBase {
  23. public:
  24. static bool is_valid();
  25. static std::shared_ptr<OptionBase> create_option();
  26. void config_model(
  27. RuntimeParam& runtime_param, std::shared_ptr<ModelBase> model) override;
  28. std::string option_name() const override { return m_option_name; };
  29. private:
  30. XPUDeviceOption();
  31. template <typename ModelImpl>
  32. void config_model_internel(RuntimeParam&, std::shared_ptr<ModelImpl>){};
  33. bool enable_cpu;
  34. #if MGE_WITH_CUDA
  35. bool enable_cuda;
  36. #endif
  37. bool enable_cpu_default;
  38. bool enable_multithread;
  39. bool enable_multithread_default;
  40. bool enable_set_core_ids;
  41. size_t thread_num;
  42. std::vector<int> core_ids;
  43. std::string m_option_name;
  44. };
  45. } // namespace lar

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