diff --git a/cmake/external/xpu.cmake b/cmake/external/xpu.cmake index 26166aa8b600a101470899001e980ce05e7446b4..4711ce83da7d530a9b224bf7c3d077700433fdab 100644 --- a/cmake/external/xpu.cmake +++ b/cmake/external/xpu.cmake @@ -7,16 +7,20 @@ set(XPU_PROJECT "extern_xpu") set(XPU_API_LIB_NAME "libxpuapi.so") set(XPU_RT_LIB_NAME "libxpurt.so") +set(XPU_BASE_DATE "20230114") +set(XPU_XCCL_BASE_VERSION "1.0.7") + if(NOT DEFINED XPU_BASE_URL) set(XPU_BASE_URL_WITHOUT_DATE "https://baidu-kunlun-product.su.bcebos.com/KL-SDK/klsdk-dev") - set(XPU_BASE_URL "${XPU_BASE_URL_WITHOUT_DATE}/20230114") + set(XPU_BASE_URL "${XPU_BASE_URL_WITHOUT_DATE}/${XPU_BASE_DATE}") else() set(XPU_BASE_URL "${XPU_BASE_URL}") endif() set(XPU_XCCL_BASE_URL - "https://klx-sdk-release-public.su.bcebos.com/xccl/release/1.0.7") + "https://klx-sdk-release-public.su.bcebos.com/xccl/release/${XPU_XCCL_BASE_VERSION}" +) if(WITH_AARCH64) set(XPU_XRE_DIR_NAME "xre-kylin_aarch64") diff --git a/python/setup.py.in b/python/setup.py.in index 71a1cfb748198aaf6a5b3bfa05ba2c0af19e5bf5..aee0e69a06d6c43b380007f2ce649ffb1ee3e5ba 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -75,6 +75,18 @@ def get_cudnn_version(): else: return 'False' +def get_xpu_version(): + if '@WITH_XPU@' == 'ON': + return '@XPU_BASE_DATE@' + else: + return 'False' + +def get_xpu_xccl_version(): + if '@WITH_XPU_BKCL@' == 'ON': + return '@XPU_XCCL_BASE_VERSION@' + else: + return 'False' + def is_taged(): try: cmd = ['git', 'describe', '--exact-match', '--tags', 'HEAD', '2>/dev/null'] @@ -91,18 +103,20 @@ def is_taged(): def write_version_py(filename='paddle/version/__init__.py'): cnt = '''# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY # -full_version = '%(major)d.%(minor)d.%(patch)s' -major = '%(major)d' -minor = '%(minor)d' -patch = '%(patch)s' -rc = '%(rc)d' -cuda_version = '%(cuda)s' -cudnn_version = '%(cudnn)s' -istaged = %(istaged)s -commit = '%(commit)s' -with_mkl = '%(with_mkl)s' - -__all__ = ['cuda', 'cudnn', 'show'] +full_version = '%(major)d.%(minor)d.%(patch)s' +major = '%(major)d' +minor = '%(minor)d' +patch = '%(patch)s' +rc = '%(rc)d' +cuda_version = '%(cuda)s' +cudnn_version = '%(cudnn)s' +xpu_version = '%(xpu)s' +xpu_xccl_version = '%(xpu_xccl)s' +istaged = %(istaged)s +commit = '%(commit)s' +with_mkl = '%(with_mkl)s' + +__all__ = ['cuda', 'cudnn', 'show', 'xpu', 'xpu_xccl'] def show(): """Get the version of paddle if `paddle` package if tagged. Otherwise, output the corresponding commit id. @@ -125,6 +139,10 @@ def show(): cudnn: the cudnn version of package. It will return `False` if CPU version paddle package is installed + xpu: the xpu version of package. It will return `False` if non-XPU version paddle package is installed + + xpu_xccl: the xpu xccl version of package. It will return `False` if non-XPU version paddle package is installed + Examples: .. code-block:: python @@ -139,12 +157,16 @@ def show(): # rc: 0 # cuda: '10.2' # cudnn: '7.6.5' + # xpu: '20230114' + # xpu_xccl: '1.0.7' # Case 2: paddle is not tagged paddle.version.show() # commit: cfa357e984bfd2ffa16820e354020529df434f7d # cuda: '10.2' # cudnn: '7.6.5' + # xpu: '20230114' + # xpu_xccl: '1.0.7' """ if istaged: print('full_version:', full_version) @@ -156,6 +178,8 @@ def show(): print('commit:', commit) print('cuda:', cuda_version) print('cudnn:', cudnn_version) + print('xpu:', xpu_version) + print('xpu_xccl:', xpu_xccl_version) def mkl(): return with_mkl @@ -165,7 +189,7 @@ def cuda(): Returns: string: Return the version information of cuda. If paddle package is CPU version, it will return False. - + Examples: .. code-block:: python @@ -182,7 +206,7 @@ def cudnn(): Returns: string: Return the version information of cudnn. If paddle package is CPU version, it will return False. - + Examples: .. code-block:: python @@ -193,6 +217,40 @@ def cudnn(): """ return cudnn_version + +def xpu(): + """Get xpu version of paddle package. + + Returns: + string: Return the version information of xpu. If paddle package is non-XPU version, it will return False. + + Examples: + .. code-block:: python + + import paddle + + paddle.version.xpu() + # '20230114' + + """ + return xpu_version + +def xpu_xccl(): + """Get xpu xccl version of paddle package. + + Returns: + string: Return the version information of xpu xccl. If paddle package is non-XPU version, it will return False. + + Examples: + .. code-block:: python + + import paddle + + paddle.version.xpu_xccl() + # '1.0.7' + + """ + return xpu_xccl_version ''' commit = git_commit() @@ -213,6 +271,8 @@ def cudnn(): 'version': '${PADDLE_VERSION}', 'cuda': get_cuda_version(), 'cudnn': get_cudnn_version(), + 'xpu': get_xpu_version(), + 'xpu_xccl': get_xpu_xccl_version(), 'commit': commit, 'istaged': is_taged(), 'with_mkl': '@WITH_MKL@'}) @@ -463,7 +523,7 @@ shutil.copy('${WARPCTC_LIBRARIES}', libs_path) shutil.copy('${WARPRNNT_LIBRARIES}', libs_path) package_data['paddle.libs']+=[ - os.path.basename('${LAPACK_LIB}'), + os.path.basename('${LAPACK_LIB}'), os.path.basename('${BLAS_LIB}'), os.path.basename('${GFORTRAN_LIB}'), os.path.basename('${GNU_RT_LIB_1}')] diff --git a/setup.py b/setup.py index 90be1f9bb254fadf820426a2337ddcdd197308b1..8737de4e36a6cf0f0246e1641408c2d190cbda99 100644 --- a/setup.py +++ b/setup.py @@ -345,6 +345,22 @@ def get_cudnn_version(): return 'False' +def get_xpu_version(): + with_xpu = env_dict.get("WITH_XPU") + if with_xpu == 'ON': + return env_dict.get("XPU_BASE_DATE") + else: + return 'False' + + +def get_xpu_xccl_version(): + with_xpu_xccl = env_dict.get("WITH_XPU_BKCL") + if with_xpu_xccl == 'ON': + return env_dict.get("XPU_XCCL_BASE_VERSION") + else: + return 'False' + + def is_taged(): try: cmd = [ @@ -376,18 +392,20 @@ def is_taged(): def write_version_py(filename='paddle/version/__init__.py'): cnt = '''# THIS FILE IS GENERATED FROM PADDLEPADDLE SETUP.PY # -full_version = '%(major)d.%(minor)d.%(patch)s' -major = '%(major)d' -minor = '%(minor)d' -patch = '%(patch)s' -rc = '%(rc)d' -cuda_version = '%(cuda)s' -cudnn_version = '%(cudnn)s' -istaged = %(istaged)s -commit = '%(commit)s' -with_mkl = '%(with_mkl)s' - -__all__ = ['cuda', 'cudnn', 'show'] +full_version = '%(major)d.%(minor)d.%(patch)s' +major = '%(major)d' +minor = '%(minor)d' +patch = '%(patch)s' +rc = '%(rc)d' +cuda_version = '%(cuda)s' +cudnn_version = '%(cudnn)s' +xpu_version = '%(xpu)s' +xpu_xccl_version = '%(xpu_xccl)s' +istaged = %(istaged)s +commit = '%(commit)s' +with_mkl = '%(with_mkl)s' + +__all__ = ['cuda', 'cudnn', 'show', 'xpu', 'xpu_xccl'] def show(): """Get the version of paddle if `paddle` package if tagged. Otherwise, output the corresponding commit id. @@ -410,6 +428,10 @@ def show(): cudnn: the cudnn version of package. It will return `False` if CPU version paddle package is installed + xpu: the xpu version of package. It will return `False` if non-XPU version paddle package is installed + + xpu_xccl: the xpu xccl version of package. It will return `False` if non-XPU version paddle package is installed + Examples: .. code-block:: python @@ -424,12 +446,16 @@ def show(): # rc: 0 # cuda: '10.2' # cudnn: '7.6.5' + # xpu: '20230114' + # xpu_xccl: '1.0.7' # Case 2: paddle is not tagged paddle.version.show() # commit: cfa357e984bfd2ffa16820e354020529df434f7d # cuda: '10.2' # cudnn: '7.6.5' + # xpu: '20230114' + # xpu_xccl: '1.0.7' """ if istaged: print('full_version:', full_version) @@ -441,6 +467,8 @@ def show(): print('commit:', commit) print('cuda:', cuda_version) print('cudnn:', cudnn_version) + print('xpu:', xpu_version) + print('xpu_xccl:', xpu_xccl_version) def mkl(): return with_mkl @@ -478,6 +506,40 @@ def cudnn(): """ return cudnn_version + +def xpu(): + """Get xpu version of paddle package. + + Returns: + string: Return the version information of xpu. If paddle package is non-XPU version, it will return False. + + Examples: + .. code-block:: python + + import paddle + + paddle.version.xpu() + # '20230114' + + """ + return xpu_version + +def xpu_xccl(): + """Get xpu xccl version of paddle package. + + Returns: + string: Return the version information of xpu xccl. If paddle package is non-XPU version, it will return False. + + Examples: + .. code-block:: python + + import paddle + + paddle.version.xpu_xccl() + # '1.0.7' + + """ + return xpu_xccl_version ''' commit = git_commit() @@ -500,6 +562,8 @@ def cudnn(): 'version': env_dict.get("PADDLE_VERSION"), 'cuda': get_cuda_version(), 'cudnn': get_cudnn_version(), + 'xpu': get_xpu_version(), + 'xpu_xccl': get_xpu_xccl_version(), 'commit': commit, 'istaged': is_taged(), 'with_mkl': env_dict.get("WITH_MKL"),