From 6463f35444dfe05a143dae6dd85a3e05fe53f7b9 Mon Sep 17 00:00:00 2001 From: Andrey Arapov <107317698+andy108369@users.noreply.github.com> Date: Wed, 28 Feb 2024 00:01:57 +0100 Subject: [PATCH] feat(bid-script/gpu): support model.vram for pricing calculation and AMD support in addition to NVIDIA models (#249) * feat(bid-script/gpu): support model.vram for pricing calculation fixes akash-network/support#148 * feat(bid-script/gpu): support AMD in addition to NVIDIA models --- .../akash-provider/scripts/price_script_generic.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/charts/akash-provider/scripts/price_script_generic.sh b/charts/akash-provider/scripts/price_script_generic.sh index 7c8fb696..cb43de55 100755 --- a/charts/akash-provider/scripts/price_script_generic.sh +++ b/charts/akash-provider/scripts/price_script_generic.sh @@ -2,7 +2,7 @@ # WARNING: the runtime of this script should NOT exceed 5 seconds! (Perhaps can be amended via AKASH_BID_PRICE_SCRIPT_PROCESS_TIMEOUT env variable) # Requirements: # curl jq bc mawk ca-certificates -# Version: November-16-2023 +# Version: February-27-2024 set -o pipefail # Example: @@ -160,9 +160,18 @@ fi gpu_price_total=0 while IFS= read -r resource; do count=$(echo "$resource" | jq -r '.count') - model=$(echo "$resource" | jq -r '.gpu.attributes.vendor.nvidia.model // 0') + model=$(echo "$resource" | jq -r '.gpu.attributes.vendor | (.nvidia // .amd // empty).model // 0') + vram=$(echo "$resource" | jq -r --arg v_model "$model" '.gpu.attributes.vendor | ( + .nvidia | select(.model == $v_model) // + .amd | select(.model == $v_model) // + empty + ).ram // 0') gpu_units=$(echo "$resource" | jq -r '.gpu.units // 0') # default to 100 USD/GPU per unit a month when PRICE_TARGET_GPU_MAPPINGS is not set + # price_target_gpu_mappings can specify or . E.g. a100.40Gi=900,a100.80Gi=1000 or a100=950 + if [[ "$vram" != "0" ]]; then + model="${model}.${vram}" + fi price="${gpu_mappings[''$model'']:-$gpu_unit_max_price}" ((gpu_price_total += count * gpu_units * price))