- You may try out parallelization and other techniques of optimizing your code and see if your performance improves.
- If the problem still persists, then it must be due to delays in launching Matlab Runtime Environment multiple times. In this case you can try caching by using a Python Dictionary to store the results and try to avoid multiple access to the original Matlab file.
MATLAB On High Performance Computing (HPC)
조회 수: 16 (최근 30일)
이전 댓글 표시
Hello all,
I have a python code that calles a MATLAB compiled file many times during a single run to get information from a model built in MATLAB. When I run this code on Windows, it doesn't take time since I have MATLAB installed on my machine. To use the speed of HPC, when I run the model there, it takes a very long time to get my result (triple the speed on Windows). I wanted to ask if there is anyway to speed the process. I tried using MCR but still, it is quite slow
댓글 수: 0
답변 (1개)
Ayush Kashyap
2023년 7월 10일
Hi Mohamed,
To reslove the issue of speed of performance, you make try these two ways mainly:
I am attaching a simple example of implementing caching using python dictionary:
def cache_function(*inputs):
if inputs in cache_dict:
return cache_dict[inputs]
else:
result = call_matlab_compiled_file(*inputs)
cache_dict[inputs] = result
return result
Don't forget to replace your direct calls to Matlab files as follows:
cache_dict = {}
result = cache_function(input1, input2, ...)
Hope this helps resolve your problem.
Alternatively, you may also try out other libraries like 'functools.lru_cache' or 'cachetools'.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Python Package Integration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!