From d88c3e1200ad04d4c2f0cdc10811d7ee1728b586 Mon Sep 17 00:00:00 2001 From: pangyoki Date: Thu, 28 Oct 2021 17:55:53 +0800 Subject: [PATCH] Expose paddle.version.show API and add doc for it (#36800) * add doc for show() in paddle.version * fix format * print cuda and cudnn in show API --- python/setup.py.in | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/python/setup.py.in b/python/setup.py.in index 03b0555c96..0642a96fb0 100644 --- a/python/setup.py.in +++ b/python/setup.py.in @@ -100,9 +100,50 @@ istaged = %(istaged)s commit = '%(commit)s' with_mkl = '%(with_mkl)s' -__all__ = ['cuda', 'cudnn'] +__all__ = ['cuda', 'cudnn', 'show'] def show(): + """Get the version of paddle if `paddle` package if tagged. Otherwise, output the corresponding commit id. + + Returns: + If paddle package is not tagged, the commit-id of paddle will be output. + Otherwise, the following information will be output. + + full_version: version of paddle + + major: the major version of paddle + + minor: the minor version of paddle + + patch: the patch level version of paddle + + rc: whether it's rc version + + cuda: the cuda version of package. It will return `False` if CPU version paddle package is installed + + cudnn: the cudnn version of package. It will return `False` if CPU version paddle package is installed + + Examples: + .. code-block:: python + + import paddle + + # Case 1: paddle is tagged with 2.2.0 + paddle.version.show() + # full_version: 2.2.0 + # major: 2 + # minor: 2 + # patch: 0 + # rc: 0 + # cuda: '10.2' + # cudnn: '7.6.5' + + # Case 2: paddle is not tagged + paddle.version.show() + # commit: cfa357e984bfd2ffa16820e354020529df434f7d + # cuda: '10.2' + # cudnn: '7.6.5' + """ if istaged: print('full_version:', full_version) print('major:', major) @@ -111,6 +152,8 @@ def show(): print('rc:', rc) else: print('commit:', commit) + print('cuda:', cuda_version) + print('cudnn:', cudnn_version) def mkl(): return with_mkl -- GitLab