Skip to content

Commit

Permalink
[ROCM] add is_compiled_with_rocm api, test=develop (#33043)
Browse files Browse the repository at this point in the history
  • Loading branch information
qili93 committed May 27, 2021
1 parent 8c6bbb4 commit 6a5b7e5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 2 additions & 0 deletions python/paddle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@
from .device import set_device # noqa: F401
from .device import get_device # noqa: F401
from .fluid.framework import is_compiled_with_cuda # noqa: F401
from .fluid.framework import is_compiled_with_rocm # noqa: F401
from .device import is_compiled_with_xpu # noqa: F401
from .device import is_compiled_with_npu # noqa: F401
from .device import XPUPlace # noqa: F401
Expand Down Expand Up @@ -384,6 +385,7 @@
'less_equal',
'triu',
'is_compiled_with_cuda',
'is_compiled_with_rocm',
'sin',
'dist',
'unbind',
Expand Down
2 changes: 2 additions & 0 deletions python/paddle/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from paddle.fluid import framework
from paddle.fluid.dygraph.parallel import ParallelEnv
from paddle.fluid.framework import is_compiled_with_cuda #DEFINE_ALIAS
from paddle.fluid.framework import is_compiled_with_rocm #DEFINE_ALIAS

__all__ = [
'get_cudnn_version',
Expand All @@ -33,6 +34,7 @@
# 'CUDAPinnedPlace',
# 'CUDAPlace',
'is_compiled_with_cuda',
'is_compiled_with_rocm',
'is_compiled_with_npu'
]

Expand Down
16 changes: 16 additions & 0 deletions python/paddle/fluid/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
'cuda_pinned_places',
'in_dygraph_mode',
'is_compiled_with_cuda',
'is_compiled_with_rocm',
'is_compiled_with_xpu',
'Variable',
'require_version',
Expand Down Expand Up @@ -398,6 +399,21 @@ def is_compiled_with_cuda():
return core.is_compiled_with_cuda()


def is_compiled_with_rocm():
"""
Whether this whl package can be used to run the model on AMD or Hygon GPU(ROCm).
Returns (bool): `True` if ROCm is currently available, otherwise `False`.
Examples:
.. code-block:: python
import paddle
support_gpu = paddle.is_compiled_with_rocm()
"""
return core.is_compiled_with_rocm()


def cuda_places(device_ids=None):
"""
**Note**:
Expand Down
4 changes: 2 additions & 2 deletions python/paddle/utils/cpp_extension/cpp_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
from unittest.mock import Mock
_du_build_ext.get_export_symbols = Mock(return_value=None)

CUDA_HOME = find_cuda_home()
if core.is_compiled_with_rocm():
ROCM_HOME = find_rocm_home()
else:
CUDA_HOME = find_cuda_home()
CUDA_HOME = ROCM_HOME


def setup(**attr):
Expand Down

0 comments on commit 6a5b7e5

Please sign in to comment.