【debug】报错RuntimeError: can‘t start new thread解决

目录

报错信息:

解决方案:

整理不易,欢迎一键三连!!!


跑PyTorch 的深度学习的代码,之前跑没有问题,换了一台服务器,遇到这个bug报错:RuntimeError: can't start new thread,原因是测试的时候线程开得太多了,导致软件开始,不再能够被处理,卡死。

报错信息:


[ERROR:0] global /tmp/pip-req-build-cg56sov1/opencv/modules/core/src/parallel_impl.cpp (24
0) WorkerThread 158: Can't spawn new thread: res = 11
[ERROR:0] global /tmp/pip-req-build-cg56sov1/opencv/modules/core/src/parallel_impl.cpp (24
0) WorkerThread 120: Can't spawn new thread: res = 11
[ERROR:0] global /tmp/pip-req-build-cg56sov1/opencv/modules/core/src/parallel_impl.cpp (24
0) WorkerThread 152: Can't spawn new thread: res = 11
[ERROR:0] global /tmp/pip-req-build-cg56sov1/opencv/modules/core/src/parallel_impl.cpp (24
0) WorkerThread 159: Can't spawn new thread: res = 11
[ERROR:0] global /tmp/pip-req-build-cg56sov1/opencv/modules/core/src/parallel_impl.cpp (24
0) WorkerThread 160: Can't spawn new thread: res = 11


...


RuntimeError: can't start new thread

解决方案:

1.cpu线程数降低,可以尝试将num_work调小,即调小mmseg工程里的config文件中workers_per_gpu参数。

data = dict(
    samples_per_gpu=4,  #batch_size
    workers_per_gpu=1,  #num_work
    train=dict(...)
    )

2.数据增广albumentations库中所使用的基于opencv的各种数据变换占用了太多的cpu,因此需要调小opencv的线程数目在训练最开始的时候加入以下两行。

import cv2
cv2.setNumThreads(1)	# 0也可以

整理不易,欢迎一键三连!!!

送你们一条美丽的--分割线--


⛵⛵⭐⭐

你可能感兴趣的:(Debug,mmsegmentation,python,albumentation,进程,mmseg,debug,torch,pytorch)