Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose paddle.version.show API and add doc for it #36800

Merged
merged 3 commits into from
Oct 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion python/setup.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

show可以打印下编译时使用的cuda 和 cudnn的版本信息,比如:
cuda: 10.x.x
cudnn: 8.x.x

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已打印cuda和cudnn信息

# 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)
Expand All @@ -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
Expand Down