Skip to content

Commit

Permalink
Restrict GPU access from worker to deviceIds
Browse files Browse the repository at this point in the history
  • Loading branch information
namannandan committed Jul 2, 2024
1 parent e979f41 commit 2282882
Showing 1 changed file with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,13 @@ private void startWorkerPython(int port, String deviceIds)
modelPath.getAbsolutePath(),
model.getModelArchive().getManifest().getModel().getHandler())));

if (model.getParallelLevel() > 0) {
if (model.getParallelType() != ParallelType.CUSTOM) {
attachRunner(argl, envp, port, deviceIds);
} else {
if (deviceIds != null) {
envp.add("CUDA_VISIBLE_DEVICES=" + deviceIds);
}
argl.add(EnvironmentUtils.getPythonRunTime(model));
}
} else if (model.getParallelLevel() == 0) {
if (deviceIds != null) {
envp.add("CUDA_VISIBLE_DEVICES=" + deviceIds);
}

if (model.getParallelLevel() > 0 && model.getParallelType() != ParallelType.CUSTOM) {
attachRunner(argl, envp, port, deviceIds);
} else {
argl.add(EnvironmentUtils.getPythonRunTime(model));
}

Expand Down Expand Up @@ -291,9 +288,6 @@ private void startWorkerCPP(int port, String runtimeType, String deviceIds)
private void attachRunner(
ArrayList<String> argl, List<String> envp, int port, String deviceIds) {
envp.add("LOGLEVEL=INFO");
if (deviceIds != null) {
envp.add("CUDA_VISIBLE_DEVICES=" + deviceIds);
}
ModelConfig.TorchRun torchRun = model.getModelArchive().getModelConfig().getTorchRun();
envp.add(String.format("OMP_NUM_THREADS=%d", torchRun.getOmpNumberThreads()));
argl.add("torchrun");
Expand Down

0 comments on commit 2282882

Please sign in to comment.