diff options
Diffstat (limited to 'dev-util/nvidia-cuda-toolkit')
5 files changed, 1320 insertions, 0 deletions
diff --git a/dev-util/nvidia-cuda-toolkit/Manifest b/dev-util/nvidia-cuda-toolkit/Manifest index fbc33464db06..4d7b3cc0ea96 100644 --- a/dev-util/nvidia-cuda-toolkit/Manifest +++ b/dev-util/nvidia-cuda-toolkit/Manifest @@ -3,8 +3,16 @@ DIST cuda_11.8.0_520.61.05_linux.run 4336730777 BLAKE2B cfdb4a51c49ee504e56a4a95 DIST cuda_12.3.2_545.23.08_linux.run 4368514070 BLAKE2B bfb6239b7669636e2ef424921f5a1dd99409a0351ea7d3453fcec3d484e714d87639e733cfae913b0f222d7af8acb7bebae340ea8af53fb7ab320805abb7b230 SHA512 dce569e42955fc351a6b52b2876948029d5183bb000754f0cdcba754673a280acfd4c9e4d8cf61d572ed045de006e0bbb0e8ff32012e6cc336be9c05fd529340 DIST cuda_12.4.0_550.54.14_linux.run 4454353277 BLAKE2B da339a44ac21799a88b4573e9afc0866f11649707594383414cb0c729b36dc63d55032e5ccbbbe46e84c1dc88fc76e466067be7ef2ae3d131a74190c548d76ba SHA512 329b81c63dcefa5c6713eeb2dc5ccc223f5b456f4b7558bd3723d166357d8bb4c79d12082ea396aaadae8b5593b20584f7bd0cf617bb3494e4423b58726255a1 DIST cuda_12.4.1_550.54.15_linux.run 4454730420 BLAKE2B 643513a673e72aeab2e0268c4f91b504132aee378e5e483c46803ed9b1b109274e23bce0cd1022de1220e81dbfb0442c9d84370ad9c6a17e14fe2aaff23ccf13 SHA512 340fab9aad2f3e03fb773c2ec1d4f2c3b1428b350c2072b02263f68f3c521b7ec42086ae7b5e66594a0b91862cc165d8519e4c92e428268bc1e98adcfe106d42 +DIST cuda_12.5.0_555.42.02_linux.run 4294677299 BLAKE2B ffefb576feb9f8e6ea8975bf74fe7277902364035e5dcb27f7b4bdc1d73ea44ce8e057087d670ec18eb49727a9343484bf3aa234c045b91684c70141cf8162e7 SHA512 84fa3ad278217a0fbea97d2d880f625e7e7074a12e98d50d664daaf8298d7d8dd7b222c6f5815636e484df8f1e75c062c70c09f744d139652d960ca8c064114e +DIST cuda_12.5.1_555.42.06_linux.run 4311634770 BLAKE2B 3546faeb24687dd11ad0a61a4f02cfbd97119d9e3cd3e24ea294b81ed488de7dfef03607c69d7b5a8087db10cf794205936add7cfa8ccda207e3aca315be48df SHA512 604843e09717c2af0873b2d5a2e242ff1b99122d515b6a7a29e70c55ab605524744359781f5b642059550b4def57877597111914965efe7d3a1a1387c9dbb1a0 +DIST cuda_12.6.0_560.28.03_linux.run 4333105923 BLAKE2B 533e9080dbf087a661ab6e59548e48ca0d2b514f47c3e97ac89b628f79197875a7425ad69c4d271b5fa8243561c1ccba698e3bf322b194b29a5f7fa031ea8f06 SHA512 fe5710c168298d2283a3f636ad5e1e212970fe8d9554ab450aa61d786536f50efb9d9e9396b6ac59638bd4204faadb5a99ec8a8c02e2c57a18f479123aaff3c9 +DIST cuda_12.6.1_560.35.03_linux.run 4345714567 BLAKE2B 147c7f03e0d9ade4c603d93920d0cd6bb1706efc268797ae870b5244feaa8159393015f96e920c6255e93d8040dd5b046075804cfa7c5da18a645800d65b8c3d SHA512 514ec89f847457c3ba78cd0dc22c25aebf2a19a6bbd5a8d071f31519d1007889cde6ba888a01596434216a8a88bfba21059cdc8e3fa9397133c93d2a9f0c015e EBUILD nvidia-cuda-toolkit-11.8.0-r4.ebuild 8044 BLAKE2B 54995f4f2a8a1998539a6798ff2a68bbfed1943c3e6da27eff58458853db006e105bb39e5bb1935b11971539dcc63fb552ce0b280860ba46ce04f04e98890568 SHA512 df7eb92e74e80302e0fd966ba1c2a97a38f97e3e6bba4bb0a1a389e1336c13d3c9a3603f7079a597d2ae723f7088e83ff708e8ef5d2ba503de0469bf25e1c1c8 EBUILD nvidia-cuda-toolkit-12.3.2.ebuild 9504 BLAKE2B 6abf260006cfd3471665526df049d3f80d956f6a849e8e73c0914aa32faf86ff68d659aa8fcc5a4e95eb6890bf271a2d40edec67aeadd5154444d66e8d337c5e SHA512 3660334d48205d952fd73e688742d700db4b9594920d42d289c581d10af34af516fd8920993650dafacb983492ae72d6b4f3b0ce51d3301d66d6450b34c0c7a9 EBUILD nvidia-cuda-toolkit-12.4.0.ebuild 9515 BLAKE2B 270c9952890a529d17355d5456d6d2422740f69eb9af1b88121e0c8b7a0a9632a39647fc69da4e3653cba4e4cd60f3afc20fce2095743ba128aae8a15f0676ab SHA512 949e4ad4b2d1758279bb620c5a2ba0ea90c93e852f862c448490c689d8d4f522891cb6a772a65894a4f9867be1c8dea1facf87616370bdd0f45987f9d437a3ab EBUILD nvidia-cuda-toolkit-12.4.1.ebuild 9515 BLAKE2B 2fdc866adfe7f552349bcce9b62c2a56186ef859efcc455d4e829f12f71a63cc1ef74eae08a9dc6bbb508aa398679e74a9668353dc3166109157b312fcb0c291 SHA512 58c85d9ee76f180039fd0ccf7e377a4f22bc2d9b92451a54909ddecc4e177c07fc95bb29cfc74b28c9472a64a4c167319be0bcccd6c536296d2105cd88775770 +EBUILD nvidia-cuda-toolkit-12.5.0-r1.ebuild 9535 BLAKE2B b8b50bede8a66a8bce76f6677991b0cf433c3338e89dc82597473dc63874810b9b7461de97d9abc55a471b38618445b7c6dc8e37c18caa8c7d0e3fb9cbdf835e SHA512 8f983c2dc5797fa82f144008ddce2b7eb4b2aaa66b1cf439be25a67fba4a0b4ff5af3480451d53bf0375917e1219facf48e69e7d213aca1e3acbb984595a4d41 +EBUILD nvidia-cuda-toolkit-12.5.1.ebuild 9535 BLAKE2B ea6b46070159a18d8f541af47d648a79b75f7f964d689418220e4eaf87c56fc000eb39fed84637c161aa5f18e5f7e03f0615cbec6670517fd2efefd83139a0a4 SHA512 47bca7b76aad3842f37d8da4fbbdf646a1ca2cc93bc7ae870d8e164a05f735974ca28d69a99a6d0ffcd331e5134025b3819360f27c65dc6c27338756bfc74ba8 +EBUILD nvidia-cuda-toolkit-12.6.0.ebuild 9535 BLAKE2B 984ec77cc39675ba22703339ecbd5596452a5631c7303e4db492bad0b80496ea13151cb25f87a7c0e39d9d2a173be7ad9469a91acfd785abb83632caae230297 SHA512 efbf2fcc39f60ca1f35f15202e924146618b4441c090d26e07048e10dee6ddd79f10640b1c6d8d2e84a218edb6a1382f2398eaf182a503d5dd6dbce250844af3 +EBUILD nvidia-cuda-toolkit-12.6.1.ebuild 9535 BLAKE2B f78cfef4c17ae924032894ff649a5f2911b6fd28727b2ca1f7176b4c009e0841a4936a49998e9029c3c415730f012ab24452f3f0ddf047a48f26811b7c2835eb SHA512 1395bb046c7443c69dfc4f589f9ba88956205faf7779704ecfc0928664d2cbfff07f8db378c20371f84d1971f01aa781bfde95a9a15d16053ddb5aa485467ee3 MISC metadata.xml 761 BLAKE2B a6ae653c6206cbc05349297499b6dde91bce6d543e10bd5ea915cfe9729dfa6f1eb954ae09c2e4d3997f51315ae090b38606c21b5099e750596ea66fdd93e817 SHA512 9133517d805201d25b651e48abed90394c88ef33a2571ab20b3b19d365f85a90478486c7c087c9150d7d9f6e4026873c5236c64ed649fd3bfc8f9b81479dcc59 diff --git a/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-12.5.0-r1.ebuild b/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-12.5.0-r1.ebuild new file mode 100644 index 000000000000..b20e4b0df6ac --- /dev/null +++ b/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-12.5.0-r1.ebuild @@ -0,0 +1,328 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit check-reqs toolchain-funcs unpacker + +DRIVER_PV="555.42.02" + +DESCRIPTION="NVIDIA CUDA Toolkit (compiler and friends)" +HOMEPAGE="https://developer.nvidia.com/cuda-zone" +SRC_URI="https://developer.download.nvidia.com/compute/cuda/${PV}/local_installers/cuda_${PV}_${DRIVER_PV}_linux.run" +S="${WORKDIR}" + +LICENSE="NVIDIA-CUDA" +SLOT="0/${PV}" +KEYWORDS="-* ~amd64 ~amd64-linux" +IUSE="debugger examples nsight profiler rdma vis-profiler sanitizer" +RESTRICT="bindist mirror" + +# since CUDA 11, the bundled toolkit driver (== ${DRIVER_PV}) and the +# actual required minimum driver version are different. +RDEPEND=" + <sys-devel/gcc-14_pre[cxx] + virtual/libcrypt + examples? ( + media-libs/freeglut + media-libs/glu + ) + nsight? ( + app-crypt/mit-krb5 + dev-libs/libpfm + dev-libs/wayland + dev-qt/qtwayland:6 + >=dev-libs/openssl-3 + media-libs/tiff-compat:4 + sys-libs/zlib + ) + rdma? ( sys-cluster/rdma-core ) + vis-profiler? ( + >=virtual/jre-1.8:* + )" +BDEPEND="nsight? ( dev-util/patchelf )" + +QA_PREBUILT="opt/cuda/*" +CHECKREQS_DISK_BUILD="15000M" + +pkg_setup() { + check-reqs_pkg_setup +} + +src_prepare() { + # ATTENTION: change requires revbump, see link below for supported GCC # versions + # https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements + local cuda_supported_gcc="8.5 9.5 10 11 12 13" + + sed \ + -e "s:CUDA_SUPPORTED_GCC:${cuda_supported_gcc}:g" \ + "${FILESDIR}"/cuda-config.in > "${T}"/cuda-config || die + + default +} + +src_install() { + local cudadir=/opt/cuda + local ecudadir="${EPREFIX}${cudadir}" + local pathextradirs ldpathextradirs + dodir ${cudadir} + into ${cudadir} + + # Install standard sub packages + local builddirs=( + builds/cuda_{cccl,cudart,cuobjdump,cuxxfilt,demo_suite,nvcc,nvdisasm,nvml_dev,nvprune,nvrtc,nvtx,opencl} + builds/lib{cublas,cufft,cufile,curand,cusolver,cusparse,npp,nvjitlink,nvjpeg} + builds/nvidia_fs + $(usex profiler "builds/cuda_nvprof builds/cuda_cupti builds/cuda_profiler_api" "") + $(usex vis-profiler "builds/cuda_nvvp" "") + $(usex debugger "builds/cuda_gdb" "") + ) + + local d f + for d in "${builddirs[@]}"; do + ebegin "Installing ${d}" + [[ -d ${d} ]] || die "Directory does not exist: ${d}" + + if [[ -d ${d}/bin ]]; then + for f in ${d}/bin/*; do + if [[ -f ${f} ]]; then + dobin "${f}" + else + insinto ${cudadir}/bin + doins -r "${f}" + fi + done + fi + + insinto ${cudadir} + if [[ -d ${d}/targets ]]; then + doins -r "${d}"/targets + fi + if [[ -d ${d}/share ]]; then + doins -r "${d}"/share + fi + if [[ -d ${d}/extras ]]; then + doins -r "${d}"/extras + fi + eend $? + done + dobin "${T}"/cuda-config + + doins builds/EULA.txt + # nvml and nvvm need special handling + ebegin "Installing nvvm" + doins -r builds/cuda_nvcc/nvvm + fperms +x ${cudadir}/nvvm/bin/cicc + eend $? + + ebegin "Installing nvml" + doins -r builds/cuda_nvml_dev/nvml + eend $? + + if use sanitizer; then + ebegin "Installing sanitizer" + dobin builds/integration/Sanitizer/compute-sanitizer + doins -r builds/cuda_sanitizer_api/compute-sanitizer + # special handling for the executable + fperms +x ${cudadir}/compute-sanitizer/compute-sanitizer + eend $? + fi + + use debugger && ldpathextradirs+=":${ecudadir}/extras/Debugger/lib64" + use profiler && ldpathextradirs+=":${ecudadir}/extras/CUPTI/lib64" + + if use vis-profiler; then + ebegin "Installing libnvvp" + doins -r builds/cuda_nvvp/libnvvp + # special handling for the executable + fperms +x ${cudadir}/libnvvp/nvvp + eend $? + pathextradirs+=":${ecudadir}/libnvvp" + fi + + if use nsight; then + local ncu_dir=$(grep -o 'nsight-compute-[0-9][0-9\.]*' -m1 manifests/cuda_x86_64.xml) + ebegin "Installing ${ncu_dir}" + mv builds/nsight_compute builds/${ncu_dir} || die + doins -r builds/${ncu_dir} + + # check this list on every bump + local exes=( + ${ncu_dir}/ncu + ${ncu_dir}/ncu-ui + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/libexec/QtWebEngineProcess + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/CrashReporter + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/OpenGLVersionChecker + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/QdstrmImporter + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/ncu-ui + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/ncu-ui.bin + ${ncu_dir}/target/linux-desktop-glibc_2_11_3-x64/TreeLauncherSubreaper + ${ncu_dir}/target/linux-desktop-glibc_2_11_3-x64/TreeLauncherTargetLdPreloadHelper + ${ncu_dir}/target/linux-desktop-glibc_2_11_3-x64/ncu + ) + + dobin builds/integration/nsight-compute/{ncu,ncu-ui} + eend $? + + # remove rdma libs (unless USE=rdma) + if ! use rdma; then + rm -r "${ED}"/${cudadir}/${ncu_dir}/host/target-linux-x64/CollectX || die + fi + + local nsys_dir=$(grep -o 'nsight-systems-[0-9][0-9\.]*' -m1 manifests/cuda_x86_64.xml) + ebegin "Installing ${nsys_dir}" + mv builds/nsight_systems builds/${nsys_dir} || die + doins -r builds/${nsys_dir} + + # check this list on every bump + exes+=( + ${nsys_dir}/host-linux-x64/nsys-ui + ${nsys_dir}/host-linux-x64/nsys-ui.bin + ${nsys_dir}/host-linux-x64/ResolveSymbols + ${nsys_dir}/host-linux-x64/ImportNvtxt + ${nsys_dir}/host-linux-x64/CrashReporter + ${nsys_dir}/host-linux-x64/QdstrmImporter + ${nsys_dir}/host-linux-x64/libexec/QtWebEngineProcess + ${nsys_dir}/target-linux-x64/nsys + ${nsys_dir}/target-linux-x64/launcher + ${nsys_dir}/target-linux-x64/nvgpucs + ${nsys_dir}/target-linux-x64/nsys-launcher + ${nsys_dir}/target-linux-x64/sqlite3 + ${nsys_dir}/target-linux-x64/python/bin/python + ${nsys_dir}/target-linux-x64/CudaGpuInfoDumper + ) + + # remove rdma libs (unless USE=rdma) + if ! use rdma; then + rm -r "${ED}"/${cudadir}/${nsys_dir}/target-linux-x64/CollectX || die + fi + + dobin builds/integration/nsight-systems/{nsight-sys,nsys,nsys-ui} + eend $? + + # nsight scripts and binaries need to have their executable bit set, #691284 + for f in "${exes[@]}"; do + fperms +x ${cudadir}/${f} + done + + # fix broken RPATHs + patchelf --set-rpath '$ORIGIN' \ + "${ED}"/${cudadir}/${ncu_dir}/host/{linux-desktop-glibc_2_11_3-x64,target-linux-x64}/{libarrow.so,libparquet.so.500.0.0} || die + patchelf --set-rpath '$ORIGIN' \ + "${ED}"/${cudadir}/${nsys_dir}/{host-linux-x64,target-linux-x64}/{libarrow.so,libparquet.so.500.0.0} || die + + # remove foreign archs (triggers SONAME warning, #749903) + rm -r "${ED}"/${cudadir}/${ncu_dir}/target/linux-desktop-t210-a64 || die + + # unbundle libstdc++ + rm "${ED}"/${cudadir}/${nsys_dir}/host-linux-x64/libstdc++.so.6 || die + + # unbundle openssl + rm "${ED}"/${cudadir}/${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/lib{crypto,ssl}.so* || die + rm "${ED}"/${cudadir}/${nsys_dir}/host-linux-x64/lib{crypto,ssl}.so* || die + + # unbundle libpfm + rm "${ED}"/${cudadir}/${nsys_dir}/host-linux-x64/libpfm.so* || die + + # TODO: unbundle qt5 + # TODO: unbundle boost + # TODO: unbundle icu + # TODO: unbundle mesa + # TODO: unbundle libSshClient + # TODO: unbundle sqlite + fi + + if use examples; then + local exes=( + extras/demo_suite/bandwidthTest + extras/demo_suite/busGrind + extras/demo_suite/deviceQuery + extras/demo_suite/nbody + extras/demo_suite/oceanFFT + extras/demo_suite/randomFog + extras/demo_suite/vectorAdd + ) + + # set executable bit on demo_suite binaries + for f in "${exes[@]}"; do + fperms +x ${cudadir}/${f} + done + else + rm -r "${ED}"/${cudadir}/extras/demo_suite || die + fi + + # remove rdma libs (unless USE=rdma) + if ! use rdma; then + rm "${ED}"/${cudadir}/targets/x86_64-linux/lib/libcufile_rdma* || die + fi + + # Add include and lib symlinks + dosym targets/x86_64-linux/include ${cudadir}/include + dosym targets/x86_64-linux/lib ${cudadir}/lib64 + + # Remove bad symlinks + rm "${ED}"/${cudadir}/targets/x86_64-linux/include/include || die + rm "${ED}"/${cudadir}/targets/x86_64-linux/lib/lib64 || die + + # Remove dead gdb plugins + if use debugger; then + rm "${ED}"/${cudadir}/bin/cuda-gdb-python3.{8,9}-tui || die + fi + + newenvd - 99cuda <<-EOF + PATH=${ecudadir}/bin${pathextradirs} + ROOTPATH=${ecudadir}/bin + LDPATH=${ecudadir}/lib64:${ecudadir}/nvvm/lib64${ldpathextradirs} + EOF + + # Cuda prepackages libraries, don't revdep-build on them + insinto /etc/revdep-rebuild + newins - 80${PN} <<-EOF + SEARCH_DIRS_MASK="${ecudadir}" + EOF + + # https://bugs.gentoo.org/926116 + insinto /etc/sandbox.d + newins - 80${PN} <<-EOF + SANDBOX_PREDICT="/proc/self/task" + EOF +} + +pkg_postinst_check() { + local a="$("${EROOT}"/opt/cuda/bin/cuda-config -s)" + local b="0.0" + local v + for v in ${a}; do + ver_test "${v}" -gt "${b}" && b="${v}" + done + + # if gcc and if not gcc-version is at least greatest supported + if tc-is-gcc && \ + ver_test $(gcc-version) -gt "${b}"; then + ewarn + ewarn "gcc > ${b} will not work with CUDA" + ewarn "Make sure you set an earlier version of gcc with gcc-config" + ewarn "or append --compiler-bindir= pointing to a gcc bindir like" + ewarn "--compiler-bindir=${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/gcc${b}" + ewarn "to the nvcc compiler flags" + ewarn + fi +} + +pkg_postinst() { + if [[ ${MERGE_TYPE} != binary ]]; then + pkg_postinst_check + fi + + if use profiler || use nsight; then + einfo + einfo "nvidia-drivers restrict access to performance counters." + einfo "You'll need to either run profiling tools (nvprof, nsight) " + einfo "using sudo (needs cap SYS_ADMIN) or add the following line to " + einfo "a modprobe configuration file " + einfo "(e.g. /etc/modprobe.d/nvidia-prof.conf): " + einfo + einfo "options nvidia NVreg_RestrictProfilingToAdminUsers=0" + einfo + fi +} diff --git a/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-12.5.1.ebuild b/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-12.5.1.ebuild new file mode 100644 index 000000000000..8357955fde30 --- /dev/null +++ b/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-12.5.1.ebuild @@ -0,0 +1,328 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit check-reqs toolchain-funcs unpacker + +DRIVER_PV="555.42.06" + +DESCRIPTION="NVIDIA CUDA Toolkit (compiler and friends)" +HOMEPAGE="https://developer.nvidia.com/cuda-zone" +SRC_URI="https://developer.download.nvidia.com/compute/cuda/${PV}/local_installers/cuda_${PV}_${DRIVER_PV}_linux.run" +S="${WORKDIR}" + +LICENSE="NVIDIA-CUDA" +SLOT="0/${PV}" +KEYWORDS="-* ~amd64 ~amd64-linux" +IUSE="debugger examples nsight profiler rdma vis-profiler sanitizer" +RESTRICT="bindist mirror" + +# since CUDA 11, the bundled toolkit driver (== ${DRIVER_PV}) and the +# actual required minimum driver version are different. +RDEPEND=" + <sys-devel/gcc-14_pre[cxx] + virtual/libcrypt + examples? ( + media-libs/freeglut + media-libs/glu + ) + nsight? ( + app-crypt/mit-krb5 + dev-libs/libpfm + dev-libs/wayland + dev-qt/qtwayland:6 + >=dev-libs/openssl-3 + media-libs/tiff-compat:4 + sys-libs/zlib + ) + rdma? ( sys-cluster/rdma-core ) + vis-profiler? ( + >=virtual/jre-1.8:* + )" +BDEPEND="nsight? ( dev-util/patchelf )" + +QA_PREBUILT="opt/cuda/*" +CHECKREQS_DISK_BUILD="15000M" + +pkg_setup() { + check-reqs_pkg_setup +} + +src_prepare() { + # ATTENTION: change requires revbump, see link below for supported GCC # versions + # https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements + local cuda_supported_gcc="8.5 9.5 10 11 12 13" + + sed \ + -e "s:CUDA_SUPPORTED_GCC:${cuda_supported_gcc}:g" \ + "${FILESDIR}"/cuda-config.in > "${T}"/cuda-config || die + + default +} + +src_install() { + local cudadir=/opt/cuda + local ecudadir="${EPREFIX}${cudadir}" + local pathextradirs ldpathextradirs + dodir ${cudadir} + into ${cudadir} + + # Install standard sub packages + local builddirs=( + builds/cuda_{cccl,cudart,cuobjdump,cuxxfilt,demo_suite,nvcc,nvdisasm,nvml_dev,nvprune,nvrtc,nvtx,opencl} + builds/lib{cublas,cufft,cufile,curand,cusolver,cusparse,npp,nvjitlink,nvjpeg} + builds/nvidia_fs + $(usex profiler "builds/cuda_nvprof builds/cuda_cupti builds/cuda_profiler_api" "") + $(usex vis-profiler "builds/cuda_nvvp" "") + $(usex debugger "builds/cuda_gdb" "") + ) + + local d f + for d in "${builddirs[@]}"; do + ebegin "Installing ${d}" + [[ -d ${d} ]] || die "Directory does not exist: ${d}" + + if [[ -d ${d}/bin ]]; then + for f in ${d}/bin/*; do + if [[ -f ${f} ]]; then + dobin "${f}" + else + insinto ${cudadir}/bin + doins -r "${f}" + fi + done + fi + + insinto ${cudadir} + if [[ -d ${d}/targets ]]; then + doins -r "${d}"/targets + fi + if [[ -d ${d}/share ]]; then + doins -r "${d}"/share + fi + if [[ -d ${d}/extras ]]; then + doins -r "${d}"/extras + fi + eend $? + done + dobin "${T}"/cuda-config + + doins builds/EULA.txt + # nvml and nvvm need special handling + ebegin "Installing nvvm" + doins -r builds/cuda_nvcc/nvvm + fperms +x ${cudadir}/nvvm/bin/cicc + eend $? + + ebegin "Installing nvml" + doins -r builds/cuda_nvml_dev/nvml + eend $? + + if use sanitizer; then + ebegin "Installing sanitizer" + dobin builds/integration/Sanitizer/compute-sanitizer + doins -r builds/cuda_sanitizer_api/compute-sanitizer + # special handling for the executable + fperms +x ${cudadir}/compute-sanitizer/compute-sanitizer + eend $? + fi + + use debugger && ldpathextradirs+=":${ecudadir}/extras/Debugger/lib64" + use profiler && ldpathextradirs+=":${ecudadir}/extras/CUPTI/lib64" + + if use vis-profiler; then + ebegin "Installing libnvvp" + doins -r builds/cuda_nvvp/libnvvp + # special handling for the executable + fperms +x ${cudadir}/libnvvp/nvvp + eend $? + pathextradirs+=":${ecudadir}/libnvvp" + fi + + if use nsight; then + local ncu_dir=$(grep -o 'nsight-compute-[0-9][0-9\.]*' -m1 manifests/cuda_x86_64.xml) + ebegin "Installing ${ncu_dir}" + mv builds/nsight_compute builds/${ncu_dir} || die + doins -r builds/${ncu_dir} + + # check this list on every bump + local exes=( + ${ncu_dir}/ncu + ${ncu_dir}/ncu-ui + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/libexec/QtWebEngineProcess + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/CrashReporter + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/OpenGLVersionChecker + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/QdstrmImporter + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/ncu-ui + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/ncu-ui.bin + ${ncu_dir}/target/linux-desktop-glibc_2_11_3-x64/TreeLauncherSubreaper + ${ncu_dir}/target/linux-desktop-glibc_2_11_3-x64/TreeLauncherTargetLdPreloadHelper + ${ncu_dir}/target/linux-desktop-glibc_2_11_3-x64/ncu + ) + + dobin builds/integration/nsight-compute/{ncu,ncu-ui} + eend $? + + # remove rdma libs (unless USE=rdma) + if ! use rdma; then + rm -r "${ED}"/${cudadir}/${ncu_dir}/host/target-linux-x64/CollectX || die + fi + + local nsys_dir=$(grep -o 'nsight-systems-[0-9][0-9\.]*' -m1 manifests/cuda_x86_64.xml) + ebegin "Installing ${nsys_dir}" + mv builds/nsight_systems builds/${nsys_dir} || die + doins -r builds/${nsys_dir} + + # check this list on every bump + exes+=( + ${nsys_dir}/host-linux-x64/nsys-ui + ${nsys_dir}/host-linux-x64/nsys-ui.bin + ${nsys_dir}/host-linux-x64/ResolveSymbols + ${nsys_dir}/host-linux-x64/ImportNvtxt + ${nsys_dir}/host-linux-x64/CrashReporter + ${nsys_dir}/host-linux-x64/QdstrmImporter + ${nsys_dir}/host-linux-x64/libexec/QtWebEngineProcess + ${nsys_dir}/target-linux-x64/nsys + ${nsys_dir}/target-linux-x64/launcher + ${nsys_dir}/target-linux-x64/nvgpucs + ${nsys_dir}/target-linux-x64/nsys-launcher + ${nsys_dir}/target-linux-x64/sqlite3 + ${nsys_dir}/target-linux-x64/python/bin/python + ${nsys_dir}/target-linux-x64/CudaGpuInfoDumper + ) + + # remove rdma libs (unless USE=rdma) + if ! use rdma; then + rm -r "${ED}"/${cudadir}/${nsys_dir}/target-linux-x64/CollectX || die + fi + + dobin builds/integration/nsight-systems/{nsight-sys,nsys,nsys-ui} + eend $? + + # nsight scripts and binaries need to have their executable bit set, #691284 + for f in "${exes[@]}"; do + fperms +x ${cudadir}/${f} + done + + # fix broken RPATHs + patchelf --set-rpath '$ORIGIN' \ + "${ED}"/${cudadir}/${ncu_dir}/host/{linux-desktop-glibc_2_11_3-x64,target-linux-x64}/{libarrow.so,libparquet.so.500.0.0} || die + patchelf --set-rpath '$ORIGIN' \ + "${ED}"/${cudadir}/${nsys_dir}/{host-linux-x64,target-linux-x64}/{libarrow.so,libparquet.so.500.0.0} || die + + # remove foreign archs (triggers SONAME warning, #749903) + rm -r "${ED}"/${cudadir}/${ncu_dir}/target/linux-desktop-t210-a64 || die + + # unbundle libstdc++ + rm "${ED}"/${cudadir}/${nsys_dir}/host-linux-x64/libstdc++.so.6 || die + + # unbundle openssl + rm "${ED}"/${cudadir}/${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/lib{crypto,ssl}.so* || die + rm "${ED}"/${cudadir}/${nsys_dir}/host-linux-x64/lib{crypto,ssl}.so* || die + + # unbundle libpfm + rm "${ED}"/${cudadir}/${nsys_dir}/host-linux-x64/libpfm.so* || die + + # TODO: unbundle qt5 + # TODO: unbundle boost + # TODO: unbundle icu + # TODO: unbundle mesa + # TODO: unbundle libSshClient + # TODO: unbundle sqlite + fi + + if use examples; then + local exes=( + extras/demo_suite/bandwidthTest + extras/demo_suite/busGrind + extras/demo_suite/deviceQuery + extras/demo_suite/nbody + extras/demo_suite/oceanFFT + extras/demo_suite/randomFog + extras/demo_suite/vectorAdd + ) + + # set executable bit on demo_suite binaries + for f in "${exes[@]}"; do + fperms +x ${cudadir}/${f} + done + else + rm -r "${ED}"/${cudadir}/extras/demo_suite || die + fi + + # remove rdma libs (unless USE=rdma) + if ! use rdma; then + rm "${ED}"/${cudadir}/targets/x86_64-linux/lib/libcufile_rdma* || die + fi + + # Add include and lib symlinks + dosym targets/x86_64-linux/include ${cudadir}/include + dosym targets/x86_64-linux/lib ${cudadir}/lib64 + + # Remove bad symlinks + rm "${ED}"/${cudadir}/targets/x86_64-linux/include/include || die + rm "${ED}"/${cudadir}/targets/x86_64-linux/lib/lib64 || die + + # Remove dead gdb plugins + if use debugger; then + rm "${ED}"/${cudadir}/bin/cuda-gdb-python3.{8,9}-tui || die + fi + + newenvd - 99cuda <<-EOF + PATH=${ecudadir}/bin${pathextradirs} + ROOTPATH=${ecudadir}/bin + LDPATH=${ecudadir}/lib64:${ecudadir}/nvvm/lib64${ldpathextradirs} + EOF + + # Cuda prepackages libraries, don't revdep-build on them + insinto /etc/revdep-rebuild + newins - 80${PN} <<-EOF + SEARCH_DIRS_MASK="${ecudadir}" + EOF + + # https://bugs.gentoo.org/926116 + insinto /etc/sandbox.d + newins - 80${PN} <<-EOF + SANDBOX_PREDICT="/proc/self/task" + EOF +} + +pkg_postinst_check() { + local a="$("${EROOT}"/opt/cuda/bin/cuda-config -s)" + local b="0.0" + local v + for v in ${a}; do + ver_test "${v}" -gt "${b}" && b="${v}" + done + + # if gcc and if not gcc-version is at least greatest supported + if tc-is-gcc && \ + ver_test $(gcc-version) -gt "${b}"; then + ewarn + ewarn "gcc > ${b} will not work with CUDA" + ewarn "Make sure you set an earlier version of gcc with gcc-config" + ewarn "or append --compiler-bindir= pointing to a gcc bindir like" + ewarn "--compiler-bindir=${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/gcc${b}" + ewarn "to the nvcc compiler flags" + ewarn + fi +} + +pkg_postinst() { + if [[ ${MERGE_TYPE} != binary ]]; then + pkg_postinst_check + fi + + if use profiler || use nsight; then + einfo + einfo "nvidia-drivers restrict access to performance counters." + einfo "You'll need to either run profiling tools (nvprof, nsight) " + einfo "using sudo (needs cap SYS_ADMIN) or add the following line to " + einfo "a modprobe configuration file " + einfo "(e.g. /etc/modprobe.d/nvidia-prof.conf): " + einfo + einfo "options nvidia NVreg_RestrictProfilingToAdminUsers=0" + einfo + fi +} diff --git a/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-12.6.0.ebuild b/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-12.6.0.ebuild new file mode 100644 index 000000000000..26415acb96db --- /dev/null +++ b/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-12.6.0.ebuild @@ -0,0 +1,328 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit check-reqs toolchain-funcs unpacker + +DRIVER_PV="560.28.03" + +DESCRIPTION="NVIDIA CUDA Toolkit (compiler and friends)" +HOMEPAGE="https://developer.nvidia.com/cuda-zone" +SRC_URI="https://developer.download.nvidia.com/compute/cuda/${PV}/local_installers/cuda_${PV}_${DRIVER_PV}_linux.run" +S="${WORKDIR}" + +LICENSE="NVIDIA-CUDA" +SLOT="0/${PV}" +KEYWORDS="-* ~amd64 ~amd64-linux" +IUSE="debugger examples nsight profiler rdma vis-profiler sanitizer" +RESTRICT="bindist mirror" + +# since CUDA 11, the bundled toolkit driver (== ${DRIVER_PV}) and the +# actual required minimum driver version are different. +RDEPEND=" + <sys-devel/gcc-14_pre[cxx] + virtual/libcrypt + examples? ( + media-libs/freeglut + media-libs/glu + ) + nsight? ( + app-crypt/mit-krb5 + dev-libs/libpfm + dev-libs/wayland + dev-qt/qtwayland:6 + >=dev-libs/openssl-3 + media-libs/tiff-compat:4 + sys-libs/zlib + ) + rdma? ( sys-cluster/rdma-core ) + vis-profiler? ( + >=virtual/jre-1.8:* + )" +BDEPEND="nsight? ( dev-util/patchelf )" + +QA_PREBUILT="opt/cuda/*" +CHECKREQS_DISK_BUILD="15000M" + +pkg_setup() { + check-reqs_pkg_setup +} + +src_prepare() { + # ATTENTION: change requires revbump, see link below for supported GCC # versions + # https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements + local cuda_supported_gcc="8.5 9.5 10 11 12 13" + + sed \ + -e "s:CUDA_SUPPORTED_GCC:${cuda_supported_gcc}:g" \ + "${FILESDIR}"/cuda-config.in > "${T}"/cuda-config || die + + default +} + +src_install() { + local cudadir=/opt/cuda + local ecudadir="${EPREFIX}${cudadir}" + local pathextradirs ldpathextradirs + dodir ${cudadir} + into ${cudadir} + + # Install standard sub packages + local builddirs=( + builds/cuda_{cccl,cudart,cuobjdump,cuxxfilt,demo_suite,nvcc,nvdisasm,nvml_dev,nvprune,nvrtc,nvtx,opencl} + builds/lib{cublas,cufft,cufile,curand,cusolver,cusparse,npp,nvjitlink,nvjpeg} + builds/nvidia_fs + $(usex profiler "builds/cuda_nvprof builds/cuda_cupti builds/cuda_profiler_api" "") + $(usex vis-profiler "builds/cuda_nvvp" "") + $(usex debugger "builds/cuda_gdb" "") + ) + + local d f + for d in "${builddirs[@]}"; do + ebegin "Installing ${d}" + [[ -d ${d} ]] || die "Directory does not exist: ${d}" + + if [[ -d ${d}/bin ]]; then + for f in ${d}/bin/*; do + if [[ -f ${f} ]]; then + dobin "${f}" + else + insinto ${cudadir}/bin + doins -r "${f}" + fi + done + fi + + insinto ${cudadir} + if [[ -d ${d}/targets ]]; then + doins -r "${d}"/targets + fi + if [[ -d ${d}/share ]]; then + doins -r "${d}"/share + fi + if [[ -d ${d}/extras ]]; then + doins -r "${d}"/extras + fi + eend $? + done + dobin "${T}"/cuda-config + + doins builds/EULA.txt + # nvml and nvvm need special handling + ebegin "Installing nvvm" + doins -r builds/cuda_nvcc/nvvm + fperms +x ${cudadir}/nvvm/bin/cicc + eend $? + + ebegin "Installing nvml" + doins -r builds/cuda_nvml_dev/nvml + eend $? + + if use sanitizer; then + ebegin "Installing sanitizer" + dobin builds/integration/Sanitizer/compute-sanitizer + doins -r builds/cuda_sanitizer_api/compute-sanitizer + # special handling for the executable + fperms +x ${cudadir}/compute-sanitizer/compute-sanitizer + eend $? + fi + + use debugger && ldpathextradirs+=":${ecudadir}/extras/Debugger/lib64" + use profiler && ldpathextradirs+=":${ecudadir}/extras/CUPTI/lib64" + + if use vis-profiler; then + ebegin "Installing libnvvp" + doins -r builds/cuda_nvvp/libnvvp + # special handling for the executable + fperms +x ${cudadir}/libnvvp/nvvp + eend $? + pathextradirs+=":${ecudadir}/libnvvp" + fi + + if use nsight; then + local ncu_dir=$(grep -o 'nsight-compute-[0-9][0-9\.]*' -m1 manifests/cuda_x86_64.xml) + ebegin "Installing ${ncu_dir}" + mv builds/nsight_compute builds/${ncu_dir} || die + doins -r builds/${ncu_dir} + + # check this list on every bump + local exes=( + ${ncu_dir}/ncu + ${ncu_dir}/ncu-ui + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/libexec/QtWebEngineProcess + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/CrashReporter + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/OpenGLVersionChecker + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/QdstrmImporter + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/ncu-ui + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/ncu-ui.bin + ${ncu_dir}/target/linux-desktop-glibc_2_11_3-x64/TreeLauncherSubreaper + ${ncu_dir}/target/linux-desktop-glibc_2_11_3-x64/TreeLauncherTargetLdPreloadHelper + ${ncu_dir}/target/linux-desktop-glibc_2_11_3-x64/ncu + ) + + dobin builds/integration/nsight-compute/{ncu,ncu-ui} + eend $? + + # remove rdma libs (unless USE=rdma) + if ! use rdma; then + rm -r "${ED}"/${cudadir}/${ncu_dir}/host/target-linux-x64/CollectX || die + fi + + local nsys_dir=$(grep -o 'nsight-systems-[0-9][0-9\.]*' -m1 manifests/cuda_x86_64.xml) + ebegin "Installing ${nsys_dir}" + mv builds/nsight_systems builds/${nsys_dir} || die + doins -r builds/${nsys_dir} + + # check this list on every bump + exes+=( + ${nsys_dir}/host-linux-x64/nsys-ui + ${nsys_dir}/host-linux-x64/nsys-ui.bin + ${nsys_dir}/host-linux-x64/ResolveSymbols + ${nsys_dir}/host-linux-x64/ImportNvtxt + ${nsys_dir}/host-linux-x64/CrashReporter + ${nsys_dir}/host-linux-x64/QdstrmImporter + ${nsys_dir}/host-linux-x64/libexec/QtWebEngineProcess + ${nsys_dir}/target-linux-x64/nsys + ${nsys_dir}/target-linux-x64/launcher + ${nsys_dir}/target-linux-x64/nvgpucs + ${nsys_dir}/target-linux-x64/nsys-launcher + ${nsys_dir}/target-linux-x64/sqlite3 + ${nsys_dir}/target-linux-x64/python/bin/python + ${nsys_dir}/target-linux-x64/CudaGpuInfoDumper + ) + + # remove rdma libs (unless USE=rdma) + if ! use rdma; then + rm -r "${ED}"/${cudadir}/${nsys_dir}/target-linux-x64/CollectX || die + fi + + dobin builds/integration/nsight-systems/{nsight-sys,nsys,nsys-ui} + eend $? + + # nsight scripts and binaries need to have their executable bit set, #691284 + for f in "${exes[@]}"; do + fperms +x ${cudadir}/${f} + done + + # fix broken RPATHs + patchelf --set-rpath '$ORIGIN' \ + "${ED}"/${cudadir}/${ncu_dir}/host/{linux-desktop-glibc_2_11_3-x64,target-linux-x64}/{libarrow.so,libparquet.so.500.0.0} || die + patchelf --set-rpath '$ORIGIN' \ + "${ED}"/${cudadir}/${nsys_dir}/{host-linux-x64,target-linux-x64}/{libarrow.so,libparquet.so.500.0.0} || die + + # remove foreign archs (triggers SONAME warning, #749903) + rm -r "${ED}"/${cudadir}/${ncu_dir}/target/linux-desktop-t210-a64 || die + + # unbundle libstdc++ + rm "${ED}"/${cudadir}/${nsys_dir}/host-linux-x64/libstdc++.so.6 || die + + # unbundle openssl + rm "${ED}"/${cudadir}/${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/lib{crypto,ssl}.so* || die + rm "${ED}"/${cudadir}/${nsys_dir}/host-linux-x64/lib{crypto,ssl}.so* || die + + # unbundle libpfm + rm "${ED}"/${cudadir}/${nsys_dir}/host-linux-x64/libpfm.so* || die + + # TODO: unbundle qt5 + # TODO: unbundle boost + # TODO: unbundle icu + # TODO: unbundle mesa + # TODO: unbundle libSshClient + # TODO: unbundle sqlite + fi + + if use examples; then + local exes=( + extras/demo_suite/bandwidthTest + extras/demo_suite/busGrind + extras/demo_suite/deviceQuery + extras/demo_suite/nbody + extras/demo_suite/oceanFFT + extras/demo_suite/randomFog + extras/demo_suite/vectorAdd + ) + + # set executable bit on demo_suite binaries + for f in "${exes[@]}"; do + fperms +x ${cudadir}/${f} + done + else + rm -r "${ED}"/${cudadir}/extras/demo_suite || die + fi + + # remove rdma libs (unless USE=rdma) + if ! use rdma; then + rm "${ED}"/${cudadir}/targets/x86_64-linux/lib/libcufile_rdma* || die + fi + + # Add include and lib symlinks + dosym targets/x86_64-linux/include ${cudadir}/include + dosym targets/x86_64-linux/lib ${cudadir}/lib64 + + # Remove bad symlinks + rm "${ED}"/${cudadir}/targets/x86_64-linux/include/include || die + rm "${ED}"/${cudadir}/targets/x86_64-linux/lib/lib64 || die + + # Remove dead gdb plugins + if use debugger; then + rm "${ED}"/${cudadir}/bin/cuda-gdb-python3.{8,9}-tui || die + fi + + newenvd - 99cuda <<-EOF + PATH=${ecudadir}/bin${pathextradirs} + ROOTPATH=${ecudadir}/bin + LDPATH=${ecudadir}/lib64:${ecudadir}/nvvm/lib64${ldpathextradirs} + EOF + + # Cuda prepackages libraries, don't revdep-build on them + insinto /etc/revdep-rebuild + newins - 80${PN} <<-EOF + SEARCH_DIRS_MASK="${ecudadir}" + EOF + + # https://bugs.gentoo.org/926116 + insinto /etc/sandbox.d + newins - 80${PN} <<-EOF + SANDBOX_PREDICT="/proc/self/task" + EOF +} + +pkg_postinst_check() { + local a="$("${EROOT}"/opt/cuda/bin/cuda-config -s)" + local b="0.0" + local v + for v in ${a}; do + ver_test "${v}" -gt "${b}" && b="${v}" + done + + # if gcc and if not gcc-version is at least greatest supported + if tc-is-gcc && \ + ver_test $(gcc-version) -gt "${b}"; then + ewarn + ewarn "gcc > ${b} will not work with CUDA" + ewarn "Make sure you set an earlier version of gcc with gcc-config" + ewarn "or append --compiler-bindir= pointing to a gcc bindir like" + ewarn "--compiler-bindir=${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/gcc${b}" + ewarn "to the nvcc compiler flags" + ewarn + fi +} + +pkg_postinst() { + if [[ ${MERGE_TYPE} != binary ]]; then + pkg_postinst_check + fi + + if use profiler || use nsight; then + einfo + einfo "nvidia-drivers restrict access to performance counters." + einfo "You'll need to either run profiling tools (nvprof, nsight) " + einfo "using sudo (needs cap SYS_ADMIN) or add the following line to " + einfo "a modprobe configuration file " + einfo "(e.g. /etc/modprobe.d/nvidia-prof.conf): " + einfo + einfo "options nvidia NVreg_RestrictProfilingToAdminUsers=0" + einfo + fi +} diff --git a/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-12.6.1.ebuild b/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-12.6.1.ebuild new file mode 100644 index 000000000000..32ef330046ed --- /dev/null +++ b/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-12.6.1.ebuild @@ -0,0 +1,328 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +inherit check-reqs toolchain-funcs unpacker + +DRIVER_PV="560.35.03" + +DESCRIPTION="NVIDIA CUDA Toolkit (compiler and friends)" +HOMEPAGE="https://developer.nvidia.com/cuda-zone" +SRC_URI="https://developer.download.nvidia.com/compute/cuda/${PV}/local_installers/cuda_${PV}_${DRIVER_PV}_linux.run" +S="${WORKDIR}" + +LICENSE="NVIDIA-CUDA" +SLOT="0/${PV}" +KEYWORDS="-* ~amd64 ~amd64-linux" +IUSE="debugger examples nsight profiler rdma vis-profiler sanitizer" +RESTRICT="bindist mirror" + +# since CUDA 11, the bundled toolkit driver (== ${DRIVER_PV}) and the +# actual required minimum driver version are different. +RDEPEND=" + <sys-devel/gcc-14_pre[cxx] + virtual/libcrypt + examples? ( + media-libs/freeglut + media-libs/glu + ) + nsight? ( + app-crypt/mit-krb5 + dev-libs/libpfm + dev-libs/wayland + dev-qt/qtwayland:6 + >=dev-libs/openssl-3 + media-libs/tiff-compat:4 + sys-libs/zlib + ) + rdma? ( sys-cluster/rdma-core ) + vis-profiler? ( + >=virtual/jre-1.8:* + )" +BDEPEND="nsight? ( dev-util/patchelf )" + +QA_PREBUILT="opt/cuda/*" +CHECKREQS_DISK_BUILD="15000M" + +pkg_setup() { + check-reqs_pkg_setup +} + +src_prepare() { + # ATTENTION: change requires revbump, see link below for supported GCC # versions + # https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#system-requirements + local cuda_supported_gcc="8.5 9.5 10 11 12 13" + + sed \ + -e "s:CUDA_SUPPORTED_GCC:${cuda_supported_gcc}:g" \ + "${FILESDIR}"/cuda-config.in > "${T}"/cuda-config || die + + default +} + +src_install() { + local cudadir=/opt/cuda + local ecudadir="${EPREFIX}${cudadir}" + local pathextradirs ldpathextradirs + dodir ${cudadir} + into ${cudadir} + + # Install standard sub packages + local builddirs=( + builds/cuda_{cccl,cudart,cuobjdump,cuxxfilt,demo_suite,nvcc,nvdisasm,nvml_dev,nvprune,nvrtc,nvtx,opencl} + builds/lib{cublas,cufft,cufile,curand,cusolver,cusparse,npp,nvjitlink,nvjpeg} + builds/nvidia_fs + $(usex profiler "builds/cuda_nvprof builds/cuda_cupti builds/cuda_profiler_api" "") + $(usex vis-profiler "builds/cuda_nvvp" "") + $(usex debugger "builds/cuda_gdb" "") + ) + + local d f + for d in "${builddirs[@]}"; do + ebegin "Installing ${d}" + [[ -d ${d} ]] || die "Directory does not exist: ${d}" + + if [[ -d ${d}/bin ]]; then + for f in ${d}/bin/*; do + if [[ -f ${f} ]]; then + dobin "${f}" + else + insinto ${cudadir}/bin + doins -r "${f}" + fi + done + fi + + insinto ${cudadir} + if [[ -d ${d}/targets ]]; then + doins -r "${d}"/targets + fi + if [[ -d ${d}/share ]]; then + doins -r "${d}"/share + fi + if [[ -d ${d}/extras ]]; then + doins -r "${d}"/extras + fi + eend $? + done + dobin "${T}"/cuda-config + + doins builds/EULA.txt + # nvml and nvvm need special handling + ebegin "Installing nvvm" + doins -r builds/cuda_nvcc/nvvm + fperms +x ${cudadir}/nvvm/bin/cicc + eend $? + + ebegin "Installing nvml" + doins -r builds/cuda_nvml_dev/nvml + eend $? + + if use sanitizer; then + ebegin "Installing sanitizer" + dobin builds/integration/Sanitizer/compute-sanitizer + doins -r builds/cuda_sanitizer_api/compute-sanitizer + # special handling for the executable + fperms +x ${cudadir}/compute-sanitizer/compute-sanitizer + eend $? + fi + + use debugger && ldpathextradirs+=":${ecudadir}/extras/Debugger/lib64" + use profiler && ldpathextradirs+=":${ecudadir}/extras/CUPTI/lib64" + + if use vis-profiler; then + ebegin "Installing libnvvp" + doins -r builds/cuda_nvvp/libnvvp + # special handling for the executable + fperms +x ${cudadir}/libnvvp/nvvp + eend $? + pathextradirs+=":${ecudadir}/libnvvp" + fi + + if use nsight; then + local ncu_dir=$(grep -o 'nsight-compute-[0-9][0-9\.]*' -m1 manifests/cuda_x86_64.xml) + ebegin "Installing ${ncu_dir}" + mv builds/nsight_compute builds/${ncu_dir} || die + doins -r builds/${ncu_dir} + + # check this list on every bump + local exes=( + ${ncu_dir}/ncu + ${ncu_dir}/ncu-ui + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/libexec/QtWebEngineProcess + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/CrashReporter + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/OpenGLVersionChecker + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/QdstrmImporter + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/ncu-ui + ${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/ncu-ui.bin + ${ncu_dir}/target/linux-desktop-glibc_2_11_3-x64/TreeLauncherSubreaper + ${ncu_dir}/target/linux-desktop-glibc_2_11_3-x64/TreeLauncherTargetLdPreloadHelper + ${ncu_dir}/target/linux-desktop-glibc_2_11_3-x64/ncu + ) + + dobin builds/integration/nsight-compute/{ncu,ncu-ui} + eend $? + + # remove rdma libs (unless USE=rdma) + if ! use rdma; then + rm -r "${ED}"/${cudadir}/${ncu_dir}/host/target-linux-x64/CollectX || die + fi + + local nsys_dir=$(grep -o 'nsight-systems-[0-9][0-9\.]*' -m1 manifests/cuda_x86_64.xml) + ebegin "Installing ${nsys_dir}" + mv builds/nsight_systems builds/${nsys_dir} || die + doins -r builds/${nsys_dir} + + # check this list on every bump + exes+=( + ${nsys_dir}/host-linux-x64/nsys-ui + ${nsys_dir}/host-linux-x64/nsys-ui.bin + ${nsys_dir}/host-linux-x64/ResolveSymbols + ${nsys_dir}/host-linux-x64/ImportNvtxt + ${nsys_dir}/host-linux-x64/CrashReporter + ${nsys_dir}/host-linux-x64/QdstrmImporter + ${nsys_dir}/host-linux-x64/libexec/QtWebEngineProcess + ${nsys_dir}/target-linux-x64/nsys + ${nsys_dir}/target-linux-x64/launcher + ${nsys_dir}/target-linux-x64/nvgpucs + ${nsys_dir}/target-linux-x64/nsys-launcher + ${nsys_dir}/target-linux-x64/sqlite3 + ${nsys_dir}/target-linux-x64/python/bin/python + ${nsys_dir}/target-linux-x64/CudaGpuInfoDumper + ) + + # remove rdma libs (unless USE=rdma) + if ! use rdma; then + rm -r "${ED}"/${cudadir}/${nsys_dir}/target-linux-x64/CollectX || die + fi + + dobin builds/integration/nsight-systems/{nsight-sys,nsys,nsys-ui} + eend $? + + # nsight scripts and binaries need to have their executable bit set, #691284 + for f in "${exes[@]}"; do + fperms +x ${cudadir}/${f} + done + + # fix broken RPATHs + patchelf --set-rpath '$ORIGIN' \ + "${ED}"/${cudadir}/${ncu_dir}/host/{linux-desktop-glibc_2_11_3-x64,target-linux-x64}/{libarrow.so,libparquet.so.500.0.0} || die + patchelf --set-rpath '$ORIGIN' \ + "${ED}"/${cudadir}/${nsys_dir}/{host-linux-x64,target-linux-x64}/{libarrow.so,libparquet.so.500.0.0} || die + + # remove foreign archs (triggers SONAME warning, #749903) + rm -r "${ED}"/${cudadir}/${ncu_dir}/target/linux-desktop-t210-a64 || die + + # unbundle libstdc++ + rm "${ED}"/${cudadir}/${nsys_dir}/host-linux-x64/libstdc++.so.6 || die + + # unbundle openssl + rm "${ED}"/${cudadir}/${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/lib{crypto,ssl}.so* || die + rm "${ED}"/${cudadir}/${nsys_dir}/host-linux-x64/lib{crypto,ssl}.so* || die + + # unbundle libpfm + rm "${ED}"/${cudadir}/${nsys_dir}/host-linux-x64/libpfm.so* || die + + # TODO: unbundle qt5 + # TODO: unbundle boost + # TODO: unbundle icu + # TODO: unbundle mesa + # TODO: unbundle libSshClient + # TODO: unbundle sqlite + fi + + if use examples; then + local exes=( + extras/demo_suite/bandwidthTest + extras/demo_suite/busGrind + extras/demo_suite/deviceQuery + extras/demo_suite/nbody + extras/demo_suite/oceanFFT + extras/demo_suite/randomFog + extras/demo_suite/vectorAdd + ) + + # set executable bit on demo_suite binaries + for f in "${exes[@]}"; do + fperms +x ${cudadir}/${f} + done + else + rm -r "${ED}"/${cudadir}/extras/demo_suite || die + fi + + # remove rdma libs (unless USE=rdma) + if ! use rdma; then + rm "${ED}"/${cudadir}/targets/x86_64-linux/lib/libcufile_rdma* || die + fi + + # Add include and lib symlinks + dosym targets/x86_64-linux/include ${cudadir}/include + dosym targets/x86_64-linux/lib ${cudadir}/lib64 + + # Remove bad symlinks + rm "${ED}"/${cudadir}/targets/x86_64-linux/include/include || die + rm "${ED}"/${cudadir}/targets/x86_64-linux/lib/lib64 || die + + # Remove dead gdb plugins + if use debugger; then + rm "${ED}"/${cudadir}/bin/cuda-gdb-python3.{8,9}-tui || die + fi + + newenvd - 99cuda <<-EOF + PATH=${ecudadir}/bin${pathextradirs} + ROOTPATH=${ecudadir}/bin + LDPATH=${ecudadir}/lib64:${ecudadir}/nvvm/lib64${ldpathextradirs} + EOF + + # Cuda prepackages libraries, don't revdep-build on them + insinto /etc/revdep-rebuild + newins - 80${PN} <<-EOF + SEARCH_DIRS_MASK="${ecudadir}" + EOF + + # https://bugs.gentoo.org/926116 + insinto /etc/sandbox.d + newins - 80${PN} <<-EOF + SANDBOX_PREDICT="/proc/self/task" + EOF +} + +pkg_postinst_check() { + local a="$("${EROOT}"/opt/cuda/bin/cuda-config -s)" + local b="0.0" + local v + for v in ${a}; do + ver_test "${v}" -gt "${b}" && b="${v}" + done + + # if gcc and if not gcc-version is at least greatest supported + if tc-is-gcc && \ + ver_test $(gcc-version) -gt "${b}"; then + ewarn + ewarn "gcc > ${b} will not work with CUDA" + ewarn "Make sure you set an earlier version of gcc with gcc-config" + ewarn "or append --compiler-bindir= pointing to a gcc bindir like" + ewarn "--compiler-bindir=${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/gcc${b}" + ewarn "to the nvcc compiler flags" + ewarn + fi +} + +pkg_postinst() { + if [[ ${MERGE_TYPE} != binary ]]; then + pkg_postinst_check + fi + + if use profiler || use nsight; then + einfo + einfo "nvidia-drivers restrict access to performance counters." + einfo "You'll need to either run profiling tools (nvprof, nsight) " + einfo "using sudo (needs cap SYS_ADMIN) or add the following line to " + einfo "a modprobe configuration file " + einfo "(e.g. /etc/modprobe.d/nvidia-prof.conf): " + einfo + einfo "options nvidia NVreg_RestrictProfilingToAdminUsers=0" + einfo + fi +} |