I have one of the most classic 28x28 fashion mnist example which is working fine. Once I save the model (not the model state dict + opt. state dict), rather just by model.save(…, <fileName.h5>.
Now I tried to view the resulting hdf5 but it says can not open:
root@nonroot-Standard-PC-i440FX-PIIX-1996:~/dev-learn/gpu/pytorch/port-effort-from-tflow-2nd# h5dump p297.h5
h5dump error: unable to open file "p297.h5"

The code example is in another of my post earlier:
Pytorch torch nn equivalent of tensorflow (keras) dense layers? 2nd from the bottom which I flagged as solution.
The only change I made was to add one liner:
...
acc = evaluate_model(valid_dl, model)
print('Accuracy: %.3f' % acc)

torch.save(model, "p297.h5")

# make a single prediction
print("Making prediction...")
...

By contrast, I have equivalent code in tensorflow which I can save the model as h5 after training and can view it just fine with h5dump tool.