paddle训练报错信息重复问题
Created by: chenwhql
写了一个小程序,测试exe.run(startup_progam)在optimizer.minimize之前运行会以什么形式报错,发现错误信息有冗余,体验不好
程序如下:
import paddle
import paddle.fluid as fluid
import numpy
import os
before_optimize = True
place = fluid.CUDAPlace(0)
exe = fluid.Executor(place)
x = fluid.layers.data(name='X', shape=[13], dtype='float32')
y = fluid.layers.data(name='Y', shape=[1], dtype='float32')
y_ = fluid.layers.fc(input=x, size=1, act=None)
loss = fluid.layers.square_error_cost(input=y_, label=y)
avg_loss = fluid.layers.mean(loss)
if before_optimize:
exe.run(fluid.default_startup_program())
fluid.optimizer.SGD(learning_rate=0.01).minimize(avg_loss)
if not before_optimize:
exe.run(fluid.default_startup_program())
x = numpy.random.random(size=(10, 13)).astype('float32')
y = numpy.random.random(size=(10, 1)).astype('float32')
loss_data, = exe.run(fluid.default_main_program(),
feed={'X': x, 'Y': y},
fetch_list=[avg_loss.name])
报错信息如下:
grep: warning: GREP_OPTIONS is deprecated; please use an alias or script
W0822 04:15:30.951391 2008 device_context.cc:259] Please NOTE: device: 0, CUDA Capability: 61, Driver API Version: 10.1, Runtime API Version: 10.0
W0822 04:15:31.099022 2008 device_context.cc:267] device: 0, cuDNN Version: 7.5.
An exception was thrown!
Invoke operator sgd error.
Python Callstacks:
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/framework.py", line 1780, in append_op
attrs=kwargs.get("attrs", None))
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/optimizer.py", line 674, in _append_optimize_op
stop_gradient=True)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/optimizer.py", line 386, in _create_optimization_pass
param_and_grad)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/optimizer.py", line 532, in apply_gradients
optimize_ops = self._create_optimization_pass(params_grads)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/optimizer.py", line 562, in apply_optimize
optimize_ops = self.apply_gradients(params_grads)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/optimizer.py", line 601, in minimize
loss, startup_program=startup_program, params_grads=params_grads)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/dygraph/base.py", line 86, in __impl__
return func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/wrapped_decorator.py", line 25, in __impl__
return wrapped_func(*args, **kwargs)
File "</usr/local/lib/python3.5/dist-packages/decorator.py:decorator-gen-20>", line 2, in minimize
File "startup.py", line 23, in <module>
fluid.optimizer.SGD(learning_rate=0.01).minimize(avg_loss)
C++ Callstacks:
Enforce failed. Expected framework::product(lr_dims) == 1, but received framework::product(lr_dims):0 != 1:1.
Learning rate should have 1 element at [/work/Paddle/paddle/fluid/operators/optimizers/sgd_op.cc:36]
PaddlePaddle Call Stacks:
0 0x7f96e21edc1dp void paddle::platform::EnforceNotMet::Init<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char const*, int) + 509
1 0x7f96e21ee90dp paddle::platform::EnforceNotMet::EnforceNotMet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int) + 125
2 0x7f96e376b614p paddle::operators::SGDOp::InferShape(paddle::framework::InferShapeContext*) const + 1108
3 0x7f96e4425279p paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&, paddle::framework::RuntimeContext*) const + 1401
4 0x7f96e4425d37p paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) const + 487
5 0x7f96e441efdep paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) + 318
6 0x7f96e23ca3fep paddle::framework::Executor::RunPreparedContext(paddle::framework::ExecutorPrepareContext*, paddle::framework::Scope*, bool, bool, bool) + 622
7 0x7f96e23cd22dp paddle::framework::Executor::Run(paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int, bool, bool, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, bool) + 189
8 0x7f96e21d4906p
9 0x7f96e2220594p
10 0x4ea137p PyCFunction_Call + 119
11 0x53c176p PyEval_EvalFrameEx + 23030
12 0x53fc97p
13 0x53bc93p PyEval_EvalFrameEx + 21779
14 0x53fc97p
15 0x53bc93p PyEval_EvalFrameEx + 21779
16 0x53fc97p
17 0x53b83fp PyEval_EvalFrameEx + 20671
18 0x53fc97p
19 0x5409bfp PyEval_EvalCode + 31
20 0x60cb42p
21 0x60efeap PyRun_FileExFlags + 154
22 0x60f7dcp PyRun_SimpleFileExFlags + 444
23 0x640256p Py_Main + 1110
24 0x4d0001p main + 225
25 0x7f9752d27830p __libc_start_main + 240
26 0x5d6999p _start + 41
Traceback (most recent call last):
File "startup.py", line 32, in <module>
fetch_list=[avg_loss.name])
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/executor.py", line 615, in run
six.reraise(*sys.exc_info())
File "/usr/local/lib/python3.5/dist-packages/six.py", line 693, in reraise
raise value
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/executor.py", line 611, in run
use_program_cache=use_program_cache)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/executor.py", line 653, in _run_impl
use_program_cache=use_program_cache)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/executor.py", line 745, in _run_program
exe.run(program.desc, scope, 0, True, True, fetch_var_name)
paddle.fluid.core_avx.EnforceNotMet: Invoke operator sgd error.
Python Callstacks:
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/framework.py", line 1780, in append_op
attrs=kwargs.get("attrs", None))
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/optimizer.py", line 674, in _append_optimize_op
stop_gradient=True)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/optimizer.py", line 386, in _create_optimization_pass
param_and_grad)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/optimizer.py", line 532, in apply_gradients
optimize_ops = self._create_optimization_pass(params_grads)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/optimizer.py", line 562, in apply_optimize
optimize_ops = self.apply_gradients(params_grads)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/optimizer.py", line 601, in minimize
loss, startup_program=startup_program, params_grads=params_grads)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/dygraph/base.py", line 86, in __impl__
return func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/paddle/fluid/wrapped_decorator.py", line 25, in __impl__
return wrapped_func(*args, **kwargs)
File "</usr/local/lib/python3.5/dist-packages/decorator.py:decorator-gen-20>", line 2, in minimize
File "startup.py", line 23, in <module>
fluid.optimizer.SGD(learning_rate=0.01).minimize(avg_loss)
C++ Callstacks:
Enforce failed. Expected framework::product(lr_dims) == 1, but received framework::product(lr_dims):0 != 1:1.
Learning rate should have 1 element at [/work/Paddle/paddle/fluid/operators/optimizers/sgd_op.cc:36]
PaddlePaddle Call Stacks:
0 0x7f96e21edc1dp void paddle::platform::EnforceNotMet::Init<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, char const*, int) + 509
1 0x7f96e21ee90dp paddle::platform::EnforceNotMet::EnforceNotMet(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char const*, int) + 125
2 0x7f96e376b614p paddle::operators::SGDOp::InferShape(paddle::framework::InferShapeContext*) const + 1108
3 0x7f96e4425279p paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&, paddle::framework::RuntimeContext*) const + 1401
4 0x7f96e4425d37p paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) const + 487
5 0x7f96e441efdep paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, boost::variant<paddle::platform::CUDAPlace, paddle::platform::CPUPlace, paddle::platform::CUDAPinnedPlace, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_, boost::detail::variant::void_> const&) + 318
6 0x7f96e23ca3fep paddle::framework::Executor::RunPreparedContext(paddle::framework::ExecutorPrepareContext*, paddle::framework::Scope*, bool, bool, bool) + 622
7 0x7f96e23cd22dp paddle::framework::Executor::Run(paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int, bool, bool, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, bool) + 189
8 0x7f96e21d4906p
9 0x7f96e2220594p
10 0x4ea137p PyCFunction_Call + 119
11 0x53c176p PyEval_EvalFrameEx + 23030
12 0x53fc97p
13 0x53bc93p PyEval_EvalFrameEx + 21779
14 0x53fc97p
15 0x53bc93p PyEval_EvalFrameEx + 21779
16 0x53fc97p
17 0x53b83fp PyEval_EvalFrameEx + 20671
18 0x53fc97p
19 0x5409bfp PyEval_EvalCode + 31
20 0x60cb42p
21 0x60efeap PyRun_FileExFlags + 154
22 0x60f7dcp PyRun_SimpleFileExFlags + 444
23 0x640256p Py_Main + 1110
24 0x4d0001p main + 225
25 0x7f9752d27830p __libc_start_main + 240
26 0x5d6999p _start + 41