diff --git a/paddle/fluid/framework/new_executor/interpretercore.cc b/paddle/fluid/framework/new_executor/interpretercore.cc index 6b6eb3f8d674b3928b17b625a2c5b0767d6fa0b5..f57a99e84cce653807a9836c384c20582d5d7717 100644 --- a/paddle/fluid/framework/new_executor/interpretercore.cc +++ b/paddle/fluid/framework/new_executor/interpretercore.cc @@ -566,12 +566,16 @@ void InterpreterCore::RunInstruction(const Instruction& instr_node) { : var_scope_.GetMutableScope(); #ifdef PADDLE_WITH_ASCEND_CL - // NOTE(wangxi): nan/inf cannot be detected on NPU by checking the variable - // values, but only through special `float_status` to checks whether - // the operation is overflow. More about `float_status`, see: - // https://gitee.com/ascend/modelzoo/issues/I3NF8V?from=project-issue - if (FLAGS_check_nan_inf) { - framework::details::NPUAllocAndClearFloatStatus(*op, *local_scope, place); + if (platform::is_npu_place(place)) { + auto dev_id = place.device; + platform::SetNPUDeviceId(dev_id); + // NOTE(wangxi): nan/inf cannot be detected on NPU by checking the variable + // values, but only through special `float_status` to checks whether + // the operation is overflow. More about `float_status`, see: + // https://gitee.com/ascend/modelzoo/issues/I3NF8V?from=project-issue + if (FLAGS_check_nan_inf) { + framework::details::NPUAllocAndClearFloatStatus(*op, *local_scope, place); + } } #endif diff --git a/python/paddle/fluid/tests/unittests/npu/CMakeLists.txt b/python/paddle/fluid/tests/unittests/npu/CMakeLists.txt index 0c868e4568240f6960e510f0025f85d8241b7601..57e52206653c8963a89eed01fae17c64582ff662 100644 --- a/python/paddle/fluid/tests/unittests/npu/CMakeLists.txt +++ b/python/paddle/fluid/tests/unittests/npu/CMakeLists.txt @@ -6,8 +6,7 @@ string(REPLACE ".py" "" TEST_OPS "${TEST_OPS}") if(WITH_ASCEND_CL) foreach(TEST_OP ${TEST_OPS}) - py_test_modules(${TEST_OP} MODULES ${TEST_OP} ENVS - FLAGS_USE_STANDALONE_EXECUTOR=0) + py_test_modules(${TEST_OP} MODULES ${TEST_OP}) endforeach() # NOTE: NPU `get_float_status` read the value from register, During the test,