久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <i id='1iteZ'><tr id='1iteZ'><dt id='1iteZ'><q id='1iteZ'><span id='1iteZ'><b id='1iteZ'><form id='1iteZ'><ins id='1iteZ'></ins><ul id='1iteZ'></ul><sub id='1iteZ'></sub></form><legend id='1iteZ'></legend><bdo id='1iteZ'><pre id='1iteZ'><center id='1iteZ'></center></pre></bdo></b><th id='1iteZ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='1iteZ'><tfoot id='1iteZ'></tfoot><dl id='1iteZ'><fieldset id='1iteZ'></fieldset></dl></div>

      <small id='1iteZ'></small><noframes id='1iteZ'>

      <tfoot id='1iteZ'></tfoot>
          <bdo id='1iteZ'></bdo><ul id='1iteZ'></ul>
        <legend id='1iteZ'><style id='1iteZ'><dir id='1iteZ'><q id='1iteZ'></q></dir></style></legend>
      1. 帶有悲情的 Python 多處理

        Python multiprocessing with pathos(帶有悲情的 Python 多處理)
        <i id='TuVNu'><tr id='TuVNu'><dt id='TuVNu'><q id='TuVNu'><span id='TuVNu'><b id='TuVNu'><form id='TuVNu'><ins id='TuVNu'></ins><ul id='TuVNu'></ul><sub id='TuVNu'></sub></form><legend id='TuVNu'></legend><bdo id='TuVNu'><pre id='TuVNu'><center id='TuVNu'></center></pre></bdo></b><th id='TuVNu'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='TuVNu'><tfoot id='TuVNu'></tfoot><dl id='TuVNu'><fieldset id='TuVNu'></fieldset></dl></div>
      2. <small id='TuVNu'></small><noframes id='TuVNu'>

        • <legend id='TuVNu'><style id='TuVNu'><dir id='TuVNu'><q id='TuVNu'></q></dir></style></legend>

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

              1. <tfoot id='TuVNu'></tfoot>
                  <tbody id='TuVNu'></tbody>

                  本文介紹了帶有悲情的 Python 多處理的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我正在嘗試使用 Python 的 pathos 將計算指定到單獨的進程中,以便使用多核處理器加速它.我的代碼組織如下:

                  I am trying to use Python's pathos to designate computations into separate processes in order to accelerate it with multicore processor. My code is organized like:

                  class:
                     def foo(self,name):
                      ...
                      setattr(self,name,something)
                      ...
                     def boo(self):
                        for name in list:
                           self.foo(name)
                  

                  由于我在使用 multiprocessing.Pool 時遇到了酸洗問題,所以我決定嘗試一下 pathos.我嘗試過,如先前主題中所建議的那樣:

                  As I had pickling problems with multiprocessing.Pool, I decided to try pathos. I tried, as suggested in previous topics:

                  import pathos.multiprocessing
                  

                  但它導致錯誤:沒有模塊多處理 - 我在最新的 pathos 版本中找不到.

                  but it resulted in error: No module multiprocessing - which I can't find in latest pathos version.

                  然后我嘗試修改boo方法:

                  Then I tried modify boo method:

                  def boo(self):
                   import pathos
                   pathos.pp_map.pp_map(self.foo,list)
                  

                  現(xiàn)在沒有拋出錯誤,但 foo 不起作用 - 我的類的實例沒有新屬性.請幫助我,因為在花了一天時間之后,我不知道下一步該去哪里.

                  Now there is no error thrown, but foo does not work - instance of my class has no new attributes. Please help me, because I have no idea where to move next, after a day spent on that.

                  推薦答案

                  我是pathos的作者.我不確定您想從上面的代碼中做什么.但是,我也許可以闡明一些觀點.下面是一些類似的代碼:

                  I'm the pathos author. I'm not sure what you want to do from your code above. However, I can maybe shed some light. Here's some similar code:

                  >>> from pathos.multiprocessing import ProcessingPool
                  >>> class Bar:
                  ...   def foo(self, name):
                  ...     return len(str(name))
                  ...   def boo(self, things):
                  ...     for thing in things:
                  ...       self.sum += self.foo(thing)
                  ...     return self.sum
                  ...   sum = 0
                  ... 
                  >>> b = Bar()
                  >>> results = ProcessingPool().map(b.boo, [[12,3,456],[8,9,10],['a','b','cde']])
                  >>> results
                  [6, 4, 5]
                  >>> b.sum
                  0
                  

                  那么上面發(fā)生的事情是 Bar 實例 bboo 方法在 b.boo 被傳遞給一個新的 python 進程,然后對每個嵌套列表進行評估.可以看到結(jié)果是正確的……len("12")+len("3")+len("456")是6,以此類推.

                  So what happens above, is that the boo method of the Bar instance b is called where b.boo is passed to a new python process, and then evaluated for each of the nested lists. You can see that the results are correct… len("12")+len("3")+len("456") is 6, and so on.

                  但是,您也可以看到,當您查看 b.sum 時,它神秘地仍然是 0.為什么 b.sum 仍然為零?好吧,multiprocessing(以及pathos.multiprocessing)所做的,就是將您通過地圖傳遞給其他python的任何內(nèi)容進行COPY過程……然后(并行)調(diào)用復制的實例并返回被調(diào)用的方法調(diào)用的任何結(jié)果.請注意,您必須返回結(jié)果,或打印它們,或記錄它們,或?qū)⑺鼈儼l(fā)送到文件,或以其他方式.它們無法像您預期的那樣返回到原始實例,因為它不是發(fā)送到其他處理器的原始實例.實例的副本被創(chuàng)建,然后被丟棄——它們每個都增加了它們的 sum 屬性,但原始的 `b.sum' 沒有改變.

                  However, you can also see that when you look at b.sum, it's mysteriously still 0. Why is b.sum still zero? Well, what multiprocessing (and thus also pathos.multiprocessing) does, is make a COPY of whatever you pass through the map to the other python process… and then the copied instance is then called (in parallel) and return whatever results are called by the method invoked. Note you have to RETURN results, or print them, or log them, or send them to a file, or otherwise. They can't go back to the original instance as you might expect, because it's not the original instance that's sent over to the other processors. The copies of the instance are created, then disposed of -- each of them had their sum attribute increased, but the original `b.sum' is untouched.

                  然而,pathos 內(nèi)計劃使上述工作如您所料 - 原始對象 IS 已更新,但它不起作用還是那樣.

                  There is however, plans within pathos to make something like the above work as you might expect -- where the original object IS updated, but it doesn't work like that yet.

                  如果您使用 pip 進行安裝,請注意最新發(fā)布的 pathos 版本已有幾年歷史,可能無法安裝正確,或者可能無法安裝所有子模塊.一個新的 pathos 版本正在等待中,但在那之前,最好從 github 獲取最新版本的代碼,然后從那里安裝.主干大部分穩(wěn)定在開發(fā)中.我認為您的問題可能是由于安裝中的新"pip --舊"pathos 不兼容,并非所有軟件包都已安裝.如果 pathos.multiprocessing 缺失,這很可能是罪魁禍首.

                  If you are installing with pip, note that the latest released version of pathos is several years old, and may not install correctly, or may not install all of the submodules. A new pathos release is pending, but until then, it's better to get the latest version of the code from github, and install from there. The trunk is for the most part stable under development. I think your issue may have been that not all packages were installed, due to a "new" pip -- "old" pathos incompatibility in the install. If pathos.multiprocessing is missing, this is the most likely culprit.

                  在此處從 github 獲取 pathos:https://github.com/uqfoundation/pathos

                  Get pathos from github here: https://github.com/uqfoundation/pathos

                  這篇關于帶有悲情的 Python 多處理的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  What exactly is Python multiprocessing Module#39;s .join() Method Doing?(Python 多處理模塊的 .join() 方法到底在做什么?)
                  Passing multiple parameters to pool.map() function in Python(在 Python 中將多個參數(shù)傳遞給 pool.map() 函數(shù))
                  multiprocessing.pool.MaybeEncodingError: #39;TypeError(quot;cannot serialize #39;_io.BufferedReader#39; objectquot;,)#39;(multiprocessing.pool.MaybeEncodingError: TypeError(cannot serialize _io.BufferedReader object,)) - IT屋-程序員軟件開
                  Python Multiprocess Pool. How to exit the script when one of the worker process determines no more work needs to be done?(Python 多進程池.當其中一個工作進程確定不再需要完成工作時,如何退出腳本?) - IT屋-程序員
                  How do you pass a Queue reference to a function managed by pool.map_async()?(如何將隊列引用傳遞給 pool.map_async() 管理的函數(shù)?)
                  yet another confusion with multiprocessing error, #39;module#39; object has no attribute #39;f#39;(與多處理錯誤的另一個混淆,“模塊對象沒有屬性“f)
                1. <i id='kHVVh'><tr id='kHVVh'><dt id='kHVVh'><q id='kHVVh'><span id='kHVVh'><b id='kHVVh'><form id='kHVVh'><ins id='kHVVh'></ins><ul id='kHVVh'></ul><sub id='kHVVh'></sub></form><legend id='kHVVh'></legend><bdo id='kHVVh'><pre id='kHVVh'><center id='kHVVh'></center></pre></bdo></b><th id='kHVVh'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='kHVVh'><tfoot id='kHVVh'></tfoot><dl id='kHVVh'><fieldset id='kHVVh'></fieldset></dl></div>

                  1. <tfoot id='kHVVh'></tfoot>
                        <tbody id='kHVVh'></tbody>
                        <bdo id='kHVVh'></bdo><ul id='kHVVh'></ul>
                        <legend id='kHVVh'><style id='kHVVh'><dir id='kHVVh'><q id='kHVVh'></q></dir></style></legend>
                        • <small id='kHVVh'></small><noframes id='kHVVh'>

                            主站蜘蛛池模板: 日韩成人在线观看 | 午夜理伦三级理论三级在线观看 | 亚洲国产一区在线 | 91视视频在线观看入口直接观看 | 国产网站在线免费观看 | 在线观看毛片网站 | 欧美一级电影免费 | 欧美国产日韩在线观看 | 欧美日韩在线一区二区三区 | 日韩免费福利视频 | 免费高潮视频95在线观看网站 | 日韩精品视频在线 | 日本不卡一区二区三区 | 欧美日韩国产一区二区三区 | 日日骚av | 黄色免费观看 | 中文字幕一区二区三区四区 | 亚洲综合视频 | 亚洲国产成人在线观看 | 国产精品成人一区二区三区夜夜夜 | 欧美 日韩 国产 成人 在线 91 | 国产一区久久 | 一区二区三区在线 | 欧美视频一区二区三区 | 日韩成人av在线 | 男女视频在线免费观看 | 亚洲精品www久久久久久广东 | 精品视频在线播放 | 日本人做爰大片免费观看一老师 | 国产美女在线看 | 黄色片在线 | 玖玖视频免费 | 成人av网站在线观看 | 一区二区三区四区电影视频在线观看 | 在线日韩福利 | 狠狠干天天干 | 亚洲欧洲在线视频 | 久久久久无码国产精品一区 | 操到爽| 国产欧美一区二区三区久久手机版 | 精品伦精品一区二区三区视频 |