-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrocmuninstall.sh
executable file
·105 lines (100 loc) · 4.67 KB
/
rocmuninstall.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh
#
# Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved.
#
# Author: Srinivasan Subramanian ([email protected])
#
# Script to uninstall ROCm X.Y.Z version packages, excluding kernel modules
#
# Usage: sudo ./rocmuninstall.sh X.Y.Z
# where X.Y.Z is the version of ROCm to be UNINSTALLED
# Example: To uninstall ROCm 4.1.0 packages (excluding kernel modules)
# sudo ./rocmuninstall.sh 4.1.0
#
# NOTE: To uninstall rock-dkms, rock-dkms-firmware ROCm kernel modules
# manually uninstall them and reboot the system
# V1.8: add new packages (6.2.2)
# V1.7: add new packages
# V1.6: fix SLES uninstall amdgpu
# V1.5: Add amdgpu-core
# V1.4: ROCm 4.5 support: Add amdgpu-dkms
# V1.3: Fix miopenkernel uninstall
# V1.2: Fix miopenkernel name match
# V1.1: Fix CentOS uninstall
# V1.0: Initial version
#
echo "=== ROCm Uninstall Utility V1.8 ==="
/bin/date
if [ $# -ne 1 ]
then
echo "Usage: sudo $0 <X.Y.Z>|all, where <X.Y.Z> is the ROCm version to uninstall"
echo " To uninstall all ROCm packages (except kernel) use 'all' option"
echo " Example: To uninstall ROCm 4.1 packages use:"
echo " sudo sh ./rocmuninstall.sh 4.1.0 "
echo " Example: To uninstall all ROCm packages use:"
echo " sudo sh ./rocmuninstall.sh all "
echo " User will be prompted with list of selected packages to confirm uninstallation."
exit 1
fi
# Detect OS type
ret=`/bin/grep -i -E 'debian|ubuntu' /etc/os-release`
if [ $? -ne 0 ]
then
ret=`/bin/grep -i -E 'centos|rhel' /etc/os-release`
if [ $? -ne 0 ]
then
pkgtype="sles"
else
pkgtype="rpm"
fi
else
pkgtype="deb"
fi
export REV=$1
if [ ${REV} = "all" ]
then
echo "Remove ALL ROCm packages"
if [ "$pkgtype" = "deb" ]
then
pkglist=`/usr/bin/dpkg -l | /bin/grep -i -E 'ocl-icd|kfdtest|llvm-amd|miopen|half|^ii hip|hcc|hsa|rocm|atmi|^ii comgr|composa|amd-smi|aomp|amdgpu-core|amdgpu-dkms|rock|mivision|migraph|rocprofiler|roctracer|rocbl|hipify|rocsol|rocthr|rocff|rocal-|rocalu|rocprim|rocrand|rccl|rocspar|rocwmma|rpp|rdc|openmp-|omniperf|omnitrace' | /usr/bin/awk '!/Status/ {print $2}' | /usr/bin/sort`
else
pkglist=`/usr/bin/rpm -qa | /bin/grep -i -E 'ocl-icd|kfdtest|llvm-amd|miopen|half|hip|hcc|hsa|rocm|atmi|comgr|composa|amd-smi|aomp|amdgpu-core|amdgpu-dkms|rock|mivision|migraph|rocprofiler|roctracer|rocbl|hipify|rocsol|rocthr|rocff|rocal-|rocalu|rocprim|rocrand|rccl|rocspar|rocwmma|rpp|rdc|openmp-|omniperf|omnitrace' | /usr/bin/sort`
fi
else
echo "Remove ROCm packages for release $REV"
if [ "$pkgtype" = "deb" ]
then
pkglist=`/usr/bin/dpkg -l | /bin/grep -i -E 'ocl-icd|kfdtest|llvm-amd|miopen|half|^ii hip|hcc|hsa|rocm|atmi|^ii comgr|composa|amd-smi|aomp|amdgpu-core|amdgpu-dkms|rock|mivision|migraph|rocprofiler|roctracer|rocbl|hipify|rocsol|rocthr|rocff|rocal-|rocalu|rocprim|rocrand|rccl|rocspar|rocwmma|rpp|rdc|openmp-|omniperf|omnitrace' | /usr/bin/awk '!/Status/ {print $2}' | /bin/grep -E '^[a-zA-Z\-]+[a-zA-Z]'${REV}'|^[a-zA-Z\-]+lib64'${REV} | /usr/bin/sort`
miopenkernelpkglist=`/usr/bin/dpkg -l | /bin/grep -i -E 'miopenkernel' | /bin/grep -E 'miopenkernels-gfx.+'${REV}'|miopenkernels-gfx.+db'${REV} | /usr/bin/awk '!/Status/ {print $2}' | /usr/bin/sort`
else
pkglist=`/usr/bin/rpm -qa | /bin/grep -i -E 'ocl-icd|kfdtest|llvm-amd|miopen|half|hip|hcc|hsa|rocm|atmi|comgr|composa|amd-smi|aomp|amdgpu-core|amdgpu-dkms|rock|mivision|migraph|rocprofiler|roctracer|rocbl|hipify|rocsol|rocthr|rocff|rocal-|rocalu|rocprim|rocrand|rccl|rocspar|rocwmma|rpp|rdc|openmp-|omniperf|omnitrace' | /bin/grep -E '^[a-zA-Z\-]+[a-zA-Z]'${REV}'|^[a-zA-Z\-]+lib64'${REV} | /usr/bin/sort`
miopenkernelpkglist=`/usr/bin/rpm -qa | /bin/grep -i -E 'miopenkernel' | /bin/grep -E '^miopenkernels-gfx.+'${REV}'|^miopenkernels-gfx.+db'${REV} | /usr/bin/sort`
fi
fi
# List the ROCm packages that will be uninstalled
echo "List of packages selected for uninstall: "
echo $pkglist
echo $miopenkernelpkglist
# Prompt user
while true; do
read -p "Do you want to continue to uninstall above packages [Y/n]?" ans
case $ans in
[Yy]* ) echo "Uninstalling...";
if [ "$pkgtype" = "deb" ]
then
/usr/bin/apt remove $pkglist $miopenkernelpkglist;
elif [ "$pkgtype" = "rpm" ]
then
/usr/bin/yum remove $pkglist $miopenkernelpkglist;
else
/usr/bin/zypper remove $pkglist $miopenkernelpkglist;
if [ ${REV} = "all" ]
then
/usr/bin/zypper remove amdgpu-core amdgpu-dkms-firmware amdgpu-dkms;
fi
fi
break;;
[Nn]* ) echo "Aborting."; break;;
* ) echo "Please answer yes or no to continue.";;
esac
done