diff --git a/scripts/convert_original_stable_diffusion_to_diffusers.py b/scripts/convert_original_stable_diffusion_to_diffusers.py index 0414a0e8ad6a..1f4204495482 100644 --- a/scripts/convert_original_stable_diffusion_to_diffusers.py +++ b/scripts/convert_original_stable_diffusion_to_diffusers.py @@ -848,12 +848,17 @@ def convert_open_clip_checkpoint(checkpoint): ), ) parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") + parser.add_argument("--device", type=str, help="Device to use (e.g. cpu, cuda:0, cuda:1, etc.)") args = parser.parse_args() image_size = args.image_size prediction_type = args.prediction_type - checkpoint = torch.load(args.checkpoint_path) + if args.device is None: + device = "cuda" if torch.cuda.is_available() else "cpu" + checkpoint = torch.load(args.checkpoint_path, map_location=device) + else: + checkpoint = torch.load(args.checkpoint_path, map_location=args.device) # Sometimes models don't have the global_step item if "global_step" in checkpoint: