|
| 1 | +# Note that this script can accept some limited command-line arguments, run |
| 2 | +# `julia build_tarballs.jl --help` to see a usage message. |
| 3 | +using BinaryBuilder, Pkg |
| 4 | + |
| 5 | +const YGGDRASIL_DIR = "../../.." |
| 6 | +include(joinpath(YGGDRASIL_DIR, "fancy_toys.jl")) |
| 7 | +include(joinpath(YGGDRASIL_DIR, "platforms", "cuda.jl")) |
| 8 | + |
| 9 | +name = "ONNXRuntime_CUDA" |
| 10 | +version = v"1.10.0" |
| 11 | + |
| 12 | +# Cf. https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements |
| 13 | +# Cf. https://onnxruntime.ai/docs/execution-providers/TensorRT-ExecutionProvider.html#requirements |
| 14 | +cuda_versions = [ |
| 15 | + v"10.2", |
| 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). |
| 17 | +] |
| 18 | +cudnn_version = v"8.2.4" |
| 19 | +tensorrt_version = v"8.0.1" |
| 20 | + |
| 21 | +cudnn_compat = string(cudnn_version.major) |
| 22 | +tensorrt_compat = string(tensorrt_version.major) |
| 23 | + |
| 24 | +include(joinpath(@__DIR__, "..", "common.jl")) |
| 25 | + |
| 26 | +# Override the default sources |
| 27 | +append!(sources, [ |
| 28 | + ArchiveSource("https://github.com/microsoft/onnxruntime/releases/download/v$version/onnxruntime-win-x64-gpu-$version.zip", "0da11b8d953fad4ec75f87bb894f72dea511a3940cff2f4dad37451586d1ebbc"; unpack_target="onnxruntime-x86_64-w64-mingw32-cuda"), |
| 29 | + # aarch64-linux-gnu binaries for NVIDIA Jetson from NVIDIA-managed Jetson Zoo: https://elinux.org/Jetson_Zoo#ONNX_Runtime |
| 30 | + FileSource("https://nvidia.box.com/shared/static/jy7nqva7l88mq9i8bw3g3sklzf4kccn2.whl", "a608b7a4a4fc6ad5c90d6005edbfe0851847b991b08aafff4549bbbbdb938bf6"; filename = "onnxruntime-aarch64-linux-gnu-cuda.whl"), |
| 31 | +]) |
| 32 | + |
| 33 | +# Override the default platforms |
| 34 | +platforms = CUDA.supported_platforms(min_version=v"10.2", max_version=v"11") |
| 35 | +filter!(p -> !(arch(p) == "x86_64" && Sys.islinux(p) && p["cuda"] == "10.2"), platforms) # Fails with: nvcc error : 'ptxas' died due to signal 11 (Invalid memory reference) |
| 36 | +push!(platforms, Platform("x86_64", "Linux"; cuda = "11.3")) |
| 37 | +push!(platforms, Platform("x86_64", "Windows"; cuda = "11.3")) |
| 38 | +platforms = expand_cxxstring_abis(platforms; skip=!Sys.islinux) |
| 39 | + |
| 40 | +# Override the default products |
| 41 | +append!(products, [ |
| 42 | + LibraryProduct(["libonnxruntime_providers_cuda", "onnxruntime_providers_cuda"], :libonnxruntime_providers_cuda; dont_dlopen=true), |
| 43 | + LibraryProduct(["libonnxruntime_providers_shared", "onnxruntime_providers_shared"], :libonnxruntime_providers_shared), |
| 44 | + LibraryProduct(["libonnxruntime_providers_tensorrt", "onnxruntime_providers_tensorrt"], :libonnxruntime_providers_tensorrt; dont_dlopen=true), |
| 45 | +]) |
| 46 | + |
| 47 | +append!(dependencies, [ |
| 48 | + 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" |
| 49 | + Dependency("TensorRT_jll", tensorrt_version; compat = tensorrt_compat), |
| 50 | + Dependency("Zlib_jll"), |
| 51 | +]) |
| 52 | + |
| 53 | +builds = [] |
| 54 | +for platform in platforms |
| 55 | + should_build_platform(platform) || continue |
| 56 | + additional_deps = BinaryBuilder.AbstractDependency[] |
| 57 | + if platform["cuda"] == "11.3" |
| 58 | + additional_deps = BinaryBuilder.AbstractDependency[ |
| 59 | + BuildDependency(PackageSpec("CUDA_full_jll", v"11.3.1")), |
| 60 | + 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 |
| 61 | + ] |
| 62 | + else |
| 63 | + additional_deps = CUDA.required_dependencies(platform, static_sdk = true) |
| 64 | + end |
| 65 | + push!(builds, (; platforms=[platform], dependencies=[dependencies; additional_deps])) |
| 66 | +end |
| 67 | + |
| 68 | +# don't allow `build_tarballs` to override platform selection based on ARGS. |
| 69 | +# we handle that ourselves by calling `should_build_platform` |
| 70 | +non_platform_ARGS = filter(arg -> startswith(arg, "--"), ARGS) |
| 71 | + |
| 72 | +# `--register` should only be passed to the latest `build_tarballs` invocation |
| 73 | +non_reg_ARGS = filter(arg -> arg != "--register", non_platform_ARGS) |
| 74 | + |
| 75 | +for (i, build) in enumerate(builds) |
| 76 | + build_tarballs(i == lastindex(builds) ? non_platform_ARGS : non_reg_ARGS, |
| 77 | + name, version, sources, script, |
| 78 | + build.platforms, products, build.dependencies; |
| 79 | + augment_platform_block = CUDA.augment, |
| 80 | + julia_compat = "1.6", |
| 81 | + lazy_artifacts = true, |
| 82 | + preferred_gcc_version = v"8") |
| 83 | +end |
0 commit comments