【问题标题】:Yolo v5 use all nginx cores for single requestYolo v5 将所有 nginx 核心用于单个请求
【发布时间】:2021-08-07 09:39:04
【问题描述】:

我开发了一个使用 Yolo v5 的 API(基于 Flask)。我使用 Ngnix 和 Gunicorn 来提供这项服务。只需一个请求,一切都可以正常工作。不管我给10核CPU还是50核CPU,一次只回复一个请求。

权重全部在请求外加载,请求时只使用加载的权重

weights = "./x.pt"
imgsz = 640
device = ""
set_logging()
device = select_device(device)
# Load model
model = attempt_load(weights, map_location=device)  # load FP32 model
stride = int(model.stride.max())  # model stride
imgsz = check_img_size(imgsz, s=stride)  # check img_size
# Second-stage classifier
classify = False
if classify:
    modelc = load_classifier(name='resnet101', n=2)  # initialize
    modelc.load_state_dict(torch.load('resnet101.pt', map_location=device)['model']).to(device).eval()



@application.route("URL", methods=['POST'])
def XXX():
        ...
        ...
        ...

如果有任何建议,我将不胜感激。谢谢,也对不起我的英语。

【问题讨论】:

    标签: python nginx deep-learning gunicorn yolo


    【解决方案1】:

    问题解决了。我总是将工人的数量(在 Gunicorn 设置中)设置为等于 CPU 内核的数量。有问题。当我将Workers的数量设置为1时,问题就解决了。

    文件地址(centos):

     /etc/systemd/system/X.service
    

    改为:

    WorkingDirectory=X
    Environment="PATH=X"
    ExecStart=X/venv/bin/gunicorn --workers 1 --timeout 200 --bind unix:X.sock -m 007 run
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-05-27
      • 2011-10-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多