<bdo id='VxM11'></bdo><ul id='VxM11'></ul>

<legend id='VxM11'><style id='VxM11'><dir id='VxM11'><q id='VxM11'></q></dir></style></legend>
  • <tfoot id='VxM11'></tfoot>

      <i id='VxM11'><tr id='VxM11'><dt id='VxM11'><q id='VxM11'><span id='VxM11'><b id='VxM11'><form id='VxM11'><ins id='VxM11'></ins><ul id='VxM11'></ul><sub id='VxM11'></sub></form><legend id='VxM11'></legend><bdo id='VxM11'><pre id='VxM11'><center id='VxM11'></center></pre></bdo></b><th id='VxM11'></th></span></q></dt></tr></i><div id='VxM11'><tfoot id='VxM11'></tfoot><dl id='VxM11'><fieldset id='VxM11'></fieldset></dl></div>

      <small id='VxM11'></small><noframes id='VxM11'>

      1. 多处理:在 PyObject_Call 中没有错误的 NULL 结果

        Multiprocessing : NULL result without error in PyObject_Call(多处理:在 PyObject_Call 中没有错误的 NULL 结果)

              <small id='hfsyQ'></small><noframes id='hfsyQ'>

                <tbody id='hfsyQ'></tbody>
                <bdo id='hfsyQ'></bdo><ul id='hfsyQ'></ul>

              • <i id='hfsyQ'><tr id='hfsyQ'><dt id='hfsyQ'><q id='hfsyQ'><span id='hfsyQ'><b id='hfsyQ'><form id='hfsyQ'><ins id='hfsyQ'></ins><ul id='hfsyQ'></ul><sub id='hfsyQ'></sub></form><legend id='hfsyQ'></legend><bdo id='hfsyQ'><pre id='hfsyQ'><center id='hfsyQ'></center></pre></bdo></b><th id='hfsyQ'></th></span></q></dt></tr></i><div id='hfsyQ'><tfoot id='hfsyQ'></tfoot><dl id='hfsyQ'><fieldset id='hfsyQ'></fieldset></dl></div>
                  <tfoot id='hfsyQ'></tfoot>
                  <legend id='hfsyQ'><style id='hfsyQ'><dir id='hfsyQ'><q id='hfsyQ'></q></dir></style></legend>

                  本文介绍了多处理:在 PyObject_Call 中没有错误的 NULL 结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  Here is a sample program where I use multiprocessing. The calculations are done with multiprocessing.Process and the results are collected using multiprocessing.Queue.

                  #THIS PROGRAM RUNS WITH ~40Gb RAM. (you can reduce a,b,c for less RAM 
                  #but then it works for smaller values)
                  #PROBLEM OCCURS ONLY FOR HUGE DATA.   
                  from numpy import *
                  import multiprocessing as mp
                  
                  a = arange(0, 3500, 5)
                  b = arange(0, 3500, 5)
                  c = arange(0, 3500, 5)  
                  a0 = 540. #random values
                  b0 = 26.
                  c0 = 826.
                  def rand_function(a, b, c, a0, b0, c0):
                      Nloop = 100.
                      def loop(Nloop, out):
                          res_total = zeros((700, 700, 700), dtype = 'float') 
                          n = 1
                          while n <= Nloop:
                              rad = sqrt((a-a0)**2 + (b-b0)**2 + (c-c0)**2)
                              res_total += rad
                              n +=1 
                          out.put(res_total)
                      out = mp.Queue() 
                      jobs = []
                      Nprocs = mp.cpu_count()
                      print "No. of processors : ", Nprocs
                      for i in range(Nprocs):
                          p = mp.Process(target = loop, args=(Nloop/Nprocs, out)) 
                          jobs.append(p)
                          p.start()
                  
                      final_result = zeros((700, 700, 700), dtype = 'float')
                  
                      for i in range(Nprocs):
                          final_result = final_result + out.get()
                  
                      p.join()
                  test = rand_function(a,b,c,a0, b0, c0)
                  

                  Here is the error message :

                  Traceback (most recent call last):
                    File "/usr/lib/python2.7/multiprocessing/queues.py", line 266, in _feed
                      send(obj)
                  SystemError: NULL result without error in PyObject_Call
                  

                  I read here that it is a bug. But I am unable to understand. Can anyone please tell me any way out to calculate huge data using multiprocessing?

                  Thank you very much

                  解决方案

                  The bug report your reference states that multiprocessing module is unable to push huge arguments to subprocess.

                  The reason is that it needs to pickle these arguments and store the pickled blob somewhere in memory.

                  You, however, don't need to pass arrays as arguments.

                  Possible causes:

                  • passing a closure loop as a target
                  • passing mp.Queue() as argument

                  Please see http://stevenengelhardt.com/2013/01/16/python-multiprocessing-module-and-closures/ about converting your closure to a class.

                  Set up full state before you give control to multiprocessing.

                  这篇关于多处理:在 PyObject_Call 中没有错误的 NULL 结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                  Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                  Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                  Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                  Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                  Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)

                    <tbody id='wfLOG'></tbody>

                      <small id='wfLOG'></small><noframes id='wfLOG'>

                        <i id='wfLOG'><tr id='wfLOG'><dt id='wfLOG'><q id='wfLOG'><span id='wfLOG'><b id='wfLOG'><form id='wfLOG'><ins id='wfLOG'></ins><ul id='wfLOG'></ul><sub id='wfLOG'></sub></form><legend id='wfLOG'></legend><bdo id='wfLOG'><pre id='wfLOG'><center id='wfLOG'></center></pre></bdo></b><th id='wfLOG'></th></span></q></dt></tr></i><div id='wfLOG'><tfoot id='wfLOG'></tfoot><dl id='wfLOG'><fieldset id='wfLOG'></fieldset></dl></div>
                        <legend id='wfLOG'><style id='wfLOG'><dir id='wfLOG'><q id='wfLOG'></q></dir></style></legend>

                        • <tfoot id='wfLOG'></tfoot>
                            <bdo id='wfLOG'></bdo><ul id='wfLOG'></ul>