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