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.

lazy_file.py 702 B

123456789101112131415161718192021222324252627
  1. #
  2. # \file lazy_file.py
  3. #
  4. # \brief LazyFile updates the target file only when the content is changed
  5. # in order to avoid generating new cutlass kimpls each time cmake is called
  6. #
  7. import io
  8. import os
  9. class LazyFile:
  10. def __init__(self, filename):
  11. self.filename = filename
  12. self.buffer = io.StringIO()
  13. def write(self, data):
  14. self.buffer.write(str(data))
  15. def close(self):
  16. if os.path.isfile(self.filename):
  17. old_data = open(self.filename).read()
  18. else:
  19. old_data = ""
  20. new_data = self.buffer.getvalue()
  21. if old_data != new_data:
  22. with open(self.filename, "w") as f:
  23. f.write(new_data)

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