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.

FindNumPy.cmake 2.2 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # - Find the NumPy libraries
  2. # This module finds if NumPy is installed, and sets the following variables
  3. # indicating where it is.
  4. #
  5. # TODO: Update to provide the libraries and paths for linking npymath lib.
  6. #
  7. # NUMPY_FOUND - was NumPy found
  8. # NUMPY_VERSION - the version of NumPy found as a string
  9. # NUMPY_VERSION_MAJOR - the major version number of NumPy
  10. # NUMPY_VERSION_MINOR - the minor version number of NumPy
  11. # NUMPY_VERSION_PATCH - the patch version number of NumPy
  12. # NUMPY_VERSION_DECIMAL - e.g. version 1.6.1 is 10601
  13. # NUMPY_INCLUDE_DIR - path to the NumPy include files
  14. unset(NUMPY_VERSION)
  15. unset(NUMPY_INCLUDE_DIR)
  16. if(PYTHONINTERP_FOUND)
  17. execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
  18. "import numpy as n; print(n.__version__); print(n.get_include());"
  19. RESULT_VARIABLE __result
  20. OUTPUT_VARIABLE __output
  21. OUTPUT_STRIP_TRAILING_WHITESPACE)
  22. if(__result MATCHES 0)
  23. string(REGEX REPLACE ";" "\\\\;" __values ${__output})
  24. string(REGEX REPLACE "\r?\n" ";" __values ${__values})
  25. list(GET __values 0 NUMPY_VERSION)
  26. list(GET __values 1 NUMPY_INCLUDE_DIR)
  27. string(REGEX MATCH "^([0-9])+\\.([0-9])+\\.([0-9])+" __ver_check "${NUMPY_VERSION}")
  28. if(NOT "${__ver_check}" STREQUAL "")
  29. set(NUMPY_VERSION_MAJOR ${CMAKE_MATCH_1})
  30. set(NUMPY_VERSION_MINOR ${CMAKE_MATCH_2})
  31. set(NUMPY_VERSION_PATCH ${CMAKE_MATCH_3})
  32. math(EXPR NUMPY_VERSION_DECIMAL
  33. "(${NUMPY_VERSION_MAJOR} * 10000) + (${NUMPY_VERSION_MINOR} * 100) + ${NUMPY_VERSION_PATCH}")
  34. string(REGEX REPLACE "\\\\" "/" NUMPY_INCLUDE_DIR ${NUMPY_INCLUDE_DIR})
  35. else()
  36. unset(NUMPY_VERSION)
  37. unset(NUMPY_INCLUDE_DIR)
  38. message(STATUS "Requested NumPy version and include path, but got instead:\n${__output}\n")
  39. endif()
  40. endif()
  41. else()
  42. message(STATUS "To find NumPy Python interpretator is required to be found.")
  43. endif()
  44. include(FindPackageHandleStandardArgs)
  45. find_package_handle_standard_args(NumPy REQUIRED_VARS NUMPY_INCLUDE_DIR NUMPY_VERSION
  46. VERSION_VAR NUMPY_VERSION)
  47. if(NUMPY_FOUND)
  48. message(STATUS "NumPy ver. ${NUMPY_VERSION} found (include: ${NUMPY_INCLUDE_DIR})")
  49. endif()

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