From 98c3f85efe7b92eea724c7aed2884d041a38c889 Mon Sep 17 00:00:00 2001 From: wawltor Date: Thu, 5 May 2022 09:52:45 +0800 Subject: [PATCH] fix the v100 cuda11.2 matmul_v2 and elementwise_div bug (#42477) --- paddle/fluid/pybind/pybind.cc | 4 ++++ .../paddle/fluid/tests/unittests/test_elementwise_div_op.py | 6 +++--- python/paddle/fluid/tests/unittests/test_matmul_v2_op.py | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/paddle/fluid/pybind/pybind.cc b/paddle/fluid/pybind/pybind.cc index 3a242fe258..dc554a9c5a 100644 --- a/paddle/fluid/pybind/pybind.cc +++ b/paddle/fluid/pybind/pybind.cc @@ -3022,6 +3022,10 @@ All parameter, weight, gradient are variables in Paddle. // Only GPUs with Compute Capability >= 53 support float16 return platform::GetGPUComputeCapability(place.device) >= 53; }); + m.def("is_bfloat16_supported", [](const platform::CUDAPlace &place) -> bool { + // Only GPUs with Compute Capability >= 80 support bfloat16 + return platform::GetGPUComputeCapability(place.device) >= 80; + }); #endif m.def("set_feed_variable", diff --git a/python/paddle/fluid/tests/unittests/test_elementwise_div_op.py b/python/paddle/fluid/tests/unittests/test_elementwise_div_op.py index d50241e58d..27dbd3752b 100644 --- a/python/paddle/fluid/tests/unittests/test_elementwise_div_op.py +++ b/python/paddle/fluid/tests/unittests/test_elementwise_div_op.py @@ -60,9 +60,9 @@ class ElementwiseDivOp(OpTest): pass -@unittest.skipIf( - not core.is_compiled_with_cuda() or core.cudnn_version() < 8100, - "core is not compiled with CUDA and cudnn version need larger than 8.1.0") +@unittest.skipIf(not core.is_compiled_with_cuda() or + not core.is_bfloat16_supported(core.CUDAPlace(0)), + "core is not compiled with CUDA and not support the bfloat16") class TestElementwiseDivOpBF16(OpTest): def setUp(self): self.op_type = "elementwise_div" diff --git a/python/paddle/fluid/tests/unittests/test_matmul_v2_op.py b/python/paddle/fluid/tests/unittests/test_matmul_v2_op.py index 492f300e3b..3e06b69278 100644 --- a/python/paddle/fluid/tests/unittests/test_matmul_v2_op.py +++ b/python/paddle/fluid/tests/unittests/test_matmul_v2_op.py @@ -385,9 +385,9 @@ create_test_fp16_class(TestMatMulOp17) def create_test_bf16_class(parent, atol=0.01): @unittest.skipIf( - not core.is_compiled_with_cuda() or core.cudnn_version() < 8100, - "core is not compiled with CUDA and cudnn version need larger than 8.1.0" - ) + not core.is_compiled_with_cuda() or + not core.is_bfloat16_supported(core.CUDAPlace(0)), + "core is not compiled with CUDA and not support the bfloat16") class TestMatMulOpBf16Case(parent): def get_numeric_grad(self, place, check_name): scope = core.Scope() -- GitLab