tensorboardX icon indicating copy to clipboard operation
tensorboardX copied to clipboard

add_graph error(Type 'Tuple[Tuple[Tensor, Tensor, Tensor], int, bool]' cannot be traced)

Open donttal opened this issue 6 years ago • 2 comments

Describe the bug I want get my model Visualization by add_graph, but here is the errors.

Type 'Tuple[Tuple[Tensor, Tensor, Tensor], int, bool]' cannot be traced. Only Tensors and (possibly nested) Lists, Dicts, and Tuples of Tensors can be traced (toTraceableStack at ../torch/csrc/jit/pybind_utils.h:305)
frame #0: c10::Error::Error(c10::SourceLocation, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 135 (0x128f3b787 in libc10.dylib)
frame #1: torch::jit::toTraceableStack(pybind11::tuple const&) + 826 (0x11b21ebfa in libtorch_python.dylib)
frame #2: void pybind11::cpp_function::initialize<torch::jit::script::initJitScriptBindings(_object*)::$_13, void, torch::jit::script::Module&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, pybind11::function, pybind11::tuple, pybind11::function, bool, pybind11::name, pybind11::is_method, pybind11::sibling>(torch::jit::script::initJitScriptBindings(_object*)::$_13&&, void (*)(torch::jit::script::Module&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, pybind11::function, pybind11::tuple, pybind11::function, bool), pybind11::name const&, pybind11::is_method const&, pybind11::sibling const&)::'lambda'(pybind11::detail::function_call&)::__invoke(pybind11::detail::function_call&) + 153 (0x11b2ef979 in libtorch_python.dylib)
frame #3: pybind11::cpp_function::dispatcher(_object*, _object*, _object*) + 3324 (0x11ac2378c in libtorch_python.dylib)
<omitting python frames>
frame #62: start + 1 (0x7fff668eb7fd in libdyld.dylib)

Minimal runnable code to reproduce the behavior

            for i in t:
                task_id = train_task_ids[i]
                batch_data = next(train_iters[task_id])
                batch_data = tuple(tmp.to(args.device) for tmp in batch_data)
                loss = model(batch_data, task_id, True)
                # 生成模型流程图
               if epoch == start_epoch:
                     writer.add_graph(model, (batch_data, task_id, True))
                loss.backward()
                optimizer.step()
                optimizer.zero_grad()
                loss_avg.update(loss.item())
                t.set_postfix(loss='{:5.4f}'.format(loss.item()), avg_loss='{:5.4f}'.format(loss_avg()))
                logging.info("loss={:5.4f}, avg_loss={:5.4f}'".format(loss.item(), loss_avg()))

Environment tensorboard 1.13.1 tensorboardX 2.0 tensorflow 1.13.2 tensorflow-estimator 1.13.0 torch 1.4.0 torchvision 0.5.0

Python environment Python 3.6.10 and conda 4.8.1

donttal avatar Feb 09 '20 09:02 donttal

hi,I'v met the same problems,would you please tell me how you figured it

lmkee avatar Nov 06 '20 03:11 lmkee

hi,I'v met the same problems,would you please tell me how you figured it I got an answer to another question I asked torch 1.3.0 torchvision 0.4.1 And I can see the graph in chrome now. hope this helps

donttal avatar Nov 07 '20 03:11 donttal