Gentoo Archives: gentoo-commits

From: David Seifert <soap@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-util/nvidia-cuda-toolkit/
Date: Thu, 09 Sep 2021 20:05:02
Message-Id: 1631217875.b51c46ad6d888e146142ef7d0f8096014ca69adf.soap@gentoo
1 commit: b51c46ad6d888e146142ef7d0f8096014ca69adf
2 Author: David Seifert <soap <AT> gentoo <DOT> org>
3 AuthorDate: Thu Sep 9 20:04:35 2021 +0000
4 Commit: David Seifert <soap <AT> gentoo <DOT> org>
5 CommitDate: Thu Sep 9 20:04:35 2021 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b51c46ad
7
8 dev-util/nvidia-cuda-toolkit: add 11.4.2
9
10 Signed-off-by: David Seifert <soap <AT> gentoo.org>
11
12 dev-util/nvidia-cuda-toolkit/Manifest | 1 +
13 .../nvidia-cuda-toolkit-11.4.2.ebuild | 252 +++++++++++++++++++++
14 2 files changed, 253 insertions(+)
15
16 diff --git a/dev-util/nvidia-cuda-toolkit/Manifest b/dev-util/nvidia-cuda-toolkit/Manifest
17 index 1d6709e8f53..0afbfad0db5 100644
18 --- a/dev-util/nvidia-cuda-toolkit/Manifest
19 +++ b/dev-util/nvidia-cuda-toolkit/Manifest
20 @@ -4,3 +4,4 @@ DIST cuda_11.2.2_460.32.03_linux.run 3057439068 BLAKE2B c3f3cd9eaaa4f91eb8080e7c
21 DIST cuda_11.3.1_465.19.01_linux.run 3158494112 BLAKE2B 0316c6a9bf062f2503c94604b51dea9a8d19c516e304e43ccdbc79f305a242664b7f029f7b7086edd7adc37d92a3bae074f005b3be412e1361917794cb824686 SHA512 e2db8b4dcb5f6aee2c3e8a8a6848186cdcdd7cd9d5f4bfd069bd3dc2ea500797c66a4592f0e28dcbee6c3611d1f88b6fda6afcd734aa9ef45f4aa17a1527aedb
22 DIST cuda_11.4.0_470.42.01_linux.run 3773273383 BLAKE2B 2e466728b6ca9d17dc3caadce13b58c8ba1464c2adeb09739f428aea96f5794c87bf84ca2b81c1019d45223ff5e519503d798032a800a370c7e41517d790f5c4 SHA512 17165102e7f64da77588fd47feeee5ce3f3151a2b482bdc005427ad77ada5d0ff5a51dcd40a27a467cd5988968469476ba90b0191aed993806d284833a08ccb1
23 DIST cuda_11.4.1_470.57.02_linux.run 3796641626 BLAKE2B da6a454bb1765833af8c01f2106a1e0f3e33a6a91354a527006fd0335655872b499bb51662c8e224437368ee37c3bf15f0cf0c4bccc02750e46480ceb6b84677 SHA512 a7a2415e6a0ce6a841e15fccc5c6126d8f134ebb7045e11e49d136aed264c236b91cc959320f763d0d7d878d9d83e09310a51c0ac30c926007dae07242a952de
24 +DIST cuda_11.4.2_470.57.02_linux.run 3833993301 BLAKE2B b12710da9f31e3255f31dd6b0dab8545463983a4cd1c4432bea027d4e5cc4d1ad9183e09b70ac4ea19c7d3e959df0d19bb41ea896d726e877fd3917a3045a9a4 SHA512 50c80141bfe458aa7216173d9d548f25ade03c68fff59ffe63f842773e5afba7635fb8fd79eda416507e1e88b5fe28b39ac8bdc66b168c73a72995824af5c689
25
26 diff --git a/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-11.4.2.ebuild b/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-11.4.2.ebuild
27 new file mode 100644
28 index 00000000000..c929782ee39
29 --- /dev/null
30 +++ b/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-11.4.2.ebuild
31 @@ -0,0 +1,252 @@
32 +# Copyright 1999-2021 Gentoo Authors
33 +# Distributed under the terms of the GNU General Public License v2
34 +
35 +EAPI=7
36 +
37 +inherit check-reqs toolchain-funcs unpacker
38 +
39 +DRIVER_PV="470.57.02"
40 +
41 +DESCRIPTION="NVIDIA CUDA Toolkit (compiler and friends)"
42 +HOMEPAGE="https://developer.nvidia.com/cuda-zone"
43 +SRC_URI="https://developer.download.nvidia.com/compute/cuda/${PV}/local_installers/cuda_${PV}_${DRIVER_PV}_linux.run"
44 +S="${WORKDIR}"
45 +
46 +LICENSE="NVIDIA-CUDA"
47 +SLOT="0/${PV}"
48 +KEYWORDS="-* ~amd64 ~amd64-linux"
49 +IUSE="debugger nsight profiler vis-profiler sanitizer"
50 +RESTRICT="bindist mirror"
51 +
52 +BDEPEND=""
53 +RDEPEND="
54 + <sys-devel/gcc-12_pre[cxx]
55 + >=x11-drivers/nvidia-drivers-${DRIVER_PV}
56 + debugger? (
57 + dev-libs/openssl
58 + sys-libs/libtermcap-compat
59 + sys-libs/ncurses-compat:5[tinfo]
60 + )
61 + vis-profiler? (
62 + dev-libs/openssl
63 + >=virtual/jre-1.8:*
64 + )"
65 +
66 +QA_PREBUILT="opt/cuda/*"
67 +CHECKREQS_DISK_BUILD="6800M"
68 +
69 +pkg_setup() {
70 + check-reqs_pkg_setup
71 +}
72 +
73 +src_prepare() {
74 + # ATTENTION: change requires revbump
75 + local cuda_supported_gcc="8.5 9.4 9.5 10.3 10.4 11.1 11.2 11.3"
76 +
77 + sed \
78 + -e "s:CUDA_SUPPORTED_GCC:${cuda_supported_gcc}:g" \
79 + "${FILESDIR}"/cuda-config.in > "${T}"/cuda-config || die
80 +
81 + default
82 +}
83 +
84 +src_install() {
85 + local cudadir=/opt/cuda
86 + local ecudadir="${EPREFIX}${cudadir}"
87 + local pathextradirs ldpathextradirs
88 + dodir ${cudadir}
89 + into ${cudadir}
90 +
91 + # Install standard sub packages
92 + local builddirs=(
93 + builds/cuda_{cudart,cuobjdump,memcheck,nvcc,nvdisasm,nvml_dev,nvprune,nvrtc,nvtx,thrust}
94 + builds/lib{cublas,cufft,curand,cusolver,cusparse,npp,nvjpeg}
95 + $(usex profiler "builds/cuda_nvprof builds/cuda_cupti" "")
96 + $(usex vis-profiler "builds/cuda_nvvp" "")
97 + $(usex debugger "builds/cuda_gdb" "")
98 + )
99 +
100 + local d f
101 + for d in "${builddirs[@]}"; do
102 + ebegin "Installing ${d}"
103 + [[ -d ${d} ]] || die "Directory does not exist: ${d}"
104 +
105 + if [[ -d ${d}/bin ]]; then
106 + for f in ${d}/bin/*; do
107 + if [[ -f ${f} ]]; then
108 + dobin "${f}"
109 + else
110 + insinto ${cudadir}/bin
111 + doins -r "${f}"
112 + fi
113 + done
114 + fi
115 +
116 + insinto ${cudadir}
117 + if [[ -d ${d}/targets ]]; then
118 + doins -r "${d}"/targets
119 + fi
120 + if [[ -d ${d}/share ]]; then
121 + doins -r "${d}"/share
122 + fi
123 + if [[ -d ${d}/extras ]]; then
124 + doins -r "${d}"/extras
125 + fi
126 + eend
127 + done
128 + dobin "${T}"/cuda-config
129 +
130 + doins builds/EULA.txt
131 + # nvml and nvvm need special handling
132 + ebegin "Installing nvvm"
133 + doins -r builds/cuda_nvcc/nvvm
134 + fperms +x ${cudadir}/nvvm/bin/cicc
135 + eend
136 +
137 + ebegin "Installing nvml"
138 + doins -r builds/cuda_nvml_dev/nvml
139 + eend
140 +
141 + if use sanitizer; then
142 + ebegin "Installing sanitizer"
143 + dobin builds/integration/Sanitizer/compute-sanitizer
144 + doins -r builds/cuda_sanitizer_api/compute-sanitizer
145 + # special handling for the executable
146 + fperms +x ${cudadir}/compute-sanitizer/compute-sanitizer
147 + eend
148 + fi
149 +
150 + use profiler && ldpathextradirs+=":${ecudadir}/extras/CUPTI/lib64"
151 +
152 + if use vis-profiler; then
153 + ebegin "Installing libnvvp"
154 + doins -r builds/cuda_nvvp/libnvvp
155 + # special handling for the executable
156 + fperms +x ${cudadir}/libnvvp/nvvp
157 + eend
158 + pathextradirs+=":${ecudadir}/libnvvp"
159 + fi
160 +
161 + if use nsight; then
162 + local ncu_dir=$(grep -o 'nsight-compute-[0-9][0-9\.]*' -m1 manifests/cuda_x86_64.xml)
163 + ebegin "Installing ${ncu_dir}"
164 + mv builds/nsight_compute builds/${ncu_dir} || die
165 + doins -r builds/${ncu_dir}
166 +
167 + # check this list on every bump
168 + local exes=(
169 + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/libexec/QtWebEngineProcess
170 + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/CrashReporter
171 + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/ncu-ui
172 + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/ncu-ui.bin
173 + ${ncu_dir}/target/linux-desktop-glibc_2_11_3-x64/TreeLauncherTargetLdPreloadHelper
174 + ${ncu_dir}/target/linux-desktop-glibc_2_11_3-x64/TreeLauncherSubreaper
175 + ${ncu_dir}/target/linux-desktop-glibc_2_11_3-x64/ncu
176 + )
177 +
178 + dobin builds/integration/nsight-compute/{ncu,ncu-ui,nv-nsight-cu,nv-nsight-cu-cli}
179 + eend
180 +
181 + local nsys_dir=$(grep -o 'nsight-systems-[0-9][0-9\.]*' -m1 manifests/cuda_x86_64.xml)
182 + ebegin "Installing ${nsys_dir}"
183 + mv builds/nsight_systems builds/${nsys_dir} || die
184 + doins -r builds/${nsys_dir}
185 +
186 + # check this list on every bump
187 + exes+=(
188 + ${nsys_dir}/host-linux-x64/nsys-ui
189 + ${nsys_dir}/host-linux-x64/nsys-ui.bin
190 + ${nsys_dir}/host-linux-x64/ResolveSymbols
191 + ${nsys_dir}/host-linux-x64/ImportNvtxt
192 + ${nsys_dir}/host-linux-x64/CrashReporter
193 + ${nsys_dir}/host-linux-x64/QdstrmImporter
194 + ${nsys_dir}/host-linux-x64/libexec/QtWebEngineProcess
195 + ${nsys_dir}/target-linux-x64/nsys
196 + ${nsys_dir}/target-linux-x64/launcher
197 + ${nsys_dir}/target-linux-x64/nvgpucs
198 + ${nsys_dir}/target-linux-x64/nsys-launcher
199 + ${nsys_dir}/target-linux-x64/sqlite3
200 + ${nsys_dir}/target-linux-x64/python/bin/python
201 + )
202 +
203 + dobin builds/integration/nsight-systems/{nsight-sys,nsys,nsys-exporter,nsys-ui}
204 + eend
205 +
206 + # nsight scripts and binaries need to have their executable bit set, #691284
207 + for f in "${exes[@]}"; do
208 + fperms +x ${cudadir}/${f}
209 + done
210 +
211 + # remove foreign archs (triggers SONAME warning, #749903)
212 + rm -r "${ED}"/${cudadir}/${ncu_dir}/target/linux-desktop-glibc_2_19_0-ppc64le || die
213 + rm -r "${ED}"/${cudadir}/${ncu_dir}/target/linux-desktop-t210-a64 || die
214 + rm -r "${ED}"/${cudadir}/${nsys_dir}/target-linux-armv8 || die
215 +
216 + # TODO: unbundle qt5
217 + # TODO: unbundle boost
218 + # TODO: unbundle icu
219 + # TODO: unbundle openssl
220 + # TODO: unbundle mesa
221 + # TODO: unbundle libz
222 + # TODO: unbundle libstdc++
223 + # TODO: unbundle libSshClient
224 + # TODO: unbundle sqlite
225 + # TODO: unbundle libpfm ?
226 + fi
227 +
228 + # Add include and lib symlinks
229 + dosym targets/x86_64-linux/include ${cudadir}/include
230 + dosym targets/x86_64-linux/lib ${cudadir}/lib64
231 +
232 + newenvd - 99cuda <<-EOF
233 + PATH=${ecudadir}/bin${pathextradirs}
234 + ROOTPATH=${ecudadir}/bin
235 + LDPATH=${ecudadir}/lib64:${ecudadir}/nvvm/lib64${ldpathextradirs}
236 + EOF
237 +
238 + # Cuda prepackages libraries, don't revdep-build on them
239 + insinto /etc/revdep-rebuild
240 + newins - 80${PN} <<-EOF
241 + SEARCH_DIRS_MASK="${ecudadir}"
242 + EOF
243 + # TODO: Add pkgconfig files for installed libraries
244 +}
245 +
246 +pkg_postinst_check() {
247 + local a="$(${EROOT}/opt/cuda/bin/cuda-config -s)"
248 + local b="0.0"
249 + local v
250 + for v in ${a}; do
251 + ver_test "${v}" -gt "${b}" && b="${v}"
252 + done
253 +
254 + # if gcc and if not gcc-version is at least greatest supported
255 + if tc-is-gcc && \
256 + ver_test $(gcc-version) -gt "${b}"; then
257 + ewarn
258 + ewarn "gcc > ${b} will not work with CUDA"
259 + ewarn "Make sure you set an earlier version of gcc with gcc-config"
260 + ewarn "or append --compiler-bindir= pointing to a gcc bindir like"
261 + ewarn "--compiler-bindir=${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/gcc${b}"
262 + ewarn "to the nvcc compiler flags"
263 + ewarn
264 + fi
265 +}
266 +
267 +pkg_postinst() {
268 + if [[ ${MERGE_TYPE} != binary ]]; then
269 + pkg_postinst_check
270 + fi
271 +
272 + if use profiler || use nsight; then
273 + einfo
274 + einfo "nvidia-drivers restrict access to performance counters."
275 + einfo "You'll need to either run profiling tools (nvprof, nsight) "
276 + einfo "using sudo (needs cap SYS_ADMIN) or add the following line to "
277 + einfo "a modprobe configuration file "
278 + einfo "(e.g. /etc/modprobe.d/nvidia-prof.conf): "
279 + einfo
280 + einfo "options nvidia NVreg_RestrictProfilingToAdminUsers=0"
281 + einfo
282 + fi
283 +}