-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Triton ONNX runtime backend slower than onnxruntime python client on CPU #265
Comments
@fpetrini15 ?? it's a black box |
@Mitix-EPI Can you add get_inference_statistics function call after infer and share the numbers? It would help us in identifying the bottleneck. Additionally, what happens when you run the infer command multiple times? Does the latency remain the same or it reduces with repetition? This would help us identifying if this is a warmup issue. |
Hi @Mitix-EPI, I set up a simple test suite on my local machine with minor modifications (mostly altering the code to work outside of Jupytr) and could not replicate your results. While the result you report in your # 10 requests
Single execution time: 27.143945917487144 ms
Single execution time: 16.90200436860323 ms
Single execution time: 16.530546359717846 ms
Single execution time: 16.570006497204304 ms
Single execution time: 16.596742905676365 ms
Single execution time: 16.560756601393223 ms
Single execution time: 16.599184833467007 ms
Single execution time: 16.567444428801537 ms
Single execution time: 16.583171673119068 ms
Single execution time: 16.47179201245308 ms
AVG Execution time: 17.686644196510315 ms per inference
TOTAL Execution time: 176.86644196510315 seconds ms inference However, if the model is deployed to the GPU (server log should contain something like # 1000 requests
Single execution time: 968.3446865528822 ms per inference
Single execution time: 30.06432857364416 ms per inference
Single execution time: 11.44306268543005 ms per inference
...
AVG Execution time: 10.60993140405044 ms per inference
TOTAL Execution time: 106099.3140405044 seconds ms inference You can make explicitly sure that your model is being deployed to the CPU by adding the following to your config: instance_group [
{
count: 1
kind: KIND_CPU
}
] |
Thank you so much for your interest on this issue ! Over 100 iterations, I observed no fluctual time inference between requests. The only two first requests are anomalies. Each time inference is, more or less, around 75-95ms. Here's more informations: shell run docker run --rm -p8000:8000 -p8001:8001 -p8002:8002 -v ./triton-test-inference:/models nvcr.io/nvidia/tritonserver:24.09-py3 tritonserver --model-repository=/models test_triton_inference.py import numpy as np
import time
import tritonclient.grpc as grpcclient
import tritonclient.grpc._infer_input as infer_input
grpcclient = grpcclient.InferenceServerClient(url='localhost:8001')
i = infer_input.InferInput('data_0', [1, 3, 224, 224], 'FP32')
i.set_data_from_numpy(np.zeros((1, 3, 224, 224), dtype=np.float32))
times = np.array([])
for _ in range(100):
start = time.time()
res = grpcclient.infer(model_name="test_densenet", inputs=[i])
end = time.time()
time_spend = (end-start) * 1000
times = np.append(times, time_spend)
print(f"Time: {time_spend:.2f} ms")
print(f"Mean: {np.mean(times):.2f} ms")
print(f"Median: {np.median(times):.2f} ms")
print(f"Std: {np.std(times):.2f} ms")
print("Inference statistics:")
print(grpcclient.get_inference_statistics(model_name="test_densenet")) results
test_onnxruntime_inference.py import numpy as np
import time
import onnxruntime as ort
ort_sess = ort.InferenceSession('triton-test-inference/test_densenet/1/model.onnx')
test_inputs = {"data_0": np.zeros((1, 3, 224, 224), dtype=np.float32)}
times = np.array([])
for _ in range(100):
start = time.time()
ort_sess.run(["fc6_1"], test_inputs)
end = time.time()
time_spend = (end-start) * 1000
times = np.append(times, time_spend)
print(f"Time: {time_spend:.2f} ms")
print(f"Mean: {np.mean(times):.2f} ms")
print(f"Median: {np.median(times):.2f} ms")
print(f"Std: {np.std(times):.2f} ms") results
|
Thanks ++ for your interest on my issue ! Nothing about GPU, the device I use does not have GPU.
I just tested on another computer with another cpu and it
I don't actually know how to deal with it ... I don't have any kind of slow inference with TF SavedModels or OpenVINO triton backends. It's only with ONNXRuntime. |
@Mitix-EPI You can try Model Warmup feature to issue two requests to the model during the load time. |
I just tried to add model warmup but it does not affect the time inference. config.pbtxt
results of test_triton_inference.py
|
Description
When deploying an ONNX model using the Triton Inference Server's ONNX runtime backend, the inference performance on the CPU is noticeably slower compared to running the same model using the ONNXRuntime Python client directly. This performance discrepancy is observed under identical conditions, including the same hardware, model, and input data.
Triton Information
TRITON_VERSION <= 24.09
To Reproduce
model used:
Triton server (ONNX runtime)
config.pbtxt
Python clients
Triton client
results:
473 ms ± 87.9 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
ONNX Runtime
results:
159 ms ± 23.9 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
The text was updated successfully, but these errors were encountered: