Clear Filters
Clear Filters

parfor works but parcluster fails using Cellpose in linux

4 views (last 30 days)
Hello all,
I am trying to run parallel jobs in Matlab in linux system. I used the Matlab Add-on Cellpose, which needs Matlab versoion later than 2023b.
parfor i=1:4
img = imread('calibrated-P01.001.tif');
cp=cellpose;
segmentCells2D(cp,img,ImageCellDiameter=110);
end
The parfor using Cellpose works.
But when I try to use parcluster/createJob/createTask, it falls. Here is the code
clustLocal = parcluster('Processes')
j = createJob(clustLocal,'AutoAddClientPath',true)
createTask(j,@TestCellpose,0,{},'CaptureDiary',true)
submit(j)
function TestCellpose
img = imread('calibrated-P01.001.tif');
cp=cellpose;
segmentCells2D(cp,img,ImageCellDiameter=110);
end
The error message
Error: Unable to resolve the name 'py.MWCellposeWrapper.setModelsFolderPath'
I prefer using parcluster because it can run the code in backgound.
Does anyone know how to solve the problem?
Thanks a lot!
  4 Comments
Venkat Siddarth Reddy
Venkat Siddarth Reddy on 7 May 2024
Edited: Venkat Siddarth Reddy on 7 May 2024
It seems the OS is offically supported by MATLAB R2023b( https://www.mathworks.com/content/dam/mathworks/mathworks-dot-com/support/sysreq/files/system-requirements-release-2023b-linux.pdf ). I am suspecting there might be an issue in the gateway between python and MATLAB.
Can you run the following code snippet and share the output of it?
pyenv()
string(py.sys.path)'
getenv('PATH')
mwpylib = py.importlib.import_module('MWCellposeWrapper') ;
Yunwei
Yunwei on 7 May 2024
Hi,
the output is attached. What pizzles me is in parfor the Cellpose works but not in parcluster.
I wrote path = getenv('PATH').

Sign in to comment.

Answers (1)

Swastik
Swastik on 22 May 2024
Hello @Yunwei,
It appears you have encountered an issue when utilizing parcluster in conjunction with the Cellpose Library, a problem that was not present when using parfor. Your preference for parcluster stems from its ability to submit tasks that can run in the background.
I recommend exploring the batch function in MATLAB. The batch function is designed to execute commands or scripts in the background, like parcluster, but it specifically spawns parfor loops for its execution. This means you can achieve the same level of background processing that parcluster offers, potentially without the error you encountered.
To learn more about the batch function, please visit the following MATLAB Documentation page:
Hope this will solve your issue.

Categories

Find more on Parallel Computing Fundamentals in Help Center and File Exchange

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!