Python 带dill的Pathos p_tqdm多进程错误
我正在尝试使用Python 带dill的Pathos p_tqdm多进程错误,python,pickle,python-multiprocessing,dill,pathos,Python,Pickle,Python Multiprocessing,Dill,Pathos,我正在尝试使用p\u map()通过p\u tqdm库运行一些代码,以并行化一些代码。我遇到了这个与dill有关的错误,我想不出来 Traceback (most recent call last): File "C:\Users\uid\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner self.run() File "C:
p\u map()
通过p\u tqdm
库运行一些代码,以并行化一些代码。我遇到了这个与dill有关的错误,我想不出来
Traceback (most recent call last):
File "C:\Users\uid\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\uid\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\uid\AppData\Local\Programs\Python\Python38\lib\site-packages\multiprocess\pool.py", line 576, in _handle_results
task = get()
File "C:\Users\uid\AppData\Local\Programs\Python\Python38\lib\site-packages\multiprocess\connection.py", line 254, in recv
return _ForkingPickler.loads(buf.getbuffer())
File "C:\Users\uid\AppData\Local\Programs\Python\Python38\lib\site-packages\dill\_dill.py", line 275, in loads
return load(file, ignore, **kwds)
File "C:\Users\uid\AppData\Local\Programs\Python\Python38\lib\site-packages\dill\_dill.py", line 270, in load
return Unpickler(file, ignore=ignore, **kwds).load()
File "C:\Users\uid\AppData\Local\Programs\Python\Python38\lib\site-packages\dill\_dill.py", line 473, in load
obj = StockUnpickler.load(self)
TypeError: __init__() takes 1 positional argument but 2 were given
我的代码结构如下:
import pickle
from p_tqdm import p_map
def my_func(data_fp):
data = pickle.load(open(data_fp, 'rb'))
# Do basic stuff to the data here.
return True
class MyClass():
def process_data(self):
# Do prep stuff here....get a list of filepaths we will need to load.
ret = p_map(my_func, data_fp_list, num_cpus=0.75)
return True
(process\u data()
我在运行python3.8.2
的windows10机器和RHEL7机器上都遇到过这种故障。我的pip列表
给出了:
dill 0.3.2
filelock 3.0.12
future 0.18.2
idna 2.9
joblib 0.14.1
kiwisolver 1.2.0
matplotlib 3.2.1
multiprocess 0.70.10
numpy 1.18.3
p-tqdm 1.3.3
packaging 20.4
pandas 1.0.3
pathos 0.2.6
Pillow 7.1.1
pip 20.1.1
pox 0.2.8
ppft 1.6.6.2
pyparsing 2.4.7
pytesseract 0.3.4
python-dateutil 2.8.1
pytz 2020.1
regex 2020.5.7
requests 2.23.0
sacremoses 0.0.43
scikit-learn 0.23.1
scipy 1.4.1
sentencepiece 0.1.90
setuptools 41.2.0
six 1.14.0
threadpoolctl 2.1.0
tokenizers 0.8.1rc1
torch 1.5.0+cpu
torchvision 0.6.0+cpu
tqdm 4.45.0
transformers 3.0.2
urllib3 1.25.9
Wand 0.5.9
我曾看到有人问过类似的问题,关于pathos
,因为它与dill/pickle
有关,但我不能完全理解它。我的处境和你一样吗
更新:
内置的多处理
库映射
函数也会发生这种情况,但如果使用线程而不是进程,则不会发生这种情况concurrent.futures.ThreadPoolExecutor.map()
工作起来很有魅力。我不知道这是否表明我正在处理的数据存在问题。对于同一条船上的其他人,我通过使用concurrent.futures.ThreadPoolExecutor.map
绕过了这个问题。线程似乎可以解决这个酸洗问题。仍然不知道为什么会发生这种情况,也不知道实际的修复方法是什么。对于同一条船上的其他人,我通过使用concurrent.futures.ThreadPoolExecutor.map
绕过了这个问题。线程似乎可以解决这个酸洗问题。仍然不知道为什么会发生这种情况,也不知道实际的解决办法是什么。