docker 跑算法性能问题

tech2025-04-13  3

问题描述

paas平台基于k8s,在平台上跑算法,发现有性能问题,本地8核电脑跑1分钟的程序,在平台上跑需要2个小时。

环境

docker 19.03.1

问题重现

服务器48个逻辑cpu 同样的代码,数据集大概3w条。模型采用xgboost,开启48线程运行。

cpu亲和: docker run -it -d -v /home/user/lee/xingneng/:/app --cpuset-cpus=“1,2,3,4,5,6,7,8” 10.1.8.19:80/paas_nai/python_slim:1.1 /bin/bash

cfs: docker run -it -d -v /home/user/lee/xingneng/:/app --cpu-shares=8192 --cpu-period=100000 --cpu-quota=800000 10.1.8.19:80/paas_nai/python_slim:1.1 /bin/bash

执行: docker exec -it xxx /bin/bash -c “python /app/bin/main.py train -p /app/ -t 48” 同样的代码,开启48线程 cpu亲和运行7秒 cfs运行16分钟

解决

通过配置cpu亲和 cpuset-cpus=“X,X,X” 来替换CFS调度–cpu-shares=XXX --cpu-period=XX --cpu-quota=XXX

参考: https://zhuanlan.zhihu.com/p/83526484 https://my.oschina.net/xiaominmin/blog/3234450

最新回复(0)