Load model and do inference in one workspace

Hello, I have question about memory workspaces.
I have 3 parts of code → 1) load model into cache. 2) do inference. 3) release model from cache. This cycle will be repeated N times. What I’m trying to do, is to create some workspace and load model into that workspace. At another time do inference with this model in that workspace and in the end, when cache expired I want to release memory by destroying that workspace. Is this even possible? If yes, what is proper way, how to create/get/handle workspaces? I know, you have some guides intended for workspaces, but it is not working for me and I want to understand it in right way.

Thank you

Which guide did you see?
Have you seen the code of the example on the GitHub repository yet?
This one: https://github.com/eclipse/deeplearning4j-examples/blob/master/nd4j-examples/src/main/java/org/nd4j/examples/Nd4jEx15_Workspaces.java

1 Like

Hello, I’m sorry, for really late answer, but I finally had time to try it.
Can’t find what guide I used anymore, but your link and this test DL4J: MLN/CG output overloads with output arrays in specified workspa… · eclipse/deeplearning4j@45f5ae9 · GitHub helped me to better understand memory workspaces.
Maybe one last question, if I use MultiLayerNetwork in one thread with workspaces enabled, some workspaces will be created. On second inference those workspaces will be reused (if I’m wrong, feel free to correct me please). But what, if I do first inference from first thread and after that I do second inference from second thread.? Is this even possible and how will those workspaces act?

Thank you in advance for your reply