Skip to content

Commit

Permalink
Avoid load startup model on multiple GPUs
Browse files Browse the repository at this point in the history
  • Loading branch information
frankfliu committed Mar 11, 2022
1 parent 5c27dba commit f96ebd6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion serving/src/main/java/ai/djl/serving/ModelServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ String mapModelUrl(Path path) {
if (engine == null) {
return null;
}
return modelName + "::" + engine + ":*=" + url;
return modelName + "::" + engine + ':' + configManager.getLoadOnDevices() + '=' + url;
} catch (MalformedURLException e) {
throw new AssertionError("Invalid path: " + path, e);
} catch (IOException e) {
Expand Down
10 changes: 10 additions & 0 deletions serving/src/main/java/ai/djl/serving/util/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public final class ConfigManager {
private static final String MAX_REQUEST_SIZE = "max_request_size";
private static final String MODEL_STORE = "model_store";
private static final String MODEL_URL_PATTERN = "model_url_pattern";
private static final String LOAD_ON_DEVICES = "load_on_devices";
private static final String PLUGIN_FOLDER = "plugin_folder";

// Configuration which are not documented or enabled through environment variables
Expand Down Expand Up @@ -266,6 +267,15 @@ public String getLoadModels() {
return prop.getProperty(LOAD_MODELS);
}

/**
* Returns the devices the default model will be loaded on at startup.
*
* @return the devices the default model will be loaded on at startup
*/
public String getLoadOnDevices() {
return prop.getProperty(LOAD_ON_DEVICES, "*");
}

/**
* Returns the CORS allowed origin setting.
*
Expand Down

0 comments on commit f96ebd6

Please sign in to comment.