GreenLandisaLie / AuraSR-ComfyUI

ComfyUI implementation of AuraSR
Creative Commons Attribution Share Alike 4.0 International
142 stars 5 forks source link

Very slow on MPS devices #5

Closed ynie closed 2 months ago

ynie commented 3 months ago

Hello, I have a MBP with M3 max, but it's still very slow. It has been running for 10mins and still running. I double check the device is MPS, does this behaves correct? Thanks

GreenLandisaLie commented 3 months ago

I cant debug because I only have an AMD GPU. I know for a fact that DirectML is not supported due to some internal operations involving negative dimensions. It is very likely that other devices like MPS are not supported either. Additionally, it is possible that some operations are being defaulted back to the CPU (which can be extremely slow if trying to upscale already decently sized images).

Please try to open the '...\custom_nodes\AuraSR-ComfyUI\nodes.py' with a text editor and add a few lines around: upscaled_image = self.aura_sr.upscale_4x(image=image, max_batch_size=tile_batch_size) like so:

print("[AuraSR-ComfyUI] Start Inference...")
print(device)
upscaled_image = self.aura_sr.upscale_4x(image=image, max_batch_size=tile_batch_size)
print("[AuraSR-ComfyUI] Inference completed successfully.")

Then save the file and restart ComfyUI. Try it again and make sure you give it a small image so it wouldn't take too much time to upscale (something like 256x256) then copy paste the log from your terminal so I can check it.

If MPS is not supported I'll force offload to CPU like I'm doing with DirectML.

EDIT:

Forgot to mention you to keep track of how much time it takes from going from '[AuraSR-ComfyUI] Start Inference...' to '[AuraSR-ComfyUI] Inference completed successfully.'. If after 5min (on a 256x256 image), inference has not completed then surely its due to MPS incompatibility. I've fixed a bug in the code that was preventing the usage of the CPU on non DirectML devices. Worst case, you can update the node and run in 'cpu' mode.

alexgenovese commented 2 months ago

it doesn't work on MPS

GreenLandisaLie commented 2 months ago

Closing this due to lack of info and lack of response. I can't test on MPS because I don't have one. Either it works or it doesnt - and if it doesn't you can always try CPU mode - although it will obviously be extremely slow.

EDIT: only noticed @alexgenovese 's reply seconds after closing this issue. I feared as much that it wouldn't work. AuraSR's internal code executes some torch calculations that are not yet supported by DirectML so its not far-fetched to assume they are not supported by MPS yet as well. CPU usage for this is really not recommended so you pretty much either have CUDA or you are out of luck.

alexgenovese commented 1 month ago

@GreenLandisaLie, thank you for your response.

I'm trying to make it work somewhat; in case I come up with a solution, I'll create a pull request.