Skip to content

Commit e052fde

Browse files
authored
fix the v100 cuda11.2 matmul_v2 and elementwise_div bug (#42479)
1 parent a391762 commit e052fde

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

paddle/fluid/pybind/pybind.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2972,6 +2972,10 @@ All parameter, weight, gradient are variables in Paddle.
29722972
// Only GPUs with Compute Capability >= 53 support float16
29732973
return platform::GetGPUComputeCapability(place.device) >= 53;
29742974
});
2975+
m.def("is_bfloat16_supported", [](const platform::CUDAPlace &place) -> bool {
2976+
// Only GPUs with Compute Capability >= 80 support bfloat16
2977+
return platform::GetGPUComputeCapability(place.device) >= 80;
2978+
});
29752979
#endif
29762980

29772981
m.def("set_feed_variable",

python/paddle/fluid/tests/unittests/test_elementwise_div_op.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ def init_dtype(self):
6060
pass
6161

6262

63-
@unittest.skipIf(
64-
not core.is_compiled_with_cuda() or core.cudnn_version() < 8100,
65-
"core is not compiled with CUDA and cudnn version need larger than 8.1.0")
63+
@unittest.skipIf(not core.is_compiled_with_cuda() or
64+
not core.is_bfloat16_supported(core.CUDAPlace(0)),
65+
"core is not compiled with CUDA and not support the bfloat16")
6666
class TestElementwiseDivOpBF16(OpTest):
6767
def setUp(self):
6868
self.op_type = "elementwise_div"

python/paddle/fluid/tests/unittests/test_matmul_v2_op.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,9 @@ def test_check_grad(self):
385385

386386
def create_test_bf16_class(parent, atol=0.01):
387387
@unittest.skipIf(
388-
not core.is_compiled_with_cuda() or core.cudnn_version() < 8100,
389-
"core is not compiled with CUDA and cudnn version need larger than 8.1.0"
390-
)
388+
not core.is_compiled_with_cuda() or
389+
not core.is_bfloat16_supported(core.CUDAPlace(0)),
390+
"core is not compiled with CUDA and not support the bfloat16")
391391
class TestMatMulOpBf16Case(parent):
392392
def get_numeric_grad(self, place, check_name):
393393
scope = core.Scope()

0 commit comments

Comments
 (0)