Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

running Multiple COMSOL server and Matlab parallel

Please login with a confirmed email address before reporting spam

Dear all, I want to speed up my computations using the parfor loop in MATLAB. Therefore, I called 5 comsol server and use 5 workers in Matlab to connect these comsol servers. Below is the run.sh which called the comsol servers:

#!/bin/sh
#BSUB -q mpi
#BSUB -n 24
#BSUB –o %J.out
#BSUB –e %J.err
killall -9 comsollauncher java
sleep 15s
comsol server -np 1 -silent -port 1036 -tmpdir temporary_files1 &
comsol server -np 1 -silent -port 1046 -tmpdir temporary_files2 &
comsol server -np 1 -silent -port 1056 -tmpdir temporary_files3 &
comsol server -np 1 -silent -port 1066 -tmpdir temporary_files61 &
comsol server -np 1 -silent -port 1076 -tmpdir temporary_files81 &
sleep 60s
matlab -nodisplay -r three_D_aquifer_HPTT_parallel

It seems that when I only use one comsol server, this worked well. But when I use 5 comsol server, it will produce the error like:

java.lang.RuntimeException: Error initializing storage.
......
Caused by: java.io.FileNotFoundException: /share/home/shixq2/.comsol/v54/configuration/comsol/org.eclipse.osgi/.manager/.fileTableLock (No such file or directory) ......

Do you have any suggestions how to make this work?
Thank you in advance!
Xueyuan


4 Replies Last Post Jul 27, 2020, 11:32 a.m. EDT
COMSOL Moderator

Hello Xueyuan Kang

Your Discussion has gone 30 days without a reply. If you still need help with COMSOL and have an on-subscription license, please visit our Support Center for help.

If you do not hold an on-subscription license, you may find an answer in another Discussion or in the Knowledge Base.


Please login with a confirmed email address before reporting spam

Posted: 5 years ago Apr 24, 2020, 7:15 p.m. EDT
Updated: 4 years ago Jun 3, 2020, 1:54 a.m. EDT

Xueyuan,

I've been working on doing the same as you. I've been able to get this to work by following hints on this comsol forum - https://www.comsol.com/forum/thread/33446/parallel-computing-matlab-comsol. They start Comsol servers within a parfor loop, and then connect each individual parfor worker to a server with the "mphstart" function.

I hope this helps. If you need an example, please let me know.

Alex

Xueyuan, I've been working on doing the same as you. I've been able to get this to work by following hints on this comsol forum - https://www.comsol.com/forum/thread/33446/parallel-computing-matlab-comsol. They start Comsol servers within a parfor loop, and then connect each individual parfor worker to a server with the "mphstart" function. I hope this helps. If you need an example, please let me know. Alex

Please login with a confirmed email address before reporting spam

Posted: 4 years ago Jul 27, 2020, 11:20 a.m. EDT
Updated: 4 years ago Jul 27, 2020, 11:27 a.m. EDT

Hi, Xueyuan,

I've been working on doing the same as you. Have you solved your problem? In addition to the url that Alex mentioned, another url - http://cn.comsol.com/forum/thread/38557/parallel-computing-with-matlab-livelink-and-comsol?last=2013-07-20T17:37:08Z mentioned a similar solution. But for me, there are still mistakes. for example, when i used the code in the runfile,:

core=2; pp=parpool(core); comsolPort1 = 2036; system( ['D:\COMSOL\COMSOL55\Multiphysics\bin\win64\comsolmphserver.exe -np 1 -port ' num2str(comsolPort1) ' &'] ); pause(1) comsolPort2 = 2037; system( ['D:\COMSOL\COMSOL55\Multiphysics\bin\win64\comsolmphserver.exe -np 1 -port ' num2str(comsolPort2) ' &'] ); pause(1)

and the next code in my function contains my Comsol model :

cd('D:\COMSOL\COMSOL55\Multiphysics\mli') comsolPort=[2036 2037]; t = getCurrentTask() labit=t.ID mphstart(comsolPort(labit))

The calculation of the first round can be performed, but an error will be reported when the second round begins: Error using mphstart Already connected to a server

I thought the first-round model was still occupying ports, so I added the statement "Modelutil.disconnect;", but the calculation again prompted an error: Error using mphstart A connection to COMSOL could not be established. Please check that a COMSOL server is started prior to calling mphstart

I'm confused. Is there anything else to deal with ?

Weikai Xu

Hi, Xueyuan, I've been working on doing the same as you. Have you solved your problem? In addition to the url that Alex mentioned, another url - http://cn.comsol.com/forum/thread/38557/parallel-computing-with-matlab-livelink-and-comsol?last=2013-07-20T17:37:08Z mentioned a similar solution. But for me, there are still mistakes. for example, when i used the code in the runfile,: core=2; pp=parpool(core); comsolPort1 = 2036; system( ['D:\COMSOL\COMSOL55\Multiphysics\bin\win64\comsolmphserver.exe -np 1 -port ' num2str(comsolPort1) ' &'] ); pause(1) comsolPort2 = 2037; system( ['D:\COMSOL\COMSOL55\Multiphysics\bin\win64\comsolmphserver.exe -np 1 -port ' num2str(comsolPort2) ' &'] ); pause(1) and the next code in my function contains my Comsol model : cd('D:\COMSOL\COMSOL55\Multiphysics\mli') comsolPort=[2036 2037]; t = getCurrentTask() labit=t.ID mphstart(comsolPort(labit)) The calculation of the first round can be performed, but an error will be reported when the second round begins: Error using mphstart Already connected to a server I thought the first-round model was still occupying ports, so I added the statement "Modelutil.disconnect;", but the calculation again prompted an error: Error using mphstart A connection to COMSOL could not be established. Please check that a COMSOL server is started prior to calling mphstart I'm confused. Is there anything else to deal with ? Weikai Xu

Please login with a confirmed email address before reporting spam

Posted: 4 years ago Jul 27, 2020, 11:26 a.m. EDT

Xueyuan,

I've been working on doing the same as you. I've been able to get this to work by following hints on this comsol forum - https://www.comsol.com/forum/thread/33446/parallel-computing-matlab-comsol. They start Comsol servers within a parfor loop, and then connect each individual parfor worker to a server with the "mphstart" function.

I hope this helps. If you need an example, please let me know.

Alex

Dear Alex

I am in exactly the same situation as Xueyuan. May I ask how are you solved the problem? In addition to the url that you mentioned, another url - http://cn.comsol.com/forum/thread/38557/parallel-computing-with-matlab-livelink-and-comsol?last=2013-07-20T17:37:08Z mentioned a similar solution. But for me, there are still mistakes. For example, when i used the code in the runfile,:

core=2; pp=parpool(core); comsolPort1 = 2036; system( ['D:\COMSOL\COMSOL55\Multiphysics\bin\win64\comsolmphserver.exe -np 1 -port ' num2str(comsolPort1) ' &'] ); pause(1) comsolPort2 = 2037; system( ['D:\COMSOL\COMSOL55\Multiphysics\bin\win64\comsolmphserver.exe -np 1 -port ' num2str(comsolPort2) ' &'] ); pause(1)

and the next code in my function contains my Comsol model :

cd('D:\COMSOL\COMSOL55\Multiphysics\mli') comsolPort=[2036 2037]; t = getCurrentTask() labit=t.ID mphstart(comsolPort(labit))

The calculation of the first round can be performed, but an error will be reported when the second round begins: Error using mphstart Already connected to a server

I thought the first-round model was still occupying ports, so I added the statement "Modelutil.disconnect;", but the calculation again prompted an error:

Error using mphstart A connection to COMSOL could not be established. Please check that a COMSOL server is started prior to calling mphstart

I'm confused. Is there anything else to deal with ? Could you please kindly share your solution here? Looking forward to your reply very much, Thank you!

Kind regards, Weikai Xu

>Xueyuan, > >I've been working on doing the same as you. I've been able to get this to work by following hints on this comsol forum - https://www.comsol.com/forum/thread/33446/parallel-computing-matlab-comsol. They start Comsol servers within a parfor loop, and then connect each individual parfor worker to a server with the "mphstart" function. > >I hope this helps. If you need an example, please let me know. > >Alex Dear Alex I am in exactly the same situation as Xueyuan. May I ask how are you solved the problem? In addition to the url that you mentioned, another url - http://cn.comsol.com/forum/thread/38557/parallel-computing-with-matlab-livelink-and-comsol?last=2013-07-20T17:37:08Z mentioned a similar solution. But for me, there are still mistakes. For example, when i used the code in the runfile,: core=2; pp=parpool(core); comsolPort1 = 2036; system( ['D:\COMSOL\COMSOL55\Multiphysics\bin\win64\comsolmphserver.exe -np 1 -port ' num2str(comsolPort1) ' &'] ); pause(1) comsolPort2 = 2037; system( ['D:\COMSOL\COMSOL55\Multiphysics\bin\win64\comsolmphserver.exe -np 1 -port ' num2str(comsolPort2) ' &'] ); pause(1) and the next code in my function contains my Comsol model : cd('D:\COMSOL\COMSOL55\Multiphysics\mli') comsolPort=[2036 2037]; t = getCurrentTask() labit=t.ID mphstart(comsolPort(labit)) The calculation of the first round can be performed, but an error will be reported when the second round begins: Error using mphstart Already connected to a server I thought the first-round model was still occupying ports, so I added the statement "Modelutil.disconnect;", but the calculation again prompted an error: Error using mphstart A connection to COMSOL could not be established. Please check that a COMSOL server is started prior to calling mphstart I'm confused. Is there anything else to deal with ? Could you please kindly share your solution here? Looking forward to your reply very much, Thank you! Kind regards, Weikai Xu

Please login with a confirmed email address before reporting spam

Posted: 4 years ago Jul 27, 2020, 11:32 a.m. EDT

Hi, all

The format is correct in my reply box, but I don't know why some Enters disappear after submission. I'm sorry for the trouble to you!

Regards, Weikai Xu

Hi, all The format is correct in my reply box, but I don't know why some Enters disappear after submission. I'm sorry for the trouble to you! Regards, Weikai Xu

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.