PINA icon indicating copy to clipboard operation
PINA copied to clipboard

Problem in plotting in Poisson tutorial on colab

Open accdavlo opened this issue 1 year ago • 1 comments

Describe the bug The tutorial on Poisson does not produce a plot on Google colab.

Commitment I was trying to run the code to have a simple PINN for a class, I'm not thinking to debug the code. I thank you in advance if you will debug it.

To Reproduce https://colab.research.google.com/github/mathLab/PINA/blob/master/tutorials/tutorial2/tutorial.ipynb at the first plot cell.

Bug I get this error ValueError: only one element tensors can be converted to Python scalars when running the tutorial on Poisson on google colab https://mathlab.github.io/PINA/_rst/tutorials/tutorial2/tutorial.html

Complete Error

ValueError                                Traceback (most recent call last)
[<ipython-input-4-da1f560dd1b4>](https://localhost:8080/#) in <cell line: 2>()
      1 plotter = Plotter()
----> 2 plotter.plot(solver=pinn)

13 frames
[/usr/local/lib/python3.10/dist-packages/torch/_tensor.py](https://localhost:8080/#) in __torch_function__(cls, func, types, args, kwargs)
   1510 
   1511         with _C.DisableTorchFunctionSubclass():
-> 1512             ret = func(*args, **kwargs)
   1513             if func in get_default_nowrap_functions():
   1514                 return ret

ValueError: only one element tensors can be converted to Python scalars```

accdavlo avatar Dec 27 '24 15:12 accdavlo

Hi @accdavlo ! Sorry for the really late reply, we have been working hard on a new version which we will be releasing in a few days (you can see the dev branch here #401 ).

I tried to run the colab and the plot looks good to me, I didn't have any error. If you are still on the problem can you send some details about hardware (GPU,CPU,TPU); and also send the full code error.

News We removed the plotter in the new version which we will release soon, so now matplotlib and tensorboard are the fastest way to plot solutions and display losses. Hopefully you will find the package useful for your lectures :)

dario-coscia avatar Mar 19 '25 17:03 dario-coscia