forked from heavyai/heavyai-devstack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckEnv.sh
executable file
·86 lines (70 loc) · 1.93 KB
/
checkEnv.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
os_packages=(
"docker.io"
"docker-compose"
"jq"
"xmlstarlet"
)
missing_packages=()
installPackage(){
PACKAGE_NAME=$1
echo "Would you like to install $PACKAGE_NAME [y/n]"
read answer
case $answer in
[Yy]* ) echo "Installing $package";
if [ $UPDATE_DONE -eq 0 ]; then
echo "Updating APT repository"
sudo apt-get update
UPDATE_DONE=1
fi
sudo apt-get install $PACKAGE_NAME
;;
[Nn]* ) echo "Skipping $package";;
* ) echo "Invalid choice.";;
esac
}
packageStatus(){
PACKAGE_NAME=$1
if dpkg -l | grep -q "^ii\s\+$PACKAGE_NAME\s"; then
return 1
else
return 0
fi
}
displayStatus(){
for package in "${os_packages[@]}"; do
packageStatus $package
if [ $? -eq 0 ]; then
status="\033[0;31mMissing\033[0m"
missing_packages+=("$package")
else
status="\033[0;32mLoaded\033[0m"
fi
echo -e $package ": [" $status "]"
done
}
getGPUInfo(){
# Fetch GPU information in XML format
xml_output=$(nvidia-smi -q -x| sed '/<!DOCTYPE/d')
echo "here"
# Parse XML to get GPU name, driver version, and temperature
gpu_name=$(echo "$xml_output" | xmlstarlet sel -t -v "//gpu/product_name")
driver_version=$(echo "$xml_output" | xmlstarlet sel -t -v "//driver_version")
cuda_version=$(echo "$xml_output" | xmlstarlet sel -t -v "//cuda_version")
number_gpu=$(echo "$xml_output" | xmlstarlet sel -t -v "//attached_gpus")
gpu_memory=$(echo "$xml_output" | xmlstarlet sel -t -v "//fb_memory_usage/total")
# Print the extracted values
echo "GPU Name: $gpu_name"
echo "number of GPU: $number_gpu"
echo "Driver Version: $driver_version"
echo "Cuda Version: $cuda_version"
echo "GPU memory: $gpu_memory"
}
UPDATE_DONE=0
clear
displayStatus
for package in "${missing_packages[@]}"; do
installPackage $package
done
displayStatus
getGPUInfo