-
-
Notifications
You must be signed in to change notification settings - Fork 553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: IDAKLU / casadi serialization error - Object written in version 2 but can only read in version 1 #3100
Comments
Strange, it works at my end (even with version 23.4.1). Could be that when you upgraded to the newer PyBaMM version, casadi didn't. Can you try upgrading both PyBaMM and Casadi to their respective latest versions? |
I have upgrade pybamm and casadi to their newest version.(pybamm=23.5 casadi=3.6.3) But the problem still exist. Is that has something to do with the version of c++? |
I downgraded pybamm to version 22.10 and casadi to version 3.5.5, which solved the problem. |
Reopening as suggested in #3193 (comment) We need to find out why the newer pybamm or casadi version breaks this |
I'm having some trouble recreating this issue, even with the specific verison of PyBaMM and python mentioned, but I do think I know where the problem is coming from. The idaklu solver has a Python component and a C++ component, both of which link to casadi. The problem appears to be that under certain circumstances these two components seem to be getting out-of-sync with each other, causing the above reported serialisation error. This doesn't typically happen since both components usually link to the same libraries which are downloaded as part of the PyBaMM install. Simply rerunning the install procedure on the latest version of PyBaMM should be enough to update PyBaMM and resolve this. But if that doesn't work then I would recommend performing a clean install of PyBaMM, i.e. remove the previous version first, which removes any compiled idaklu code, allowing a fresh install to compile and link using the provided libraries. If that still doesn't work then it is possible that there are environment variables pointing to a separate version of casadi on the computer (which could be getting picked up during installation) - in that case the user can remove or upgrade that version of casadi to match the version provided by PyBaMM, and then rerun the PyBaMM install scripts. As a side note, this specific problem seems isolated to updates in casadi's serialization format (which are not likely to change that often). I can't suggest too much more without a reliable test-case. The error thrown by casadi ('RuntimeError') is quite generic so intercepting it in an attempt to provide a more directed set of instructions to the user may not be reliable. On top of that v23.4.1 still used tox, so the whole install system has been overhauled since then. I think the best thing to do at this point is to close this issue, noting the above, and refer back in the future if we run into similar problems again. |
Reopening as the issue has reemerged, including in pip installs of pybamm. See #3193 for related discussion. |
Some progress - Given the new information I have managed to recreate the serialisation error on my (working) machine by taking the following actions:
After that I receive the So it seems that this error is in-fact due to a mismatch in the version of |
Tested this on my end and I think the error does not appear when a pair of casadi 3.6.0 and subsequent patch releases (3.6.X) is used for linkage and runtime, so it is ominous that there were some changes between the minor releases, i.e., between 3.5.X and 3.6. We should note that the I can confirm that through the changes in the @jsbrittain – on a side note, does the serialisation error disappear if you manually install P.S. Since we are not sure of how many users have been affected and not sure of the fact whether it is just for all Windows users or it is only for a smaller portion of users across all platforms (though perhaps if it were for the former, we would have received several times more complaints), should we create a patch 23.9.1 release? |
I think I may have resolved the install problem by editing this line of |
@jsbrittain @agriyakhetarpal The |
Thanks, adding the necessary change(s) to #3569! I would suggest we should keep this issue open for the time being. |
…for alternative `casadi` installations Co-Authored-By: jsbrittain <[email protected]>
I have looked into this in the past week and this week; I think I can see where the issue comes from while building the Windows wheels. By examining the logs from one of the workflow runs for my fork with increased build verbosity, this is the line in specific: -- Downloading https://github.com/casadi/casadi/archive/nightly-ship.tar.gz -> casadi-casadi-nightly-ship.tar.gz...
-- Extracting source C:/vcpkg/downloads/casadi-casadi-nightly-ship.tar.gz which suggests that and the corresponding release is very old, from March 2022: https://github.com/casadi/casadi/releases/tag/nightly-ship. I assume to fix this issue we need to update the registry to download the as shown by the lines: -- Downloading https://github.com/casadi/casadi/archive/3.6.3.tar.gz -> casadi-casadi-3.6.3.tar.gz...
-- Extracting source C:/vcpkg/downloads/casadi-casadi-3.6.3.tar.gz I am not sure if this will fix the serialisation error but I suppose it is worth a try. @chmabaur, could you try installing the Windows wheel from here: https://github.com/agriyakhetarpal/PyBaMM/actions/runs/7127859881 and see if the error disappears? If it does resolve everything, I can put together a PR from my fork to the registry and put up a note in the release workflow and other appropriate places to ensure that the registry is bumped to a suitable P.S. I did try using the Python |
@agriyakhetarpal Removing the registry definitely sounds like the most maintainable solution going forwards. I took a quick look at the error from your Windows wheel build with python-casadi and, comparing it to the PyPI package listings, it looks as though there may be a misreferenced file in the casadi cmake targets ( |
I haven't tried it with the latest |
Okay, I tried it with version The Python @chmabaur – in addition to the wheels linked against casadi 3.6.3 in the link above, I would request you to try these wheels too: https://github.com/agriyakhetarpal/PyBaMM/actions/runs/7137563916. I hope at least one of these two sets of wheels resolves the serialisation error you have been receiving. (Perhaps we can look into doing a patch release if the error is found to be prevalent across a larger section of Windows users, now that we know where it comes from). |
@agriyakhetarpal Thanks a lot for your efforts to solve this issue! I have tested both wheel files in separate virtual environments on Windows for python version 3.9. I am glad to say that in both cases the serialization error disappeared. I am not able to follow your discussions above, but I hope it is ok that |
Thanks for confirming! Yes, Tagging @martinjrobins to request for write access to the casadi vcpkg registry (I think merging a PR from my end there will require a further, redundant update to the git-trees so it would be great to directly push) and then this issue can be closed with an update to the baseline commit in the vcpkg configuration file. P.S. I will open a new, separate issue to explore the possibility of moving away from the registry and getting back to using the Python |
See pybamm-team/PyBaMM#3100 for more details and discussion. This fixes the serialisation error coming from a CasADi ProtoFunction which was due to an old version being linked on Windows wheels.
See pybamm-team/PyBaMM#3100 for more details. This commti updates the git-tree to accommodate the version bump to `casadi` `3.6.4`.
…for alternative `casadi` installations Co-Authored-By: jsbrittain <[email protected]>
PyBaMM Version
23.4.1
Python Version
3.9
Describe the bug
RuntimeError:C:..\casadi\core\serialization_stream.cpp:355:Assertion"load_version==v" failed:ProtoFunction failed. Object written in version 2 but can only read in version 1.
Steps to Reproduce
Relevant log output
No response
The text was updated successfully, but these errors were encountered: