Skip to content

Instantly share code, notes, and snippets.

@av1d
Last active May 30, 2024 14:15
Show Gist options
  • Save av1d/be621206df7668c32890216419ed2106 to your computer and use it in GitHub Desktop.
Save av1d/be621206df7668c32890216419ed2106 to your computer and use it in GitHub Desktop.
get rk3588 environment
#!/bin/bash
# To help make it easier while troubleshooting issues for RK3588 LLM setups.
# Outputs to randomly-dated text file (ex: environment_2024-05-11_1715443021.txt)
# run: bash environment.sh
# find platform, assumes Debian/Ubuntu
platform=$(lsb_release -a)
# get python version
python_version=$(python3 --version)
# get kernel version
kernel_version=$(uname -r)
# get memory
ram=$(( $(getconf _PHYS_PAGES) * $(getconf PAGE_SIZE) ))
total_ram=$((ram/1024/1024))
# get current drive usage
disk_usage=$(df -h "$PWD" | awk 'NR==2{print $2 " total, " $3 " used, " $4 " available, " $5 " used%"}')
# check ring buffer for NPU messages
npu=$(dmesg | grep npu)
# check RKLLM shared library version
# download v 1.0.0:
curl -s https://raw.githubusercontent.com/Pelochus/ezrknn-llm/d974bc8cbe7b6a0306b8194993cc44be28cc3ad5/rkllm-runtime/runtime/Linux/librkllm_api/include/rkllm.h -o rkllm_100.h
# download v 1.0.1:
curl -s https://raw.githubusercontent.com/Pelochus/ezrknn-llm/main/rkllm-runtime/runtime/Linux/librkllm_api/include/rkllm.h -o rkllm_101.h
# compare to local
rkllm100=$(cmp rkllm_100.h /usr/local/include/rkllm.h)
rkllm101=$(cmp rkllm_101.h /usr/local/include/rkllm.h)
if [ -z "$rkllm100" ]; then
RKLLM_version="RKLLM 1.0.0"
else
RKLLM_version="RKLLM 1.0.1"
fi
# misc
date_string=$(date --iso-8601)
datetime_string=$(date)
epoch_time=$(date +%s)
output_file="environment_${date_string}_${epoch_time}.txt"
separator="================================"
echo "${datetime_string}" > "$output_file" # note single '>' to overwrite file
echo "${separator}" >> "$output_file"
echo "RAM: ${total_ram}" >> "$output_file"
echo "${separator}" >> "$output_file"
echo "Disk usage: ${disk_usage}" >> "$output_file"
echo "${separator}" >> "$output_file"
echo "${platform}" >> "$output_file"
echo "${separator}" >> "$output_file"
echo "Kernel version: ${kernel_version}" >> "$output_file"
echo "${separator}" >> "$output_file"
echo "RKLLM.h version: ${RKLLM_version}" >> "$output_file"
echo "${separator}" >> "$output_file"
echo "Python version: ${python_version}" >> "$output_file"
echo "${separator}" >> "$output_file"
echo "dmesg output:" >> "$output_file"
echo "${npu}" >> "$output_file"
echo "Output saved to: ${output_file}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment