MATLAB On High Performance Computing (HPC)

조회 수: 16 (최근 30일)
Mohamed AKI Ahmed
Mohamed AKI Ahmed 2023년 7월 10일
답변: Ayush Kashyap 2023년 7월 10일
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

답변 (1개)

Ayush Kashyap
Ayush Kashyap 2023년 7월 10일
Hi Mohamed,
To reslove the issue of speed of performance, you make try these two ways mainly:
  • 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.
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'.

카테고리

Help CenterFile Exchange에서 Python Package Integration에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by