-
Notifications
You must be signed in to change notification settings - Fork 2
/
40_install_cudagl
178 lines (147 loc) · 4.9 KB
/
40_install_cudagl
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#!/usr/bin/env bash
set -eu
function install_cudagl_packages()
{
source /usr/local/share/just/user_run_patch/10_load_cuda_env
packages=()
install_base=0
install_runtime=0
install_devel=0
case "${CUDA_RECIPE_TARGET-runtime}" in
runtime)
install_base=1
install_runtime=1
;;
devel|devel-only)
install_base=1
install_runtime=1
install_devel=1
;;
esac
if command -v dnf 2>&1 > /dev/null; then
source /etc/os-release
rhel_major_version=${VERSION_ID%%.*}
if [ -f "/etc/yum.repos.d/ubi.repo" ]; then
# UBI images only have a subset of all packages we need; use rocky to fill in the gaps.
/usr/local/share/just/scripts/10_sideload_rocky; \
if [ "${rhel_major_version}" -ge 9 ]; then
packages+=(--enablerepo=rocky-appstream,rocky-crb)
else
packages+=(--enablerepo=rocky-appstream,rocky-powertools)
fi
fi
########
# Base #
########
if [ "${install_base}" = "1" ]; then
packages+=(libXau libXau.i686
libXdmcp libXdmcp.i686
libxcb libxcb.i686
libXext libXext.i686
libX11 libX11.i686)
fi
###########
# Runtime #
###########
if [ "${install_runtime}" = "1" ]; then
cp -ra "/usr/local/share/just/info/rhel${rhel_major_version}"/lib* /usr/local/
echo '/usr/local/lib64' >> /etc/ld.so.conf.d/glvnd.conf
echo '/usr/local/lib' >> /etc/ld.so.conf.d/glvnd.conf
fi
#########
# Devel #
#########
if [ "${install_devel}" = "1" ]; then
packages+=(pkgconfig
libXau-devel libXau-devel.i686
libXdmcp-devel libXdmcp-devel.i686
libxcb-devel libxcb-devel.i686
libXext-devel libXext-devel.i686
libX11-devel libX11-devel.i686)
fi
###########
# Install #
###########
if [ "${#packages[@]}" -ne "0" ]; then
dnf install --setopt=obsoletes=0 -y "${packages[@]}"
rm -rf /var/cache/yum/*
fi
# This has to happen after libX11.so.6 is installed, or else every command breaks
if [ "${install_runtime}" = "1" ]; then
echo '/usr/local/$LIB/libGL.so.1' >> /etc/ld.so.preload
echo '/usr/local/$LIB/libEGL.so.1' >> /etc/ld.so.preload
fi
elif command -v apt-get 2>&1 > /dev/null; then
########
# Base #
########
if [ "${install_base}" = "1" ]; then
packages+=(libxau6 libxau6:i386
libxdmcp6 libxdmcp6:i386
libxcb1 libxcb1:i386
libxext6 libxext6:i386
libx11-6 libx11-6:i386)
echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf
echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf
echo 'LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:/usr/lib/i386-linux-gnu${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}:/usr/local/nvidia/lib:/usr/local/nvidia/lib64' \
> /usr/local/share/just/info/cuda/90_librarypath_common
fi
###########
# Runtime # Valid for Ubuntu 18 and 20. 16 was different but it's old
###########
if [ "${install_runtime}" = "1" ]; then
packages+=(libglvnd0 libglvnd0:i386
libgl1 libgl1:i386
libglx0 libglx0:i386
libegl1 libegl1:i386
libgles2 libgles2:i386)
fi
#########
# Devel #
#########
if [ "${install_devel}" = "1" ]; then
packages+=(pkg-config
libglvnd-dev libglvnd-dev:i386
libgl1-mesa-dev libgl1-mesa-dev:i386
libegl1-mesa-dev libegl1-mesa-dev:i386
libgles2-mesa-dev libgles2-mesa-dev:i386)
fi
if [ "${#packages[@]}" -ne "0" ]; then
dpkg --add-architecture i386
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends "${packages[@]}"
rm -rf /var/lib/apt/lists/*
fi
fi
mkdir -p /usr/share/glvnd/egl_vendor.d/
cat - << EOF > /usr/share/glvnd/egl_vendor.d/10_nvidia.json
{
"file_format_version" : "1.0.0",
"ICD" : {
"library_path" : "libEGL_nvidia.so.0"
}
}
EOF
mkdir -p /usr/local/share/glvnd/egl_vendor.d/
cp /usr/share/glvnd/egl_vendor.d/10_nvidia.json /usr/local/share/glvnd/egl_vendor.d/10_nvidia.json
}
if [ -n "${BASH_SOURCE+set}" ]; then
if [ "${BASH_SOURCE[0]}" = "${0}" ] || [ "$(basename "${BASH_SOURCE[0]}")" = "${0}" ]; then
set -eu
install_cudagl_packages ${@+"${@}"}
# Self delete this file, so that cuda doesn't try to get installed twice
exec bash -c "rm '${BASH_SOURCE[0]}'"
fi
else
case "${0}" in
*30_install-cuda) # Ran
set -eu
install_cudagl_packages ${@+"${@}"}
# sh doesn't have BASH_SOURCE or exact equivalent, this is closest, unless
# they are sourcing it, then bad things can happen, hence the guards
exec bash -c "rm '${0}'"
;;
*sh) # Sourced for sh/dash/etc...
;;
esac
fi