<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: mpi4py process can't exit normally in Intel® MPI Library</title>
    <link>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1428148#M10009</link>
    <description>&lt;LI-CODE lang="markup"&gt;import time
from mpi4py import MPI

comm = MPI.COMM_WORLD

if comm.rank != 0:
    time.sleep(1)
    print('rank [',comm.rank,'] started...',sep="")
else:
    time.sleep(10) # I think the sleep time of this process should be extended, and a tool like "top" should be used to observe whether other short-lived processes exit after completing the sleep. If the time the process sleeps is very short, the result of this program is your output. However, it is impossible to determine from the output alone whether other short-term processes are waiting for this long-term process to end.
    print('rank [',comm.rank,'] started...',sep="")
print('rank [',comm.rank,'] ended...',sep="")&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 07 Nov 2022 14:32:12 GMT</pubDate>
    <dc:creator>GoodLuck</dc:creator>
    <dc:date>2022-11-07T14:32:12Z</dc:date>
    <item>
      <title>mpi4py process can't exit normally</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1428020#M10004</link>
      <description>&lt;LI-CODE lang="markup"&gt;import time
from mpi4py import MPI

comm = MPI.COMM_WORLD

if comm.rank != 0:
    time.sleep(1)
    print('rank 1 exit...')
else:
    time.sleep(10000)
    print('rank 0 exit...')&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;In the above program, the processes did not exit after the execution of the non-0 process, they all waited for the 0 process to finish and exit together. But these non-0 processes will occupy computing resources.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;When using mpi4py under intel mpi, how can I achieve that each process launched exits normally after completing its own task, and not wait for all other processes to finish before exiting together?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 04:32:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1428020#M10004</guid>
      <dc:creator>GoodLuck</dc:creator>
      <dc:date>2022-11-07T04:32:11Z</dc:date>
    </item>
    <item>
      <title>Re: mpi4py process can't exit normally</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1428064#M10005</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for posting in the Intel communities.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By default, each process will exit normally after completing its own task, and will not wait for any other processes to finish before exiting.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please refer to the below code in which each process will perform its own task and exits normally without waiting for other processes to finish:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;import time
from mpi4py import MPI

comm = MPI.COMM_WORLD

if comm.rank != 0:
    time.sleep(1)
    print('rank [',comm.rank,'] started...',sep="")
else:
    time.sleep(10)
    print('rank [',comm.rank,'] started...',sep="")
print('rank [',comm.rank,'] ended...',sep="")
&lt;/LI-CODE&gt;
&lt;P&gt;Output:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SantoshY_Intel_1-1667807276196.png" style="width: 645px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/34886iD422F378C7C12101/image-dimensions/645x278?v=v2&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" width="645" height="278" role="button" title="SantoshY_Intel_1-1667807276196.png" alt="SantoshY_Intel_1-1667807276196.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If we want all the processes to exit together, we can use the Barrier() to synchronize the processes as shown in the below code:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;import time
from mpi4py import MPI

comm = MPI.COMM_WORLD

if comm.rank != 0:
    time.sleep(1)
    print('rank [',comm.rank,'] started...',sep="")
else:
    time.sleep(10)
    print('rank [',comm.rank,'] started...',sep="")
comm.Barrier()
print('rank [',comm.rank,'] ended...',sep="")
&lt;/LI-CODE&gt;
&lt;P&gt;Output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SantoshY_Intel_0-1667807226225.png" style="width: 668px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/34885i8CB45E062C0144D9/image-dimensions/668x286?v=v2&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" width="668" height="286" role="button" title="SantoshY_Intel_0-1667807226225.png" alt="SantoshY_Intel_0-1667807226225.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this resloves your issue, make sure to accept this as a solution. This would help others with similar issues. Thank you!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Santosh&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 07:48:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1428064#M10005</guid>
      <dc:creator>SantoshY_Intel</dc:creator>
      <dc:date>2022-11-07T07:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Re:mpi4py process can't exit normally</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1428066#M10006</link>
      <description>&lt;P&gt;First of all, thank you for your reply. However, didn't see where your code is. Secondly, have you tried the code I posted, maybe mpi4py will automatically call MPI_final function when exiting the process.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2022 07:46:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1428066#M10006</guid>
      <dc:creator>GoodLuck</dc:creator>
      <dc:date>2022-11-07T07:46:57Z</dc:date>
    </item>
    <item>
      <title>Re:mpi4py process can't exit normally</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1428092#M10007</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I posted the sample codes along with the outputs in my previous post. But, it might took sometime to reflect at your end. So, could you please check my previous post again? If you still unable to see the code, then please let us know so that we will repost.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Santosh&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 07 Nov 2022 09:49:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1428092#M10007</guid>
      <dc:creator>SantoshY_Intel</dc:creator>
      <dc:date>2022-11-07T09:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: mpi4py process can't exit normally</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1428148#M10009</link>
      <description>&lt;LI-CODE lang="markup"&gt;import time
from mpi4py import MPI

comm = MPI.COMM_WORLD

if comm.rank != 0:
    time.sleep(1)
    print('rank [',comm.rank,'] started...',sep="")
else:
    time.sleep(10) # I think the sleep time of this process should be extended, and a tool like "top" should be used to observe whether other short-lived processes exit after completing the sleep. If the time the process sleeps is very short, the result of this program is your output. However, it is impossible to determine from the output alone whether other short-term processes are waiting for this long-term process to end.
    print('rank [',comm.rank,'] started...',sep="")
print('rank [',comm.rank,'] ended...',sep="")&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 07 Nov 2022 14:32:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1428148#M10009</guid>
      <dc:creator>GoodLuck</dc:creator>
      <dc:date>2022-11-07T14:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: mpi4py process can't exit normally</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1428736#M10018</link>
      <description>&lt;P&gt;By default, mpi4py automatically intializes and finalizes MPI. As the call to `MPI_Finalize` is collective, your process 0 blocks at `MPI_Finalize` waiting for process 1 to reach the call.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do not want mpi4py to automatically finalize MPI, you can do the following:&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;import mpi4py
mpi4py.rc.finalize = False
from mpi4py import MPI
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nonetheless, be aware that this way your code may be non-portable to other MPI implementations. To the best of my understanding,&amp;nbsp; MPI_Finalize() should be called for clean parallel termination of your application.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 11:41:41 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1428736#M10018</guid>
      <dc:creator>dalcinl</dc:creator>
      <dc:date>2022-11-09T11:41:41Z</dc:date>
    </item>
    <item>
      <title>Re: mpi4py process can't exit normally</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1429684#M10029</link>
      <description>&lt;P&gt;(py3.9) ➜ /share mpirun -n 10 python test.py&lt;BR /&gt;rank 1 exit...&lt;BR /&gt;rank 1 exit...&lt;BR /&gt;rank 1 exit...&lt;BR /&gt;rank 1 exit...&lt;BR /&gt;rank 1 exit...&lt;BR /&gt;rank 1 exit...&lt;BR /&gt;rank 1 exit...&lt;BR /&gt;rank 1 exit...&lt;BR /&gt;rank 1 exit... #all 10 processes&amp;nbsp; exit immediately including process 0&lt;/P&gt;
&lt;P&gt;According to your kind of solution, I launched 10 processes. 9 non-zero processes exited, and all processes of the whole program also exited (but, at this time, process 0 has not finished executing!)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Nov 2022 09:08:39 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1429684#M10029</guid>
      <dc:creator>GoodLuck</dc:creator>
      <dc:date>2022-11-13T09:08:39Z</dc:date>
    </item>
    <item>
      <title>Re: mpi4py process can't exit normally</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1429932#M10034</link>
      <description>&lt;P&gt;Sorry, but something is wrong. All your lines say `rank 1 exited`. You are most likely not running exactly the same code you posted before.&lt;/P&gt;
&lt;P&gt;Anyway, I have to insist: you are trying to use MPI in a way it was not designed to work. All MPI processes should eventually call MPI_Finalize() before ending execution, and MPI_Finalize() is a collective and blocking operation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you should comment on what exactly you are trying to accomplish so that we can provide some informed advice on the best approach to tackle your needs.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Nov 2022 13:25:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1429932#M10034</guid>
      <dc:creator>dalcinl</dc:creator>
      <dc:date>2022-11-14T13:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: mpi4py process can't exit normally</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1429935#M10035</link>
      <description>&lt;LI-CODE lang="markup"&gt;import mpi4py
mpi4py.rc.finalize = False
from mpi4py import MPI
import sys
import time

comm = MPI.COMM_WORLD

if comm.rank != 0:
    time.sleep(5)
    print('rank 1 exit...')
else:
    time.sleep(10000)
    print('rank 0 exit...')&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;I am using this code. What are your run result using this code?&lt;/P&gt;</description>
      <pubDate>Mon, 14 Nov 2022 13:30:58 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1429935#M10035</guid>
      <dc:creator>GoodLuck</dc:creator>
      <dc:date>2022-11-14T13:30:58Z</dc:date>
    </item>
    <item>
      <title>Re: mpi4py process can't exit normally</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1429939#M10036</link>
      <description>&lt;P&gt;Right now I'm running MPICH&amp;nbsp; on macOS, I don't have access to my Linux workstation. I get output from all ranks but zero. I'm not sure why process 0 is not printing. Perhaps is just a I/O thing, or mpiexec is killing the rogue process 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In any case, that's what happen when you ignore the rules: you get undefined and weird behavior.&amp;nbsp; I insist, do yourself a favor and DO NOT rely on&amp;nbsp; my suggestion to avoid the blocking call to MPI_Finalize(). Otherwise, you may get a piece of code that works today, but it may stop working in the next Intel MPI version update, not to mention if you ever try to use a different MPI implementation or even platform/computing environment.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Nov 2022 13:45:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1429939#M10036</guid>
      <dc:creator>dalcinl</dc:creator>
      <dc:date>2022-11-14T13:45:05Z</dc:date>
    </item>
    <item>
      <title>Re: mpi4py process can't exit normally</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1429943#M10037</link>
      <description>&lt;P&gt;If as you say, my original question is not resolved ah, we are back to the beginning of the problem.&lt;/P&gt;</description>
      <pubDate>Mon, 14 Nov 2022 13:58:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1429943#M10037</guid>
      <dc:creator>GoodLuck</dc:creator>
      <dc:date>2022-11-14T13:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: mpi4py process can't exit normally</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1430913#M10056</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;&lt;EM&gt;&amp;gt;&amp;gt;"how can I achieve that each process launched exits normally after completing its own task, and not wait for all other processes to finish before exiting together?"&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;All processes must call the &lt;A href="https://www.mpich.org/static/docs/v3.1/www3/MPI_Finalize.html" target="_blank"&gt;MPI_Finalize&lt;/A&gt; routine before exiting. If not, it would result in an undefined behavior as said by&amp;nbsp;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/260608"&gt;@dalcinl&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;Implementing your scenario would result in an undefined behavior &amp;amp; it is not recommended as it is not following the guidelines of MPI.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;
&lt;P&gt;Santosh&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 12:18:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1430913#M10056</guid>
      <dc:creator>SantoshY_Intel</dc:creator>
      <dc:date>2022-11-17T12:18:02Z</dc:date>
    </item>
    <item>
      <title>Re:mpi4py process can't exit normally</title>
      <link>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1431669#M10064</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks for accepting our solution. If you need any additional information, please post a new question as this thread will no longer be monitored by Intel.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Santosh&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 21 Nov 2022 04:56:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-MPI-Library/mpi4py-process-can-t-exit-normally/m-p/1431669#M10064</guid>
      <dc:creator>SantoshY_Intel</dc:creator>
      <dc:date>2022-11-21T04:56:54Z</dc:date>
    </item>
  </channel>
</rss>

