BachiLi / diffvg

Differentiable Vector Graphics Rasterization
https://people.csail.mit.edu/tzumao/diffvg/
Apache License 2.0
902 stars 152 forks source link

Some points predicted by a net can't be backward using gpu. #59

Open ludysama opened 1 year ago

ludysama commented 1 year ago

Hello, I encountered a problem while using diffvg. I used a ResNet18 network added with a 3-layer MLP network to predict the control point coordinates of a path, which was rendered by diffvg to obtain the img tensor, then I use it calculate a L1 loss with my target. However, during the loss backpropagation, cuda report an error of device error, seems like some tensor needed was not sent to gpu , but if I transfer the control point coordinates to cpu, diffvg will use all tensors on cpu during rendering without this problem.

I looked through the examples in /app, I also found that some examples (GAN) also calculate loss with tensor from cpu. I’m not sure if this operation can be done on gpu?

MADONOKOUKI commented 1 year ago

I have the same issues too. (CPU works but GPU does not work). Or we will have illegal memory access error

ludysama commented 1 year ago

I try to sovle this problem by initing Path with the value that net predicted, then let gpu just optimize the path's point tensor, then let it backward first, after it just using a L1 loss to let net's pred logits close to optimized path's point. It was really boring to do. I faced with many bugs, and have'n done it. >.<