From a4c25b2f349fcbe80d707fef9443e5fa19971c7e Mon Sep 17 00:00:00 2001 From: Zhang Ting Date: Mon, 28 Sep 2020 17:22:21 +0800 Subject: [PATCH] use paddle.is_compile_with_cuda (#27586) * modify doc --- python/paddle/__init__.py | 1 + python/paddle/device.py | 3 ++- python/paddle/fluid/framework.py | 6 +++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/python/paddle/__init__.py b/python/paddle/__init__.py index e707de8e068..93b9a71ed7d 100755 --- a/python/paddle/__init__.py +++ b/python/paddle/__init__.py @@ -257,6 +257,7 @@ from .tensor.stat import numel #DEFINE_ALIAS from .device import get_cudnn_version from .device import set_device from .device import get_device +from .device import is_compiled_with_cuda #DEFINE_ALIAS from .device import is_compiled_with_xpu from .device import XPUPlace # from .tensor.tensor import Tensor #DEFINE_ALIAS diff --git a/python/paddle/device.py b/python/paddle/device.py index 46d0ff7bedc..c2f331caa8a 100644 --- a/python/paddle/device.py +++ b/python/paddle/device.py @@ -18,6 +18,7 @@ import re from paddle.fluid import core from paddle.fluid import framework from paddle.fluid.dygraph.parallel import ParallelEnv +from paddle.fluid.framework import is_compiled_with_cuda #DEFINE_ALIAS __all__ = [ 'get_cudnn_version', @@ -31,7 +32,7 @@ __all__ = [ # 'cuda_places', # 'CUDAPinnedPlace', # 'CUDAPlace', - # 'is_compiled_with_cuda' + 'is_compiled_with_cuda' ] _cudnn_version = None diff --git a/python/paddle/fluid/framework.py b/python/paddle/fluid/framework.py index 2afe3ac3d76..d4a4b135cdb 100644 --- a/python/paddle/fluid/framework.py +++ b/python/paddle/fluid/framework.py @@ -360,13 +360,13 @@ def is_compiled_with_cuda(): """ Whether this whl package can be used to run the model on GPU. - Returns (bool): support gpu or not. + Returns (bool): `True` if CUDA is currently available, otherwise `False`. Examples: .. code-block:: python - import paddle.fluid as fluid - support_gpu = fluid.is_compiled_with_cuda() + import paddle + support_gpu = paddle.is_compiled_with_cuda() """ return core.is_compiled_with_cuda() -- GitLab