Diff nvidia-cuda-toolkit-10.2.89-r3 with a nvidia-cuda-toolkit-11.1.1-r2

/usr/portage/dev-util/nvidia-cuda-toolkit/nvidia-cuda-toolkit-11.1.1-r2.ebuild 2021-04-29 12:39:00.000000000 +0300
5 5

  
6 6
inherit check-reqs cuda toolchain-funcs unpacker
7 7

  
8
MYD=$(ver_cut 1-2 ${PV})
9
DRIVER_PV="440.33.01"
8
DRIVER_PV="455.32.00"
10 9

  
11 10
DESCRIPTION="NVIDIA CUDA Toolkit (compiler and friends)"
12 11
HOMEPAGE="https://developer.nvidia.com/cuda-zone"
13
SRC_URI="https://developer.download.nvidia.com/compute/cuda/${MYD}/Prod/local_installers/cuda_${PV}_${DRIVER_PV}_linux.run"
12
SRC_URI="https://developer.download.nvidia.com/compute/cuda/${PV}/local_installers/cuda_${PV}_${DRIVER_PV}_linux.run"
14 13

  
15 14
LICENSE="NVIDIA-CUDA"
16 15
SLOT="0/${PV}"
17 16
KEYWORDS="-* ~amd64 ~amd64-linux"
18
IUSE="debugger doc eclipse profiler"
17
IUSE="debugger nsight profiler vis-profiler sanitizer"
19 18
RESTRICT="bindist mirror"
20 19

  
21 20
BDEPEND=""
22 21
RDEPEND="
23
	<sys-devel/gcc-9[cxx]
22
	<sys-devel/gcc-11_pre[cxx]
24 23
	>=x11-drivers/nvidia-drivers-${DRIVER_PV}
25 24
	debugger? (
26
		dev-libs/openssl-compat:1.0.0
25
		dev-libs/openssl
27 26
		sys-libs/libtermcap-compat
28 27
		sys-libs/ncurses-compat:5[tinfo]
29 28
	)
30
	eclipse? (
31
		dev-libs/openssl-compat:1.0.0
32
		>=virtual/jre-1.8:*
33
	)
34
	profiler? (
35
		dev-libs/openssl-compat:1.0.0
29
	vis-profiler? (
30
		dev-libs/openssl
36 31
		>=virtual/jre-1.8:*
37 32
	)"
38 33

  
......
51 46
	local cuda_supported_gcc
52 47

  
53 48
	# ATTENTION: change requires revbump
54
	cuda_supported_gcc="4.7 4.8 4.9 5.3 5.4 6.3 6.4 7.2 7.3 8.2 8.3 8.4"
49
	cuda_supported_gcc="4.7 4.8 4.9 5.3 5.4 6.3 6.4 7.2 7.3 8.2 8.3 8.4 9.2 9.3 10.2"
55 50

  
56 51
	sed \
57 52
		-e "s:CUDA_SUPPORTED_GCC:${cuda_supported_gcc}:g" \
......
61 56
}
62 57

  
63 58
src_install() {
64
	local i remove=( doc )
65 59
	local cudadir=/opt/cuda
66 60
	local ecudadir="${EPREFIX}${cudadir}"
61
	dodir ${cudadir}
62
	into ${cudadir}
63

  
64
	# Install standard sub packages
65
	local builddirs=(
66
		builds/cuda_{cudart,cuobjdump,memcheck,nvcc,nvdisasm,nvml_dev,nvprune,nvrtc,nvtx}
67
		builds/lib{cublas,cufft,curand,cusolver,cusparse,npp,nvjpeg}
68
		$(usex profiler "builds/cuda_nvprof builds/cuda_cupti" "")
69
		$(usex vis-profiler "builds/cuda_nvvp" "")
70
		$(usex debugger "builds/cuda_gdb" "")
71
	)
72

  
73
	local d
74
	for d in "${builddirs[@]}"; do
75
		ebegin "Installing ${d}"
76
		[[ -d ${d} ]] || die "Directory does not exist: ${d}"
77

  
78
		if [[ -d ${d}/bin ]]; then
79
			local f
80
			for f in ${d}/bin/*; do
81
				if [[ -f ${f} ]]; then
82
					dobin "${f}"
83
				else
84
					insinto ${cudadir}/bin
85
					doins -r "${f}"
86
				fi
87
			done
88
		fi
67 89

  
68
	cd builds/cuda-toolkit
69
	if use doc; then
70
		DOCS+=( doc/pdf/. )
71
		HTML_DOCS+=( doc/html/. )
72
	fi
73
	einstalldocs
74

  
75
	mv doc/man/man3/{,cuda-}deprecated.3 || die
76
	doman doc/man/man*/*
77

  
78
	use debugger || remove+=( bin/cuda-gdb bin/cuda-gdbserver extras/Debugger share/gdb extras/cuda-gdb-${PV}.src.tar.gz )
79

  
80
	if use profiler; then
81
		# hack found in install-linux.pl
82
		for i in nvvp nsight; do
83
			cat > bin/${i} <<- EOF || die
84
				#!/usr/bin/env sh
85
				LD_LIBRARY_PATH=\${LD_LIBRARY_PATH}:${ecudadir}/lib:${ecudadir}/lib64 \
86
					UBUNTU_MENUPROXY=0 LIBOVERLAY_SCROLLBAR=0 \
87
					${ecudadir}/lib${i}/${i} -vm ${EPREFIX}/usr/bin/java
88
			EOF
89
			chmod a+x bin/${i} || die
90
		done
91
	else
92
		use eclipse || remove+=( libnvvp libnsight nsightee_plugins nsight-compute-2019.5.0 nsight-systems-2019.5.2 bin/nsight bin/nsight_ee_plugins_manage.sh bin/nvvp bin/computeprof )
93
		remove+=( extras/CUPTI bin/nvprof )
94
	fi
95

  
96
	for i in "${remove[@]}"; do
97
		ebegin "Cleaning ${i}..."
98
		rm -r "${i}" || die
90
		insinto ${cudadir}
91
		if [[ -d ${d}/targets ]]; then
92
			doins -r "${d}"/targets
93
		fi
94
		if [[ -d ${d}/share ]]; then
95
			doins -r "${d}"/share
96
		fi
97
		if [[ -d ${d}/extras ]]; then
98
			doins -r "${d}"/extras
99
		fi
99 100
		eend
100 101
	done
102
	dobin "${T}"/cuda-config
101 103

  
102
	dodir ${cudadir}
103
	into ${cudadir}
104
	doins builds/EULA.txt
105
	# nvml and nvvm need special handling
106
	ebegin "Installing nvvm"
107
	doins -r builds/cuda_nvcc/nvvm
108
	exeinto ${cudadir}/nvvm/bin
109
	doexe builds/cuda_nvcc/nvvm/bin/cicc
110
	eend
111

  
112
	ebegin "Installing nvml"
113
	doins -r builds/cuda_nvml_dev/nvml
114
	eend
115

  
116
	if use sanitizer; then
117
		ebegin "Installing sanitizer"
118
		dobin builds/integration/Sanitizer/compute-sanitizer
119
		doins -r builds/cuda_sanitizer_api/Sanitizer
120
		# special handling for the executable
121
		exeinto ${cudadir}/Sanitizer
122
		doexe builds/cuda_sanitizer_api/Sanitizer/compute-sanitizer
123
		eend
124
	fi
104 125

  
105
	# Install binaries separately to make sure the X permission is set
106
	local bindirs=( bin nvvm/bin extras/demo_suite  $(usex profiler "libnsight/nsight") )
107
	for i in $(find "${bindirs[@]}" -maxdepth 1 -type f); do
108
		exeinto ${cudadir}/${i%/*}
109
		doexe ${i}
110
		rm ${i} || die
111
	done
112
	exeinto ${cudadir}/bin
113
	doexe "${T}"/cuda-config
126
	if use vis-profiler; then
127
		ebegin "Installing libnvvp"
128
		doins -r builds/cuda_nvvp/libnvvp
129
		# special handling for the executable
130
		exeinto ${cudadir}/libnvvp
131
		doexe builds/cuda_nvvp/libnvvp/nvvp
132
		eend
133
	fi
114 134

  
115
	# Install the rest
116
	insinto ${cudadir}
117
	doins -r *
135
	if use nsight; then
136
		local ncu_dir=$(grep -o 'nsight-compute-[0-9][0-9\.]*' -m1 manifests/cuda_x86_64.xml)
137
		ebegin "Installing ${ncu_dir}"
138
		mv builds/nsight_compute builds/${ncu_dir} || die
139
		doins -r builds/${ncu_dir}
140

  
141
		exeinto ${cudadir}/${ncu_dir}
142
		doexe builds/${ncu_dir}/{ncu,ncu-ui,nv-nsight-cu,nv-nsight-cu-cli}
143

  
144
		exeinto ${cudadir}/${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64
145
		doexe builds/${ncu_dir}/host/linux-desktop-glibc_2_11_3-x64/{ncu-ui,ncu-ui.bin,CrashReporter}
146
		dobin builds/integration/nsight-compute/{ncu,ncu-ui,nv-nsight-cu,nv-nsight-cu-cli}
147
		eend
118 148

  
119
	cat > "${T}"/99cuda <<- EOF || die
120
		PATH=${ecudadir}/bin$(usex profiler ":${ecudadir}/libnvvp" "")
149
		local nsys_dir=$(grep -o 'nsight-systems-[0-9][0-9\.]*' -m1 manifests/cuda_x86_64.xml)
150
		ebegin "Installing ${nsys_dir}"
151
		mv builds/nsight_systems builds/${nsys_dir} || die
152
		doins -r builds/${nsys_dir}
153
		exeinto ${cudadir}/${nsys_dir}/target-linux-x64
154
		doexe builds/${nsys_dir}/target-linux-x64/nsys
155

  
156
		exeinto ${cudadir}/${nsys_dir}/host-linux-x64
157
		doexe builds/${nsys_dir}/host-linux-x64/{nsight-sys,nsight-sys.bin,nsys-ui,CrashReporter,ImportNvtxt,QdstrmImporter,ResolveSymbols}
158
		dobin builds/integration/nsight-systems/{nsight-sys,nsys,nsys-exporter,nsys-ui}
159
		eend
160
		# TODO: unbundle qt5
161
		# TODO: unbundle boost
162
		# TODO: unbundle icu
163
		# TODO: unbundle openssl
164
		# TODO: unbundle mesa
165
		# TODO: unbundle libz
166
		# TODO: unbundle libstdc++
167
		# TODO: unbundle libSshClient
168
		# TODO: unbundle sqlite
169
		# TODO: unbundle libpfm ?
170
	fi
171

  
172
	# Add include and lib symlinks
173
	dosym "targets/x86_64-linux/include" ${cudadir}/include
174
	dosym "targets/x86_64-linux/lib" ${cudadir}/lib64
175

  
176
	newenvd - 99cuda <<-EOF
177
		PATH=${ecudadir}/bin$(usex vis-profiler ":${ecudadir}/libnvvp" "")
121 178
		ROOTPATH=${ecudadir}/bin
122
		LDPATH=${ecudadir}/lib64:${ecudadir}/lib:${ecudadir}/nvvm/lib64
179
		LDPATH=${ecudadir}/lib64:${ecudadir}/nvvm/lib64$(usex profiler ":${ecudadir}/extras/CUPTI/lib64" "")
123 180
	EOF
124
	doenvd "${T}"/99cuda
125 181

  
126
	#Cuda prepackages libraries, don't revdep-build on them
127
	echo "SEARCH_DIRS_MASK=\"${ecudadir}\"" > "${T}/80${PN}" || die
128
	insinto "/etc/revdep-rebuild"
129
	doins "${T}/80${PN}"
182
	# Cuda prepackages libraries, don't revdep-build on them
183
	insinto /etc/revdep-rebuild
184
	newins - 80${PN} <<-EOF
185
		SEARCH_DIRS_MASK="${ecudadir}"
186
	EOF
187
	# TODO: Find a better way to add +x permission to installed executables
188
	# TODO: Add pkgconfig files for installed libraries
130 189
}
131 190

  
132 191
pkg_postinst_check() {
133
	local a b
134
	a="$(${EROOT}/opt/cuda/bin/cuda-config -s)"
135
	b="0.0"
136
	for v in $a; do
137
		if ver_test "${v}" -gt "${b}"; then
138
			b="${v}"
139
		fi
192
	local a="$(${EROOT}/opt/cuda/bin/cuda-config -s)"
193
	local b="0.0"
194
	local v
195
	for v in ${a}; do
196
		ver_test "${v}" -gt "${b}" && b="${v}"
140 197
	done
141 198

  
142 199
	# if gcc and if not gcc-version is at least greatest supported
143 200
	if tc-is-gcc && \
144
		ver_test $(gcc-version) -gt ${b}; then
145
			ewarn ""
201
		ver_test $(gcc-version) -gt "${b}"; then
202
			ewarn
146 203
			ewarn "gcc > ${b} will not work with CUDA"
147 204
			ewarn "Make sure you set an earlier version of gcc with gcc-config"
148 205
			ewarn "or append --compiler-bindir= pointing to a gcc bindir like"
149 206
			ewarn "--compiler-bindir=${EPREFIX}/usr/*pc-linux-gnu/gcc-bin/gcc${b}"
150 207
			ewarn "to the nvcc compiler flags"
151
			ewarn ""
208
			ewarn
152 209
	fi
153 210
}
154 211

  
......
156 213
	if [[ ${MERGE_TYPE} != binary ]]; then
157 214
		pkg_postinst_check
158 215
	fi
216

  
217
	if use profiler || use nsight; then
218
		einfo
219
		einfo "nvidia-drivers restrict access to performance counters."
220
		einfo "You'll need to either run profiling tools (nvprof, nsight) "
221
		einfo "using sudo (needs cap SYS_ADMIN) or add the following line to "
222
		einfo "a modprobe configuration file "
223
		einfo "(e.g. /etc/modprobe.d/nvidia-prof.conf): "
224
		einfo
225
		einfo "options nvidia NVreg_RestrictProfilingToAdminUsers=0"
226
		einfo
227
	fi
159 228
}
Thank you!