diff --git a/deployment_kit/models.py b/deployment_kit/models.py index d45fa52..8b51664 100644 --- a/deployment_kit/models.py +++ b/deployment_kit/models.py @@ -61,6 +61,9 @@ def _helper_args(image, name, mounts, gpu=None): args=['run','--name',name,'--pull','never','--network','none','--init','--cpus','4', '--memory','12g','--pids-limit','128','--cap-drop','ALL', '--security-opt','no-new-privileges','--label','contextra.deployment.helper=true','--label','contextra.deployment.owner='+name] + # Leave bounded PID capacity for Triton/gRPC; contract checks need no BLAS pool. + for key in ('OPENBLAS_NUM_THREADS','OMP_NUM_THREADS','MKL_NUM_THREADS'): + args+=['--env',key+'=1'] if gpu is not None: args+=['--gpus','device='+str(gpu)] for src,dest,readonly in mounts: require(',' not in str(src),'MOUNT_PATH','모델 도구 경로에 쉼표를 사용하지 마세요.') diff --git a/tests/deployment/test_models.py b/tests/deployment/test_models.py index 6676793..edb65b3 100644 --- a/tests/deployment/test_models.py +++ b/tests/deployment/test_models.py @@ -107,3 +107,14 @@ class ModelTests(unittest.TestCase): a=models._helper_args(IID,'fixture',[],0) self.assertEqual(a[a.index('--network')+1],'none');self.assertEqual(a[a.index('--pull')+1],'never') self.assertIn('--memory',a);self.assertNotIn('--privileged',a) + def test_helper_blas_does_not_exhaust_triton_pid_budget(self): + for gpu in (None,0): + with self.subTest(gpu=gpu): + a=models._helper_args(IID,'fixture',[],gpu) + env={a[i+1] for i,value in enumerate(a) if value=='--env'} + self.assertEqual(env,{'OPENBLAS_NUM_THREADS=1','OMP_NUM_THREADS=1','MKL_NUM_THREADS=1'}) + self.assertEqual(a[a.index('--pids-limit')+1],'128') + self.assertEqual(a[a.index('--cpus')+1],'4') + self.assertEqual(a[a.index('--memory')+1],'12g') + self.assertEqual(a[a.index('--cap-drop')+1],'ALL') + self.assertEqual(a[-3:],['--entrypoint','python3',IID])