Unable to load torch model trained on CUDA with a CPU only machine

I’ve a similar issue to this: Import torch file with trained model in CUDA, in a CPU machine

I’d trained a model on Colab with CUDA service, and saved as model.pickle file.

When I want to load the model on my local computer via:

with open("D:/models/resnet34_new.pickle", 'rb') as file:
        model = torch.load(file, map_location=torch.device('cpu'))

It shows the error:

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.

I’d searched multiple solutions online, but none works for me.

What could I do the load the model?
Thank you for any help!

Have you tried saving the model as a .pt file? I’ve used that method and it works.

# Saving
path = "./your_name.pt"
torch.save(model.state_dict(), path)

# Loading
model.load_state_dict(torch.load(path, map_location=torch.device("cpu")))

I would try it, thanks!