bryanbocao / awesome-cmd-cheatsheets

Quick search the commands you need.
3 stars 1 forks source link

RuntimeError: Attempting to deserialize object on a CUDA device #8

Closed bryanbocao closed 2 years ago

bryanbocao commented 2 years ago

Tried to run

CUDA_VISIBLE_DEVICES='' python prune_resnet18_cifar10.py --mode test --round 1 --total_epochs 1 --step_size 1

on cpu

https://github.com/VainF/Torch-Pruning/blob/master/examples/cifar_minimal/run.sh

but got

RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.
bryanbocao commented 2 years ago

Add argument

map_location=torch.device('cpu')

in load()

model = torch.load(previous_ckpt, map_location=torch.device('cpu'))