Created
October 3, 2024 21:01
-
-
Save rahuljantwal-8451/3b764cd1de798028bc32692460768938 to your computer and use it in GitHub Desktop.
Requests to triton server with ensemble model
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Define variables | |
TRITON_URL="localhost:8000" | |
MODEL_NAME="executor_model" | |
MODEL_VERSION="1" | |
# Create JSON payload | |
PAYLOAD=$(cat <<EOF | |
{ | |
"inputs": [ | |
{ | |
"name": "col1", | |
"shape": [1], | |
"datatype": "INT64", | |
"data": [132131] | |
}, | |
{ | |
"name": "col2", | |
"shape": [1], | |
"datatype": "INT64", | |
"data": [4] | |
} | |
] | |
} | |
EOF | |
) | |
# Send curl request | |
make_request() { | |
curl -X POST "http://${TRITON_URL}/v2/models/${MODEL_NAME}/versions/${MODEL_VERSION}/infer" \ | |
-H "Content-Type: application/json" \ | |
-d "$PAYLOAD" | |
} | |
# Function to measure execution time | |
measure_time() { | |
start_time=$(date +%s.%N) | |
"$@" | |
end_time=$(date +%s.%N) | |
duration=$(echo "$end_time - $start_time" | bc) | |
echo "Execution time: $duration seconds" | |
} | |
# Run multiple times: | |
total_time=0 | |
runs=50 | |
for i in $(seq 1 $runs); do | |
#echo "Run $i:" | |
start_time=$(date +%s%N) | |
make_request #> /dev/null # Suppress output | |
end_time=$(date +%s%N) | |
duration_ns=$((end_time - start_time)) | |
duration=$((duration_ns / 1000000)) | |
total_time=$((total_time + duration)) | |
#echo "Execution time: $duration ms" | |
echo "" | |
done | |
average_time=$((total_time / runs)) | |
echo "Average execution time over $runs runs: $average_time ms" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment