forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
amd_build_script_verbose.sh
138 lines (119 loc) · 5.28 KB
/
amd_build_script_verbose.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#Check for Ubuntu
if lsb_release -d | grep Ubuntu ; then
echo 'You are using Ubuntu'
echo '----------------------------------------------------------------------------------------------------------'
#Check correct Ubuntu version
if ! { lsb_release -d | grep 18.04 || lsb_release -d | grep 20.04 || lsb_release -d | grep 20.10; }; then
echo 'You are not using Ubuntu 18.04, 20.04, or 20.10. Please use maunal instructions and modify according to your version.'
exit
fi
#Start terminal on login
mkdir ~/.config/autostart
echo '
[Desktop Entry]
Type=Application
Exec=gnome-terminal
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_NG]=Terminal
Name=Terminal
Comment[en_NG]=Start Terminal On Startup
Comment=Start Terminal On Startup
' > ~/.config/autostart/gnome-terminal.desktop
#Enable auto login
sudo sed -i 's/.*AutomaticLogin.*/ /' /etc/gdm3/custom.conf && sudo sed -i "/\[daemon\]/a AutomaticLoginEnable=True\nAutomaticLogin=$USER" /etc/gdm3/custom.conf || { sed -i 's/bash ~\/Downloads\/pytorch-rocm-amd\/amd_build_script.sh//' ~/.bashrc; exit; }
else
echo ''
echo '----------------------------------------------------------------------------------------------------------'
echo 'It seems you are not using Ubuntu. This script was desiged and tested on Ubuntu 18.04 and 20.04. Please use manual Instructions and modify accordingly.'
exit
fi
sudo apt-get install git -y || exit
##Install ROCM
echo ''
echo '----------------------------------------------------------------------------------------------------------'
echo 'Installing basic packages'
sudo sed -i '/cdrom/d' /etc/apt/sources.list #For Ubuntu 20.10
sudo apt update || exit
sudo apt upgrade -y || exit
sudo apt dist-upgrade -y || exit
sudo apt install libnuma-dev -y || exit
##Groups
echo 'Creating and joining groups'
sudo usermod -a -G video $LOGNAME
echo 'ADD_EXTRA_GROUPS=1' | sudo tee -a /etc/adduser.conf
echo 'EXTRA_GROUPS=video' | sudo tee -a /etc/adduser.conf
if { lsb_release -d | grep 20.04; }; then
sudo usermod -a -G render $LOGNAME;
echo 'EXTRA_GROUPS=render' | sudo tee -a /etc/adduser.conf ;
fi
echo 'Adding apt source'
wget -q -O - https://repo.radeon.com/rocm/rocm.gpg.key | sudo apt-key add -
echo 'deb [arch=amd64] https://repo.radeon.com/rocm/apt/debian/ xenial main' | sudo tee /etc/apt/sources.list.d/rocm.list > /dev/null
sudo apt update
echo 'Installing ROCm'
sudo apt install rocm-dkms -y || exit
##Reboot
echo ''
echo 'Rebooting'
while true; do
read -p "Are you ready to reboot? y/n " yn
case $yn in
[Yy]* ) echo "tail -n +73 ~/Downloads/pytorch-rocm-amd/amd_build_script_verbose.sh | bash" >> ~/.bashrc && sudo reboot || { echo 'Unable to reboot. Another process must be preventing restart eg. update manager. Please exit process and restart script. '; sed -i '$d' ~/.bashrc; exit 1; };;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
##Cleanup
sed -i '$d' ~/.bashrc;
echo 'Finishing up'
export PATH=$PATH:/opt/rocm/bin:/opt/rocm/rocprofiler/bin:/opt/rocm/opencl/bin
echo 'PATH=$PATH:/opt/rocm/bin:/opt/rocm/rocprofiler/bin:/opt/rocm/opencl/bin' >> ~/.bashrc
echo ''
echo 'ROCM installed'
echo '----------------------------------------------------------------------------------------------------------'
##Pytorch
echo ''
echo 'Updating Pytorch (My fork)'
cd ~/Downloads/pytorch-rocm-amd || exit
sleep 10
git pull
echo ''
echo 'Git submodule (may take awhile)'
git submodule sync || exit
git submodule update --init --recursive
echo ''
echo 'Pytorch downloaded'
echo '----------------------------------------------------------------------------------------------------------'
##Hipify
python3 tools/amd_build/build_amd.py > /dev/null
echo ''
echo "Pytorch HIPified"
echo '----------------------------------------------------------------------------------------------------------'
#Additional Packages:
echo 'Installing Additional Packages (this may take awhile)'
sudo apt install -y gcc cmake clang ccache llvm ocl-icd-opencl-dev
sudo apt install -y python3-pip python3 python
sudo apt install -y rocrand rocblas miopen-hip miopengemm rocfft rocprim rocsparse rocm-cmake rocm-dev rocm-device-libs rocm-libs rccl hipcub rocthrust
pip3 install -r requirements.txt
##Wheel (Most errors will be here)
echo ''
echo '----------------------------------------------------------------------------------------------------------'
echo 'Creating .whl. Most errors will occur here. Will take long to compile'
sleep 10
RCCL_DIR=/opt/rocm/rccl/lib/cmake/rccl/ PYTORCH_ROCM_ARCH=gfx900 hip_DIR=/opt/rocm/hip/cmake/ USE_NVCC=OFF BUILD_CAFFE2_OPS=0 PATH=/usr/lib/ccache/:$PATH USE_CUDA=OFF python3 setup.py bdist_wheel || echo 'Build failed. ' && set -e
echo ''
echo 'Hardest part over'
echo '----------------------------------------------------------------------------------------------------------'
##Install
echo 'Installing Pytorch .whl'
echo ''
if sudo pip3 install dist/*.whl > /dev/null; then
echo ''
echo 'Pytorch installed'
echo '----------------------------------------------------------------------------------------------------------'
else
echo 'Install failed'
echo '----------------------------------------------------------------------------------------------------------'
fi