set num_workers=0 to prevent create subprocess which may cause error in demo-service

Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/11802831
This commit is contained in:
yuxiang.tyx
2023-02-28 14:12:50 +08:00
committed by wenmeng.zwm
parent 7181e667f6
commit 3e5dbd2997

View File

@@ -55,6 +55,10 @@ class ObjectDetection3DPipeline(Pipeline):
else:
self.device = torch.device('cpu')
self.detector = DepeDetect(model).to(self.device)
if os.getenv('MODELSCOPE_ENVIRONMENT') == 'eas':
self.num_workers = 0
else:
self.num_workers = 4
def __call__(self, input, **kwargs):
"""
@@ -110,7 +114,7 @@ class ObjectDetection3DPipeline(Pipeline):
data_loader = build_dataloader(
self.dataset,
samples_per_gpu=1,
workers_per_gpu=4,
workers_per_gpu=self.num_workers,
dist=False,
shuffle=False)
result = next(iter(data_loader))