Cannot import MPI from mpi4py

3,353 views
Skip to first unread message

Maha

unread,
May 7, 2018, 4:10:43 AM5/7/18
to mpi4py

I am trying to run an optimization program. But it gives the following  error
"ImportError: mpi4py is required for parallelization"
When I checked the mpi4py module is already loaded. But MPI cannot be imported from mpi4pyI. The following command generates the error.
" from mpi4py import MPI " gives "ImportError: DLL load failed: The specified module could not be found."

Could you please help me to solve the problem.
Thanks

Maha

Lisandro Dalcin

unread,
May 7, 2018, 4:12:42 AM5/7/18
to mpi4py
On Mon, 7 May 2018 at 11:10, Maha <maha...@gmail.com> wrote:


> I am trying to run an optimization program. But it gives the following
error
> "ImportError: mpi4py is required for parallelization"
> When I checked the mpi4py module is already loaded. But MPI cannot be
imported from mpi4pyI. The following command generates the error.
> " from mpi4py import MPI " gives "ImportError: DLL load failed: The
specified module could not be found."


So I have to guess you are using Windows. You need to install the Microsoft
MPI runtime: https://msdn.microsoft.com/en-us/library/bb524831(v=vs.85).aspx

--
Lisandro Dalcin
============
Research Scientist
Computer, Electrical and Mathematical Sciences & Engineering (CEMSE)
Extreme Computing Research Center (ECRC)
King Abdullah University of Science and Technology (KAUST)
http://ecrc.kaust.edu.sa/

4700 King Abdullah University of Science and Technology
al-Khawarizmi Bldg (Bldg 1), Office # 0109
Thuwal 23955-6900, Kingdom of Saudi Arabia
http://www.kaust.edu.sa

Office Phone: +966 12 808-0459

Maha

unread,
May 7, 2018, 9:31:11 AM5/7/18
to mpi4py
Dear Dalcin
Thank you very much for the straight forward answer. It solved the problem. It helped me a lot
Thanks
Maha

Maha D

unread,
May 8, 2018, 11:25:41 AM5/8/18
to mpi...@googlegroups.com
Dear Dalcin,
Thank you very much for the previous reply again.

I am trying to follow the example given in the 
and adapt to solve the problem given in the research paper "Engineering Optimization with Particle Swarm".

The results give only with No-parallelization but not for SPM-Parallelization and DPM_parallelization.  The error is followed.


Traceback (most recent call last):
  File "C:\Users\Maha\Documents\Python\Optimisation\ALPSO PreV.py", line 79, in <module>
    alpso_spm(opt_prob)
  File "C:\Python27\lib\site-packages\pyOpt\pyOpt_optimizer.py", line 160, in __call__
    return self.__solve__(opt_problem, *args, **kwargs)
  File "C:\Python27\lib\site-packages\pyOpt\pyALPSO\pyALPSO.py", line 414, in __solve__
    fileout,filename,log_file,hos_file,seed,scale,nhs,objconfunc)
  File "C:\Python27\lib\site-packages\pyOpt\pyALPSO\alpso_spm.py", line 146, in alpso
    h_start = Bcast(h_start, root=0)
UnboundLocalError: local variable 'Bcast' referenced before assignment


I can't understand why. Could you please clarify this too. 

I have attached the program with this.


Thank
s and regards,

Mahanama



--
You received this message because you are subscribed to the Google Groups "mpi4py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mpi4py+unsubscribe@googlegroups.com.
To post to this group, send email to mpi...@googlegroups.com.
Visit this group at https://groups.google.com/group/mpi4py.
To view this discussion on the web visit https://groups.google.com/d/msgid/mpi4py/CAEcYPwAN_x7XQthfLO9OFq6pPw3LkRYT3LUPGC_TiA66S4m_Sw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

ALPSO PreV.py

Lisandro Dalcin

unread,
May 8, 2018, 11:35:11 AM5/8/18
to mpi4py
Ask to the pyOpt folks. I did't write that code, this is not an mpi4py bug.
Look at the code in alpso_spm.py, it should be easy to fix, look around the
lines checking mpi4py.__version__, remove all that and just write "Bcast =
comm.bcast".
an email to mpi4py+un...@googlegroups.com.
>> To post to this group, send email to mpi...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/mpi4py.
>> To view this discussion on the web visit
https://groups.google.com/d/msgid/mpi4py/CAEcYPwAN_x7XQthfLO9OFq6pPw3LkRYT3LUPGC_TiA66S4m_Sw%40mail.gmail.com
.
>> For more options, visit https://groups.google.com/d/optout.


> --
> You received this message because you are subscribed to the Google Groups
"mpi4py" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to mpi4py+un...@googlegroups.com.
> To post to this group, send email to mpi...@googlegroups.com.
> Visit this group at https://groups.google.com/group/mpi4py.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/mpi4py/CAEkWiHHHxxJtTSNvK%3D6qj7pAVD-6ANXgViixh3p3ym6-gQvUbA%40mail.gmail.com
.
> For more options, visit https://groups.google.com/d/optout.



Reply all
Reply to author
Forward
0 new messages