Skip to content

RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn #2

@chenjingcheng

Description

@chenjingcheng

python examples/refine_svg.py examples/test_assets/plane_oriented_init.svg examples/test_assets/plane_128.png
Using device: mps
iteration: 0
render loss: 0.23392434418201447
Traceback (most recent call last):
File "/Users/mac01/Documents/diffvg-torch/examples/refine_svg.py", line 133, in
main(args)
File "/Users/mac01/Documents/diffvg-torch/examples/refine_svg.py", line 102, in main
loss.backward()
File "/opt/miniconda3/envs/diffvg-torch/lib/python3.12/site-packages/torch/_tensor.py", line 630, in backward
torch.autograd.backward(
File "/opt/miniconda3/envs/diffvg-torch/lib/python3.12/site-packages/torch/autograd/init.py", line 364, in backward
_engine_run_backward(
File "/opt/miniconda3/envs/diffvg-torch/lib/python3.12/site-packages/torch/autograd/graph.py", line 865, in _engine_run_backward
return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn

If the device is cuda ,the result is same.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions