use cpu when set --device=cuda on mac

This commit is contained in:
Qing 2023-05-29 21:40:58 +08:00
parent 6674104742
commit 592ec3485b

View File

@ -197,12 +197,18 @@ def parse_args():
setattr(args, k, v)
if args.device == "cuda":
import torch
import platform
if torch.cuda.is_available() is False:
parser.error(
"torch.cuda.is_available() is False, please use --device cpu or check your pytorch installation"
)
if platform.system() == "Darwin":
logger.info("MacOS does not support cuda, use cpu instead")
setattr(args, "device", "cpu")
else:
import torch
if torch.cuda.is_available() is False:
parser.error(
"torch.cuda.is_available() is False, please use --device cpu or check your pytorch installation"
)
if args.sd_local_model_path and args.model == "sd1.5":
if not os.path.exists(args.sd_local_model_path):