diff --git a/charts/akash-provider/Chart.yaml b/charts/akash-provider/Chart.yaml index a0c005d4..cfb18cdb 100644 --- a/charts/akash-provider/Chart.yaml +++ b/charts/akash-provider/Chart.yaml @@ -17,7 +17,7 @@ type: application # Versions are expected to follow Semantic Versioning (https://semver.org/) # Major version bit highlights the mainnet release (e.g. mainnet4 = 4.x.x, mainnet5 = 5.x.x, ...) -version: 6.0.6 +version: 6.0.7 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/akash-provider/scripts/price_script_generic.sh b/charts/akash-provider/scripts/price_script_generic.sh index 327f51ca..ec0cd185 100755 --- a/charts/akash-provider/scripts/price_script_generic.sh +++ b/charts/akash-provider/scripts/price_script_generic.sh @@ -73,8 +73,7 @@ function get_akt_price { # bid script starts reading the deployment order request specs here (passed by the Akash Provider) data_in=$(jq .) -## DEBUG -if ! [[ -z $DEBUG_BID_SCRIPT ]]; then +if ! [[ -z $DEBUG_BID_SCRIPT ]] && ! [[ -z $AKASH_OWNER ]]; then echo "====================== start ======================" >> /tmp/${AKASH_OWNER}.log echo "$(TZ=UTC date -R)" >> /tmp/${AKASH_OWNER}.log echo "$data_in" >> /tmp/${AKASH_OWNER}.log @@ -135,10 +134,9 @@ TARGET_IP="${PRICE_TARGET_IP:-5}" # USD for leased IP/mon ## # Populate the price target gpu_mappings dynamically based on the "price_target_gpu_mappings" value passed by the helm-chart -# Default: "a100=120,t4=80,*=130" declare -A gpu_mappings=() -IFS=',' read -ra PAIRS <<< "${PRICE_TARGET_GPU_MAPPINGS:-a100=120,t4=80,*=130}" +IFS=',' read -ra PAIRS <<< "${PRICE_TARGET_GPU_MAPPINGS}" for pair in "${PAIRS[@]}"; do IFS='=' read -ra KV <<< "$pair" key="${KV[0]}" @@ -146,21 +144,33 @@ for pair in "${PAIRS[@]}"; do gpu_mappings["$key"]=$value done -gpu_price_total=0 +# Default to 100 USD/GPU per unit a month when PRICE_TARGET_GPU_MAPPINGS is not set +# Or use the highest price from PRICE_TARGET_GPU_MAPPINGS when model detection fails (ref. https://github.com/akash-network/support/issues/139 ) +gpu_unit_max_price=100 +for value in "${gpu_mappings[@]}"; do + if (( value > gpu_unit_max_price )); then + gpu_unit_max_price=$value + fi +done + +if ! [[ -z $DEBUG_BID_SCRIPT ]]; then + echo "DEBUG: gpu_unit_max_price $gpu_unit_max_price" +fi +gpu_price_total=0 while IFS= read -r resource; do model=$(echo "$resource" | jq -r '.gpu.attributes.vendor.nvidia.model // 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="${gpu_mappings[''$model'']:-100}" + price="${gpu_mappings[''$model'']:-$gpu_unit_max_price}" ((gpu_price_total += gpu_units * price)) - ## DEBUG - #echo "model $model" - #echo "price for this model $price" - #echo "gpu_units $gpu_units" - #echo "gpu_price_total $gpu_price_total" - #echo "" + if ! [[ -z $DEBUG_BID_SCRIPT ]]; then + echo "DEBUG: model $model" + echo "DEBUG: price for this model $price" + echo "DEBUG: gpu_units $gpu_units" + echo "DEBUG: gpu_price_total $gpu_price_total" + fi done <<< "$(echo "$data_in" | jq -rc '.[]')" # Calculate the total resource cost for the deployment request in USD @@ -177,6 +187,10 @@ total_cost_usd_target=$(bc -l <<< "( \ ($gpu_price_total) \ )") +if ! [[ -z $DEBUG_BID_SCRIPT ]]; then + echo "DEBUG: Total cost USD/month: $total_cost_usd_target" +fi + # average block time: 6.117 seconds (based on the time diff between 8090658-8522658 heights [with 432000 blocks as a shift in between if considering block time is 6.0s "(60/6)*60*24*30"]) # average number of days in a month: 30.437 # (60/6.117)*24*60*30.437 = 429909 blocks per month