-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·90 lines (79 loc) · 2.59 KB
/
install.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
#!/usr/bin/env bash
# install dependencies
install_dependencies() {
echo "Installing dependencies ..."
echo ""
echo "Installing docker ..."
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
echo ""
echo ""
echo "Installing nvidia container toolkit ..."
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg \
&& curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list | \
sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' | \
sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
sudo apt update
sudo apt install -y nvidia-container-toolkit
sudo nvidia-ctk runtime configure --runtime=docker
#
sudo usermod -aG docker $USER
echo ""
echo ""
echo "Installing net-tools and xclip... "
sudo apt install -y net-tools xclip
}
close_current_session() {
echo ""
echo ""
echo "Enter password again to add docker to the usergroup."
su - ${USER}
}
# copy scripts to ~/.cuda-env
copy_scripts() {
echo "Copying scripts to '~/.cuda-env' ..."
mkdir -p ~/.cuda-env
cp -r . ~/.cuda-env/
}
# make scripts executable
make_executable() {
echo "Making scripts executable..."
chmod +x ~/.cuda-env/bin/*.sh
}
# execute cuda-env-image-build.sh
execute_image_build() {
echo "Building cuda-env-image..."
~/.cuda-env/bin/build.sh
}
# update .zshrc
update_bashrc() {
echo "Updating .zshrc..."
echo "" >> ~/.zshrc
echo "# >>> cuda-env scripts >>>" >> ~/.zshrc
echo 'alias cuda-env="~/.cuda-env/main.sh"' >> ~/.zshrc
echo "# <<< cuda-env scripts <<<" >> ~/.zshrc
}
# source .zshrc
source_bashrc() {
echo "Sourcing .zshrc..."
source ~/.zshrc
}
main() {
#install_dependencies
copy_scripts
make_executable
execute_image_build
update_bashrc
source_bashrc
close_current_session
}
main