Creating FMU from Python code which refers to a file on disk #233
-
Hello. I am wondering how packaging a Python code to FMU works if the Python code requires loading a physical file to memory (GPU)? Specifically, I have trained an AI model using Torch saved as a .pth file. To generate predictions (~4500 Real outputs) given inputs (about ~250 Real/Integer inputs), I first need to load the file to my device (CUDA). I would like to convert this to an FMU for co-simulation with other components in Dymola. I recognize that the dependent third party libraries must be recreated through environment.yml. How does this work with physical file dependencies? Any help is much appreciated. Below is an image for better illustration of the problem: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You will need to place the .pth file inside the FMU (resource folder). This is where project files are placed when using the CLI. Additionally, nothing is stopping you from hosting the .pth file on some web server, and have the FMU fetch the data dynamically. |
Beta Was this translation helpful? Give feedback.
You will need to place the .pth file inside the FMU (resource folder). This is where project files are placed when using the CLI.
Access the runtime path using
self.resources
.Additionally, nothing is stopping you from hosting the .pth file on some web server, and have the FMU fetch the data dynamically.