Autostronomy / AstroPhot

A fast, flexible, automated, and differentiable astronomical image 2D forward modelling tool for precise parallel multi-wavelength photometry
https://astrophot.readthedocs.io
GNU General Public License v3.0
87 stars 9 forks source link

Bug report: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first. #149

Closed Mebiusbear closed 10 months ago

Mebiusbear commented 10 months ago

This bug appears when I'm running ap.fit.LM(model2, verbose = 1).fit()

In the preceding two lines of code, the variable pixel_shape is explicitly moved from a tensor to CPU using .cpu(). Consequently, attempting to use window.pixel_shape in the subsequent lines results in an error.

https://github.com/Autostronomy/AstroPhot/blob/e816201d5149eead74d195bcf6832b31fdc8dff3/astrophot/models/model_object.py#L512C44-L512C44

ConnorStoneAstro commented 10 months ago

Hi @Mebiusbear , thanks for spotting this! Could you send a screenshot/trace of the full error? I'll make sure this is fixed today.

ConnorStoneAstro commented 10 months ago

Please see PR #150 and let me know if this would fix the problem. I'm going to run some tests on GPU, but it would be nice to hear if this addresses your problem in particular :)

ConnorStoneAstro commented 10 months ago

Closed by #150