动态图版本修改num_workers,不同配置出现不同情况的训练崩溃
如题,我在aistudio上使用python3.7 + PaddlePaddle 2.0.0.rc0的环境,并使用了11月23日最新的Paddleseg develop分支进行训练,当num_workers使用默认参数时,训练一切正常;但是当num_workers设置为6时,无法启动训练,直接崩溃,LOG如下:
W1124 11:17:10.012058 2725 device_context.cc:338] Please NOTE: device: 0, CUDA Capability: 70, Driver API Version: 10.1, Runtime API Version: 10.1 W1124 11:17:10.012121 2725 device_context.cc:346] device: 0, cuDNN Version: 7.6. 2020-11-24 11:17:14 [INFO] Loading pretrained model from https://bj.bcebos.com/paddleseg/dygraph/hrnet_w48_ssld.tar.gz 2020-11-24 11:17:17 [INFO] There are 1525/1525 variables loaded into HRNet. ERROR:root:DataLoader reader thread raised an exception! Exception in thread Thread-2: Traceback (most recent call last): File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dataloader/dataloader_iter.py", line 648, in _get_data data = self._data_queue.get(timeout=self._timeout) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/multiprocessing/queues.py", line 105, in get raise Empty _queue.Empty
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/threading.py", line 926, in _bootstrap_inner self.run() File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/threading.py", line 870, in run self._target(*self._args, **self._kwargs) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dataloader/dataloader_iter.py", line 580, in _thread_loop batch = self._get_data() File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dataloader/dataloader_iter.py", line 664, in _get_data "pids: {}".format(len(failed_workers), pids)) RuntimeError: DataLoader 6 workers exit unexpectedly, pids: 2745, 2746, 2747, 2748, 2749, 2750
Traceback (most recent call last):
File "train.py", line 141, in
C++ Traceback (most recent call last):
0 std::thread::_State_impl<std::thread::_Invoker<std::tuple<ThreadPool::ThreadPool(unsigned long)::{lambda()#1}> > >::_M_run() 1 std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>, bool) 2 paddle::operators::reader::PyReader::ReadNext(std::vector<paddle::framework::LoDTensor, std::allocatorpaddle::framework::LoDTensor >) 3 paddle::operators::reader::BlockingQueue<std::vector<paddle::framework::LoDTensor, std::allocatorpaddle::framework::LoDTensor > >::Receive(std::vector<paddle::framework::LoDTensor, std::allocatorpaddle::framework::LoDTensor >) 4 paddle::platform::EnforceNotMet::EnforceNotMet(std::string const&, char const*, int) 5 paddle::platform::GetCurrentTraceBackStringabi:cxx11
Error Message Summary:
FatalError: Blocking queue is killed because the data reader raises an exception. [Hint: Expected killed_ != true, but received killed_:1 == true:1.] (at /paddle/paddle/fluid/operators/reader/blocking_queue.h:154)
INFO 2020-11-24 11:17:30,806 utils.py:275] terminate all the procs ERROR 2020-11-24 11:17:30,806 utils.py:445] ABORT!!! Out of all 1 trainers, the trainer process with rank=[0] was aborted. Please check its log. INFO 2020-11-24 11:17:33,808 utils.py:275] terminate all the procs
之后我担心是因为aistudio不支持六线程,所以我把num_workers改为了2,起初正常训练,但是当第一个epoch训练结束后,即将进行第二epoch时,突然崩溃报错,LOG信息如下:
2020-11-24 12:25:50 [INFO] [TRAIN] epoch=1, iter=6600/160000, loss=0.9178, lr=0.009628, batch_cost=0.5062, reader_cost=0.0002 | ETA 21:34:16
2020-11-24 12:27:30 [INFO] [TRAIN] epoch=1, iter=6800/160000, loss=0.9466, lr=0.009617, batch_cost=0.5025, reader_cost=0.0002 | ETA 21:22:58
2020-11-24 12:29:11 [INFO] [TRAIN] epoch=1, iter=7000/160000, loss=0.8990, lr=0.009605, batch_cost=0.5035, reader_cost=0.0002 | ETA 21:23:53
2020-11-24 12:30:51 [INFO] [TRAIN] epoch=1, iter=7200/160000, loss=0.8944, lr=0.009594, batch_cost=0.5022, reader_cost=0.0002 | ETA 21:18:57
2020-11-24 12:32:32 [INFO] [TRAIN] epoch=1, iter=7400/160000, loss=0.8827, lr=0.009583, batch_cost=0.5016, reader_cost=0.0002 | ETA 21:15:37
2020-11-24 12:34:12 [INFO] [TRAIN] epoch=1, iter=7600/160000, loss=0.8959, lr=0.009572, batch_cost=0.5016, reader_cost=0.0002 | ETA 21:13:58
2020-11-24 12:35:52 [INFO] [TRAIN] epoch=1, iter=7800/160000, loss=0.8504, lr=0.009560, batch_cost=0.5026, reader_cost=0.0002 | ETA 21:15:02
2020-11-24 12:37:33 [INFO] [TRAIN] epoch=1, iter=8000/160000, loss=0.8318, lr=0.009549, batch_cost=0.5023, reader_cost=0.0002 | ETA 21:12:23
2020-11-24 12:37:33 [INFO] Start evaluating (total_samples=2919, total_iters=2919)...
2919/2919 [==============================] - 349s 120ms/step
2020-11-24 12:43:22 [INFO] [EVAL] #Images=2919 mIoU=0.5434 Acc=0.8826 Kappa=0.8171
2020-11-24 12:43:22 [INFO] [EVAL] Class IoU:
[0.7062 0.8445 0.7874 0.8723 0.0762 0.0091 0.5084]
2020-11-24 12:43:22 [INFO] [EVAL] Class Acc:
[0.8305 0.8737 0.8944 0.9597 0.2308 0.5468 0.7574]
2020-11-24 12:43:32 [INFO] [EVAL] The model with the best validation mIoU (0.5434) was saved at iter 8000.
2020-11-24 12:45:14 [INFO] [TRAIN] epoch=1, iter=8200/160000, loss=0.9237, lr=0.009538, batch_cost=0.5080, reader_cost=0.0008 | ETA 21:25:19
2020-11-24 12:46:55 [INFO] [TRAIN] epoch=1, iter=8400/160000, loss=0.8876, lr=0.009526, batch_cost=0.5059, reader_cost=0.0003 | ETA 21:18:08
2020-11-24 12:48:36 [INFO] [TRAIN] epoch=1, iter=8600/160000, loss=0.8928, lr=0.009515, batch_cost=0.5053, reader_cost=0.0002 | ETA 21:15:06
2020-11-24 12:50:17 [INFO] [TRAIN] epoch=1, iter=8800/160000, loss=0.8726, lr=0.009504, batch_cost=0.5063, reader_cost=0.0002 | ETA 21:15:50
Traceback (most recent call last):
File "train.py", line 141, in
C++ Traceback (most recent call last):
0 paddle::imperative::ThrowErrorIfLoadProcessFailed() 1 paddle::platform::GetCurrentTraceBackStringabi:cxx11
Error Message Summary:
FatalError: DataLoader process (pid 1. If run DataLoader by DataLoader.from_generator(...), queue capacity is set by from_generator(..., capacity=xx, ...).
2. If run DataLoader by DataLoader(dataset, ...), queue capacity is set as 2 times of the max value of num_workers and len(places).
3. If run by DataLoader(dataset, ..., use_shared_memory=True), set use_shared_memory=False for not using shared memory.) exited is killed by signal: 5882.
It may be caused by insufficient shared storage space. This problem usually occurs when using docker as a development environment.
Please use command df -h to check the storage space of /dev/shm. Shared storage space needs to be greater than (DataLoader Num * DataLoader queue capacity * 1 batch data size).
You can solve this problem by increasing the shared storage space or reducing the queue capacity appropriately.
Bus error (at /paddle/paddle/fluid/imperative/data_loader.cc:161)
INFO 2020-11-24 12:51:34,541 utils.py:275] terminate all the procs ERROR 2020-11-24 12:51:34,541 utils.py:445] ABORT!!! Out of all 1 trainers, the trainer process with rank=[0] was aborted. Please check its log. INFO 2020-11-24 12:51:37,545 utils.py:275] terminate all the procs
共享内存不足了,只要reader_cost的时间消耗够小,num_workers的取值尽量小。
共享内存不足了,只要reader_cost的时间消耗够小,num_workers的取值尽量小。
但是另一个错误直接起线程就挂了是怎么回事呀
就是因为这个原因,aistudio资源给的有限,numworker过大容易出错,程序出错后环境重启一下
就是因为这个原因,aistudio资源给的有限,numworker过大容易出错,程序出错后环境重启一下
好的,了解了。非常感谢