PaddlePaddle / Paddle

PArallel Distributed Deep LEarning: Machine Learning Framework from Industrial Practice (『飞桨』核心框架,深度学习&机器学习高性能单机、分布式训练和跨平台部署)
http://www.paddlepaddle.org/
Apache License 2.0
21.66k stars 5.44k forks source link

test_empty_like_op.py Error #64071

Closed penPenf28 closed 1 week ago

penPenf28 commented 1 week ago

bug描述 Describe the Bug

基本环境

python: 3.10 GPU: NVIDIA A800 paddle commit id: c0b2c7d10e95988fd0b76b782a3fb56606579c0c

复现过程

安装paddle

git clone https://github.com/PaddlePaddle/Paddle.git
cd Paddle
mkdir build
cd build
cmake .. -DPY_VERSION=3.10 -DWITH_GPU=ON -WITH_TESTING=on
make -j$(nproc)
pip install python/dist/paddlepaddle_gpu-0.0.0-cp310-cp310-linux_x86_64.whl

运行testcase

# activate env
cd /Paddle/test/legacy_test
python test_empty_like_op.py
# error
W0507 13:53:11.123783 18171 gpu_resources.cc:119] Please NOTE: device: 0, GPU Compute Capability: 8.0, Driver API Version: 12.0, Runtime API Version: 12.1
W0507 13:53:11.152410 18171 gpu_resources.cc:164] device: 0, cuDNN Version: 8.6.
W0507 13:53:11.152446 18171 gpu_resources.cc:196] WARNING: device: 0. The installed Paddle is compiled with CUDA 12.1, but CUDA runtime version in your machine is 12.0, which may cause serious incompatible bug. Please recompile or reinstall Paddle with compatible CUDA version.
F..........I0507 13:53:11.174595 18171 program_interpreter.cc:221] New Executor is Running.
I0507 13:53:11.184360 18171 pir_interpreter.cc:1377] New Executor is Running ...
I0507 13:53:11.184751 18171 pir_interpreter.cc:1403] pir interpreter is running by multi-thread mode ...
....
======================================================================
FAIL: test_attr (__main__.TestEmptyError)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/root/xinhongwen/code/Paddle/test/legacy_test/test_empty_like_op.py", line 282, in test_attr
    self.assertRaises(TypeError, test_dtype)
AssertionError: TypeError not raised by test_dtype

----------------------------------------------------------------------
Ran 15 tests in 1.710s

FAILED (failures=1)

错误原因

观察出错的testcase如下 image 看起来期望实现的功能是不可以把float64的类型转换为uint8类型,而实际底层支持这一功能

其他补充信息 Additional Supplementary Information

No response

SigureMo commented 1 week ago

@penPenf28 CI 中单测都会跑的除非禁用掉,但这个并没有

CI 中全部单测是使用 ctest 运行的,请参考 https://www.paddlepaddle.org.cn/documentation/docs/zh/dev_guides/code_contributing_path_cn.html#bendibianyibingzhixingdanyuanceshi

也就是

ctest -R test_empty_like_op

ctest 执行时部分单测和直接 python 跑是有 diff 的,该单测的 diff 是因为该单测位于 STATIC_MODE_TESTING_LIST

https://github.com/PaddlePaddle/Paddle/blob/5ee37e19e454bb7c21da09ccfb62ca46144b50f0/tools/static_mode_white_list.py#L175

这意味着这些单测在执行前会 paddle.enable_static() 一下,以启用静态图模式(因为以前 Paddle 静态图是默认模式),如果你想要直接跑,相应地,在 test_empty_like_op.py 单测开始前加一个 paddle.enable_static() 即可,比如

 if __name__ == '__main__':
+    paddle.enable_static()
     unittest.main()
changeyoung98 commented 1 week ago

你好,之前的单测写得有问题,已提交修复pr删除了TestEmptyError:https://github.com/PaddlePaddle/Paddle/pull/64073

changeyoung98 commented 1 week ago

你好,之前的单测写得有问题,已提交修复pr删除了TestEmptyError:#64073

PR已合入:D