LaurentMazare / tch-rs

Rust bindings for the C++ api of PyTorch.
Apache License 2.0
4.24k stars 333 forks source link

VarStore Save/Load Bug #617

Open Moocow9m opened 1 year ago

Moocow9m commented 1 year ago

I am saving and immediately loading a VarStore for a SequentialModel, but it errors out with Internal torch error: isGenericDict() INTERNAL ASSERT FAILED. I have seen an issue with this happening on the ruby bindings with a model from python, but its odd since I save and load using the rust bindings. The code is just a simple vs.save("model.bin"); vs.load("model.bin"); but this doesn't work. Model structure is just one linear layer. Full stack trace: https://pastebin.com/i8WnJEZ0

Edit: After some testing, it seems this only happens when saving/loading with a file extension bin or pt. If I save with the extension x for example, it loads just fine. Seems it has to do with the Tensor::loadz_multi_with_device function. I normally use the bin extension for binary files, but I'll make it model for now until this is fixed.

SekoiaTree commented 1 year ago

Can confirm, exactly the same error and exactly the same solution.

exellian commented 1 year ago

Also having the same issue on macos