首页 Paddle框架 帖子详情
使用paddle运行gpu版本报错
收藏
快速回复
Paddle框架 问答深度学习 3000 3
使用paddle运行gpu版本报错
收藏
快速回复
Paddle框架 问答深度学习 3000 3

-

# 定义使用CPU还是GPU,使用CPU时use_cuda = False,使用GPU时use_cuda = True
use_cuda = True
place = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace()

--------------------------------------------------------------------------EnforceNotMet Traceback (most recent call last) in
8 train_cost,train_acc = exe.run(program=fluid.default_main_program(),#运行主程序
9 feed=feeder.feed(data), #喂入一个batch的数据
---> 10 fetch_list=[avg_cost, acc]) #fetch均方误差和准确率
11
12
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py in run(self, program, feed, fetch_list, feed_var_name, fetch_var_name, scope, return_numpy, use_program_cache)
649 scope=scope,
650 return_numpy=return_numpy,
--> 651 use_program_cache=use_program_cache)
652 else:
653 if fetch_list and program._is_data_parallel and program._program and (
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/executor.py in _run(self, program, exe, feed, fetch_list, feed_var_name, fetch_var_name, scope, return_numpy, use_program_cache)
747 self._feed_data(program, feed, feed_var_name, scope)
748 if not use_program_cache:
--> 749 exe.run(program.desc, scope, 0, True, True, fetch_var_name)
750 else:
751 exe.run_cached_prepared_ctx(ctx, scope, False, False, False)
EnforceNotMet: Invoke operator conv2d error.
Python Callstacks:
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/framework.py", line 1771, in append_op
attrs=kwargs.get("attrs", None))
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layer_helper.py", line 43, in append_op
return self.main_program.current_block().append_op(*args, **kwargs)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layers/nn.py", line 2181, in conv2d
'fuse_relu_before_depthwise_conv': False
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/nets.py", line 123, in simple_img_conv_pool
use_cudnn=use_cudnn)
File "", line 9, in convolutional_neural_network
act="relu") # 激活类型
File "", line 2, in
predict = convolutional_neural_network(images)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3265, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3183, in run_ast_nodes
if (yield from self.run_code(code, result)):
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3018, in run_cell_async
interactivity=interactivity, compiler=compiler, result=result)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/IPython/core/async_helpers.py", line 67, in _pseudo_sync_runner
coro.send(None)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 2843, in _run_cell
return runner(coro)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 2817, in run_cell
raw_cell, store_history, silent, shell_futures)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/ipykernel/zmqshell.py", line 536, in run_cell
return super(ZMQInteractiveShell, self).run_cell(*args, **kwargs)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/ipykernel/ipkernel.py", line 294, in do_execute
res = shell.run_cell(code, store_history=store_history, silent=silent)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/tornado/gen.py", line 326, in wrapper
yielded = next(result)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/ipykernel/kernelbase.py", line 534, in execute_request
user_expressions, allow_stdin,
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/tornado/gen.py", line 326, in wrapper
yielded = next(result)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/ipykernel/kernelbase.py", line 267, in dispatch_shell
yield gen.maybe_future(handler(stream, idents, msg))
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/tornado/gen.py", line 326, in wrapper
yielded = next(result)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/ipykernel/kernelbase.py", line 357, in process_one
yield gen.maybe_future(dispatch(*args))
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/tornado/gen.py", line 1147, in run
yielded = self.gen.send(value)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/tornado/gen.py", line 1080, in __init__
self.run()
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/tornado/gen.py", line 346, in wrapper
runner = Runner(result, future, yielded)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/ipykernel/kernelbase.py", line 370, in dispatch_queue
yield self.process_one()
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/tornado/gen.py", line 1147, in run
yielded = self.gen.send(value)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/tornado/gen.py", line 1233, in inner
self.run()
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/tornado/stack_context.py", line 300, in null_wrapper
return fn(*args, **kwargs)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/tornado/ioloop.py", line 758, in _run_callback
ret = callback()
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/asyncio/events.py", line 88, in _run
self._context.run(self._callback, *self._args)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/asyncio/base_events.py", line 1771, in _run_once
handle._run()
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/asyncio/base_events.py", line 534, in run_forever
self._run_once()
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/tornado/platform/asyncio.py", line 132, in start
self.asyncio_loop.run_forever()
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/ipykernel/kernelapp.py", line 505, in start
self.io_loop.start()
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/traitlets/config/application.py", line 664, in launch_instance
app.start()
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/ipykernel_launcher.py", line 16, in
app.launch_new_instance()
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
C++ Callstacks:
holder_ should not be null
Tensor not initialized yet when Tensor::type() is called. at [/paddle/paddle/fluid/framework/tensor.h:139]
PaddlePaddle Call Stacks:
0 0x7f42b4e24d58p void paddle::platform::EnforceNotMet::Init(std::string, char const*, int) + 360
1 0x7f42b4e250a7p paddle::platform::EnforceNotMet::EnforceNotMet(std::string const&, char const*, int) + 87
2 0x7f42b4e25adbp paddle::framework::Tensor::type() const + 107
3 0x7f42b5239e7bp paddle::operators::ConvOp::GetExpectedKernelType(paddle::framework::ExecutionContext const&) const + 299
4 0x7f42b6d88efbp paddle::framework::OperatorWithKernel::ChooseKernel(paddle::framework::RuntimeContext const&, paddle::framework::Scope const&, boost::variant const&) const + 235
5 0x7f42b6d8b068p paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant const&, paddle::framework::RuntimeContext*) const + 728
6 0x7f42b6d8b2e1p paddle::framework::OperatorWithKernel::RunImpl(paddle::framework::Scope const&, boost::variant const&) const + 529
7 0x7f42b6d888dcp paddle::framework::OperatorBase::Run(paddle::framework::Scope const&, boost::variant const&) + 332
8 0x7f42b4faf61ep paddle::framework::Executor::RunPreparedContext(paddle::framework::ExecutorPrepareContext*, paddle::framework::Scope*, bool, bool, bool) + 382
9 0x7f42b4fb26bfp paddle::framework::Executor::Run(paddle::framework::ProgramDesc const&, paddle::framework::Scope*, int, bool, bool, std::vector > const&, bool) + 143
10 0x7f42b4e15ebdp
11 0x7f42b4e57166p
12 0x555882e49744p _PyMethodDef_RawFastCallKeywords + 596
13 0x555882e49861p _PyCFunction_FastCallKeywords + 33
14 0x555882eb56e8p _PyEval_EvalFrameDefault + 21240
15 0x555882df9539p _PyEval_EvalCodeWithName + 761
16 0x555882e48f57p _PyFunction_FastCallKeywords + 903
17 0x555882eb18ccp _PyEval_EvalFrameDefault + 5340
18 0x555882df9539p _PyEval_EvalCodeWithName + 761
19 0x555882e48f57p _PyFunction_FastCallKeywords + 903
20 0x555882eb18ccp _PyEval_EvalFrameDefault + 5340
21 0x555882df9539p _PyEval_EvalCodeWithName + 761
22 0x555882dfa424p PyEval_EvalCodeEx + 68
23 0x555882dfa44cp PyEval_EvalCode + 28
24 0x555882ebff8dp
25 0x555882e495d9p _PyMethodDef_RawFastCallKeywords + 233
26 0x555882e49861p _PyCFunction_FastCallKeywords + 33
27 0x555882eb4b94p _PyEval_EvalFrameDefault + 18340
28 0x555882e52592p _PyGen_Send + 674
29 0x555882eb1e69p _PyEval_EvalFrameDefault + 6777
30 0x555882e52592p _PyGen_Send + 674
31 0x555882eb1e69p _PyEval_EvalFrameDefault + 6777
32 0x555882e52592p _PyGen_Send + 674
33 0x555882e4957dp _PyMethodDef_RawFastCallKeywords + 141
34 0x555882e513cfp _PyMethodDescr_FastCallKeywords + 79
35 0x555882eb507cp _PyEval_EvalFrameDefault + 19596
36 0x555882e48ccbp _PyFunction_FastCallKeywords + 251
37 0x555882eb0806p _PyEval_EvalFrameDefault + 1046
38 0x555882e48ccbp _PyFunction_FastCallKeywords + 251
39 0x555882eb0a93p _PyEval_EvalFrameDefault + 1699
40 0x555882df9539p _PyEval_EvalCodeWithName + 761
41 0x555882dfa860p _PyFunction_FastCallDict + 1024
42 0x555882e18e53p _PyObject_Call_Prepend + 99
43 0x555882e0bdbep PyObject_Call + 110
44 0x555882eb2232p _PyEval_EvalFrameDefault + 7746
45 0x555882df981ap _PyEval_EvalCodeWithName + 1498
46 0x555882e48f57p _PyFunction_FastCallKeywords + 903
47 0x555882eb18ccp _PyEval_EvalFrameDefault + 5340
48 0x555882e52059p
49 0x555882e495d9p _PyMethodDef_RawFastCallKeywords + 233
50 0x555882e49861p _PyCFunction_FastCallKeywords + 33
51 0x555882eb4b94p _PyEval_EvalFrameDefault + 18340
52 0x555882df9d09p _PyEval_EvalCodeWithName + 2761
53 0x555882e48f57p _PyFunction_FastCallKeywords + 903
54 0x555882eb0a93p _PyEval_EvalFrameDefault + 1699
55 0x555882e52059p
56 0x555882e495d9p _PyMethodDef_RawFastCallKeywords + 233
57 0x555882e49861p _PyCFunction_FastCallKeywords + 33
58 0x555882eb4b94p _PyEval_EvalFrameDefault + 18340
59 0x555882df9d09p _PyEval_EvalCodeWithName + 2761
60 0x555882e48f57p _PyFunction_FastCallKeywords + 903
61 0x555882eb0806p _PyEval_EvalFrameDefault + 1046
62 0x555882e52059p
63 0x555882e495d9p _PyMethodDef_RawFastCallKeywords + 233
64 0x555882e49861p _PyCFunction_FastCallKeywords + 33
65 0x555882eb4b94p _PyEval_EvalFrameDefault + 18340
66 0x555882df9d09p _PyEval_EvalCodeWithName + 2761
67 0x555882dfa635p _PyFunction_FastCallDict + 469
68 0x555882e18e53p _PyObject_Call_Prepend + 99
69 0x555882e0bdbep PyObject_Call + 110
70 0x555882eb2232p _PyEval_EvalFrameDefault + 7746
71 0x555882e5243cp _PyGen_Send + 332
72 0x555882e4957dp _PyMethodDef_RawFastCallKeywords + 141
73 0x555882e513cfp _PyMethodDescr_FastCallKeywords + 79
74 0x555882eb507cp _PyEval_EvalFrameDefault + 19596
75 0x555882e48ccbp _PyFunction_FastCallKeywords + 251
76 0x555882eb0a93p _PyEval_EvalFrameDefault + 1699
77 0x555882df981ap _PyEval_EvalCodeWithName + 1498
78 0x555882dfa635p _PyFunction_FastCallDict + 469
79 0x555882eb2232p _PyEval_EvalFrameDefault + 7746
80 0x555882df9d09p _PyEval_EvalCodeWithName + 2761
81 0x555882dfa635p _PyFunction_FastCallDict + 469
82 0x555882f08b5bp
83 0x555882e518fbp _PyObject_FastCallKeywords + 1179
84 0x555882eb4e86p _PyEval_EvalFrameDefault + 19094
85 0x555882dfa56bp _PyFunction_FastCallDict + 267
86 0x555882e18e53p _PyObject_Call_Prepend + 99
87 0x555882e518fbp _PyObject_FastCallKeywords + 1179
88 0x555882ee4383p
89 0x555882e1a584p _PyMethodDef_RawFastCallDict + 404
90 0x555882e1a7c1p _PyCFunction_FastCallDict + 33
91 0x555882eb6007p _PyEval_EvalFrameDefault + 23575
92 0x555882e48ccbp _PyFunction_FastCallKeywords + 251
93 0x555882eb0a93p _PyEval_EvalFrameDefault + 1699
94 0x555882e48ccbp _PyFunction_FastCallKeywords + 251
95 0x555882eb0a93p _PyEval_EvalFrameDefault + 1699
96 0x555882e48ccbp _PyFunction_FastCallKeywords + 251
97 0x555882eb0a93p _PyEval_EvalFrameDefault + 1699
98 0x555882e48ccbp _PyFunction_FastCallKeywords + 251
99 0x555882eb0a93p _PyEval_EvalFrameDefault + 1699

0
收藏
回复
全部评论(3)
时间顺序
沙印123
#2 回复于2020-02

同求

0
回复
沙印123
#3 回复于2020-02

报错原因EnforceNotMet: Invoke operator conv2d error.

可能不是由于gpu环境出错,我遇到同样的问题改为cpu也没有解决。

解决办法:conv2d的卷积是针对三通道而言的,如果你的项目是图像识别的话,jpg png照片都是四通道的,要转换为三通道,结果正常运行。

from PIL import Image
import os
import string
from matplotlib import pyplot as plt

path = './x.png'
img = Image.open(path)

img = img.convert('RGB')
save_path = './y.png'
img.save(save_path)

0
回复
星光ld1
#4 回复于2020-02

看着问题不太确定是不是一个notebook里出现了两次program的使用,我之前在一个项目上碰到过因为上下定义了两个program出错的情形

0
回复
需求/bug反馈?一键提issue告诉我们
发现bug?如果您知道修复办法,欢迎提pr直接参与建设飞桨~
在@后输入用户全名并按空格结束,可艾特全站任一用户