AWS Sagemaker 推理端点未利用所有 vCPU

Bha*_*rla 3 python machine-learning amazon-web-services amazon-sagemaker

我在 sagemaker 推理端点(单实例)上部署了一个自定义模型,在进行负载测试时,我观察到 CPU 利用率指标达到了 100% 的最大值,但根据这篇文章,它应该达到 #vCPU*100% 的最大值。我已确认推理端点未使用 clowdwatch 日志中的所有核心。

因此,如果一个预测调用需要一秒钟处理才能给出响应,则部署的模型每秒只能处理一个 API 调用,如果使用所有 vCPU,则可能会增加到每秒 8 个调用。

AWS Sagemaker部署中是否有任何设置可以使用所有vCPU来提高并发性?

或者我们可以inference.py在部署时在文件内使用多处理 python 包,以便每次调用都到达默认核心,然后所有计算/预测都在任何其他核心中完成,无论该核心在该实例中是空的吗?

ero*_*3pi 7

更新


至于问题,Are there any settings in AWS Sagemaker deployment to use all vCPUs to increase concurrency? 您可以使用各种设置对于模型,您可以在环境变量的default_workers_per_modelconfig.properties中设置TS_DEFAULT_WORKERS_PER_MODEL=$(nproc --all)。环境变量具有最高优先级。

除此之外,对于每个模型,您可以使用管理 API 设置工作人员数量,但遗憾的是无法在 sagemaker 中卷曲到管理 API。所以 TS_DEFAULT_WORKERS_PER_MODEL 是最好的选择。设置此项应确保使用所有核心。

但是如果您使用的是 docker 文件,那么在入口点中您可以设置等待模型加载的脚本并对其进行卷曲以设置工作人员数量

# load the model
curl -X POST localhost:8081/models?url=model_1.mar&batch_size=8&max_batch_delay=50
# after loading the model it is possible to set min_worker, etc
curl -v -X PUT http://localhost:8081/models/model_1?min_worker=1
Run Code Online (Sandbox Code Playgroud)

关于日志确认并非所有核心都被使用的另一个问题,我面临同样的问题,并认为这是日志系统中的问题。请查看这个问题https://github.com/pytorch/serve/issues/782。社区本身同意,如果未设置线程,则默认情况下它会打印 0,即使默认情况下它使用 2*num_cores。

对于所有可能的配置的详尽集合

# Reference: https://github.com/pytorch/serve/blob/master/docs/configuration.md
# Variables that can be configured through config.properties and Environment Variables
# NOTE: Variables which can be configured through environment variables **SHOULD** have a
# "TS_" prefix
# debug
inference_address=http://0.0.0.0:8080
management_address=http://0.0.0.0:8081
metrics_address=http://0.0.0.0:8082
model_store=/opt/ml/model
load_models=model_1.mar
# blacklist_env_vars
# default_workers_per_model
# default_response_timeout
# unregister_model_timeout
# number_of_netty_threads
# netty_client_threads
# job_queue_size
# number_of_gpu
# async_logging
# cors_allowed_origin
# cors_allowed_methods
# cors_allowed_headers
# decode_input_request
# keystore
# keystore_pass
# keystore_type
# certificate_file
# private_key_file
# max_request_size
# max_response_size
# default_service_handler
# service_envelope
# model_server_home
# snapshot_store
# prefer_direct_buffer
# allowed_urls
# install_py_dep_per_model
# metrics_format
# enable_metrics_api
# initial_worker_port

# Configuration which are not documented or enabled through environment variables

# When below variable is set true, then the variables set in environment have higher precedence.
# For example, the value of an environment variable overrides both command line arguments and a property in the configuration file. The value of a command line argument overrides a value in the configuration file.
# When set to false, environment variables are not used at all
# use_native_io=
# io_ratio=
# metric_time_interval=
enable_envvars_config=true
# model_snapshot=
# version=
Run Code Online (Sandbox Code Playgroud)