@@ -13,7 +13,7 @@ version = v"1.10.0"
1313# Cf. https://onnxruntime.ai/docs/execution-providers/TensorRT-ExecutionProvider.html#requirements
1414cuda_versions = [
1515 v " 10.2" ,
16- v " 11.3" ,
16+ v " 11.3" , # Using 11.3, and not 11.4, to be compatible with CUDNN v8.2.4, and with TensorRT (JLL) v8.0.1 (where the latter includes aarch64 support).
1717]
1818cudnn_version = v " 8.2.4"
1919tensorrt_version = v " 8.0.1"
@@ -35,21 +35,18 @@ sources = [
3535script = raw """
3636cd $WORKSPACE/srcdir
3737
38+ cuda_version=${bb_full_target##*-cuda+}
3839if [[ $target != *-w64-mingw32* ]]; then
39- if [[ $bb_full_target == x86_64-linux-gnu-*-cuda* && $bb_full_target != *-cuda+none* ]]; then
40- cuda_version=`echo $bb_full_target | sed -E -e 's/.*cuda\+ ([0-9]+\. [0-9]+).*/\1 /'`
41- cuda_version_major=`echo $cuda_version | cut -d . -f 1`
42- cuda_version_minor=`echo $cuda_version | cut -d . -f 2`
43- cuda_sdk_path=$prefix/cuda
44- export PATH=$PATH:$cuda_sdk_path/bin
40+ if [[ $bb_full_target == x86_64-linux-gnu-*-cuda* && $cuda_version != none ]]; then
41+ export CUDA_PATH="$prefix/cuda"
4542 mkdir $WORKSPACE/tmpdir
4643 export TMPDIR=$WORKSPACE/tmpdir
4744 cmake_extra_args=(
48- "-DCMAKE_CUDA_FLAGS=-cudart shared"
49- " -Donnxruntime_CUDA_HOME=$cuda_sdk_path"
50- " -Donnxruntime_CUDNN_HOME=$prefix"
51- " -Donnxruntime_USE_CUDA=ON"
52- " -Donnxruntime_USE_TENSORRT=ON"
45+ -DCUDAToolkit_ROOT=$CUDA_PATH
46+ -Donnxruntime_CUDA_HOME=$CUDA_PATH
47+ -Donnxruntime_CUDNN_HOME=$prefix
48+ -Donnxruntime_USE_CUDA=ON
49+ -Donnxruntime_USE_TENSORRT=ON
5350 )
5451 fi
5552
@@ -76,10 +73,10 @@ if [[ $target != *-w64-mingw32* ]]; then
7673 make install
7774 install_license $WORKSPACE/srcdir/onnxruntime/LICENSE
7875else
79- if [[ $bb_full_target == *-cuda+none* ]]; then
80- srcdir=onnxruntime-$target
81- else
76+ if [[ $bb_full_target == *-cuda* && $cuda_version != none ]]; then
8277 srcdir=onnxruntime-$target-cuda
78+ else
79+ srcdir=onnxruntime-$target
8380 fi
8481 chmod 755 $srcdir/onnxruntime-*/lib/*
8582 mkdir -p $includedir $libdir
8885 install_license $srcdir/onnxruntime-*/LICENSE
8986fi
9087
91- if [[ $bb_full_target == aarch64-linux-gnu*cuda* ]]; then
88+ if [[ $bb_full_target == aarch64-linux-gnu*- cuda* && $cuda_version != none ]]; then
9289 cd $WORKSPACE/srcdir
9390 unzip -d onnxruntime-$target-cuda onnxruntime-$target-cuda.whl
9491 mkdir -p $libdir
@@ -104,6 +101,20 @@ function platform_exclude_filter(p::Platform)
104101 Sys. isfreebsd (p)
105102end
106103platforms = supported_platforms (; exclude= platform_exclude_filter)
104+
105+ let cuda_platforms = CUDA. supported_platforms (min_version= v " 10.2" , max_version= v " 11" )
106+ push! (cuda_platforms, Platform (" x86_64" , " Linux" ; cuda = " 11.3" ))
107+ push! (cuda_platforms, Platform (" x86_64" , " Windows" ; cuda = " 11.3" ))
108+
109+ # Tag non-CUDA platforms matching CUDA platforms with cuda="none"
110+ for platform in platforms
111+ if CUDA. is_supported (platform) && arch (platform) != " powerpc64le" || platform == Platform (" x86_64" , " Windows" )
112+ platform[" cuda" ] = " none"
113+ end
114+ end
115+ append! (platforms, cuda_platforms)
116+ end
117+
107118platforms = expand_cxxstring_abis (platforms; skip= ! Sys. islinux)
108119
109120# The products that we will ensure are always built
@@ -116,50 +127,26 @@ dependencies = [
116127 HostBuildDependency (PackageSpec (" protoc_jll" , v " 3.16.1" ))
117128]
118129
119- augment_platform_block = CUDA. augment
120-
121130builds = []
122- for cuda_version in [nothing , cuda_versions... ], platform in platforms
123- augmented_platform = deepcopy (platform)
124- if isnothing (cuda_version)
125- augmented_platform[" cuda" ] = " none"
126- else
127- if (
128- CUDA. is_supported (platform)
129- && (
130- (arch (platform) == " aarch64" && Sys. islinux (platform) && Base. thismajor (cuda_version) == v " 10" )
131- || (arch (platform) == " x86_64" && Sys. islinux (platform) && Base. thismajor (cuda_version) == v " 11" )
132- )
133- ) || (
134- arch (platform) == " x86_64" && Sys. iswindows (platform) && Base. thismajor (cuda_version) == v " 11"
135- )
136- augmented_platform[" cuda" ] = CUDA. platform (cuda_version)
137- else
138- continue
139- end
140- end
141- should_build_platform (triplet (augmented_platform)) || continue
142- platform_dependencies = BinaryBuilder. AbstractDependency[]
143- append! (platform_dependencies, dependencies)
144- if ! isnothing (cuda_version)
145- if Base. thisminor (cuda_version) != v " 11.3"
146- append! (platform_dependencies, CUDA. required_dependencies (augmented_platform))
147- else
148- append! (platform_dependencies, [
131+ for platform in platforms
132+ should_build_platform (platform) || continue
133+ additional_deps = BinaryBuilder. AbstractDependency[]
134+ if haskey (platform, " cuda" ) && platform[" cuda" ] != " none"
135+ if platform[" cuda" ] == " 11.3"
136+ additional_deps = BinaryBuilder. AbstractDependency[
149137 BuildDependency (PackageSpec (" CUDA_full_jll" , v " 11.3.1" )),
150- Dependency (" CUDA_Runtime_jll" , v " 0.7.0" ), # Using Dependency with build version v"0.7.0" to get support for cuda = "11.3"
151- ])
138+ Dependency (" CUDA_Runtime_jll" , v " 0.7.0" ), # Using v"0.7.0" to get support for cuda = "11.3" - using Dependency rather than RuntimeDependency to be sure to pass audit
139+ ]
140+ else
141+ additional_deps = CUDA. required_dependencies (platform, static_sdk = true )
152142 end
153- append! (platform_dependencies, [
143+ push! (additional_deps,
154144 Dependency (get_addable_spec (" CUDNN_jll" , v " 8.2.4+0" ); compat = cudnn_compat), # Using v"8.2.4+0" to get support for cuda = "11.3"
155145 Dependency (" TensorRT_jll" , tensorrt_version; compat = tensorrt_compat),
156146 Dependency (" Zlib_jll" ),
157- ] )
147+ )
158148 end
159- push! (builds, (;
160- platforms= [augmented_platform],
161- dependencies= platform_dependencies,
162- ))
149+ push! (builds, (; platforms= [platform], dependencies= [dependencies; additional_deps]))
163150end
164151
165152# don't allow `build_tarballs` to override platform selection based on ARGS.
@@ -169,11 +156,12 @@ non_platform_ARGS = filter(arg -> startswith(arg, "--"), ARGS)
169156# `--register` should only be passed to the latest `build_tarballs` invocation
170157non_reg_ARGS = filter (arg -> arg != " --register" , non_platform_ARGS)
171158
172- for (i,build) in enumerate (builds)
159+ for (i, build) in enumerate (builds)
173160 build_tarballs (i == lastindex (builds) ? non_platform_ARGS : non_reg_ARGS,
174161 name, version, sources, script,
175162 build. platforms, products, build. dependencies;
176- julia_compat= " 1.6" ,
177- augment_platform_block,
163+ augment_platform_block = CUDA. augment,
164+ julia_compat = " 1.6" ,
165+ lazy_artifacts = true ,
178166 preferred_gcc_version = v " 8" )
179167end
0 commit comments