ximinng / DiffSketcher

[NIPS 2023] Official implementation for "DiffSketcher: Text Guided Vector Sketch Synthesis through Latent Diffusion Models" https://arxiv.org/abs/2306.14685
https://ximinng.github.io/DiffSketcher-project/
MIT License
231 stars 23 forks source link

Running on Mac M1 Max #3

Open mattdesl opened 11 months ago

mattdesl commented 11 months ago

I have a MBP M1 Max that should be able to run this (in theory) using the mps backend but am struggling. By default, the diffvg is being run with use_gpu=True hardcoded inside diffsketcher_pipeline.py (init_diffvg call). There is no CUDA support in diffvg, and it doesn't seem easy to just have diffvg use the mps device (if you know a way, that would be very helpful). After setting this variable to False so that diffvg is initialized with CPU, I get another error that the model expects all tensors to use the same device (now that the first step uses mps and the second uses cpu).

To fix, I can pass -cpu flag when running the main python script, but then the image is generated extremely slowly. Can we somehow make it use mps for the first phase, then switch device to cpu for remainder of work if CUDA is not supported?

EDIT: It seems there is some memory constraint that occurs when trying to use a full -cpu pipeline, as it just faults and stops without a clear error. My next question would be, perhaps we could split the work up: first I run the mps phase for generating the image, then I re-run a new script to run the second phase with model set to a new cpu device for diffvg.

ximinng commented 11 months ago

HI, mattdesl,

Sorry, I haven't used diffvg with mps backend on Mac either, so I may not be able to advise you on that. Regarding the use of CPU interrupts, it is possible that your program is being killed or interrupted due to excessive memory usage. I have conducted experiments on the A800 and V100, and there should be no issues with these devices. I recommend that you run our algorithm on a machine with an Nvidia GPU.

Have a nice day~

ximinng commented 6 months ago

try docker

docker run --name svgdreamer --gpus all -it --ipc=host ximingxing/svgrender:v1 /bin/bash