Unverified Commit 1f1b6c65 authored by camenduru's avatar camenduru Committed by GitHub
Browse files

Device to use (e.g. cpu, cuda:0, cuda:1, etc.) (#1844)

* Device to use (e.g. cpu, cuda:0, cuda:1, etc.)

* "cuda" if torch.cuda.is_available() else "cpu"
parent df2b548e
...@@ -848,12 +848,17 @@ if __name__ == "__main__": ...@@ -848,12 +848,17 @@ if __name__ == "__main__":
), ),
) )
parser.add_argument("--dump_path", default=None, type=str, required=True, help="Path to the output model.") 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() args = parser.parse_args()
image_size = args.image_size image_size = args.image_size
prediction_type = args.prediction_type 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 # Sometimes models don't have the global_step item
if "global_step" in checkpoint: if "global_step" in checkpoint:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment