Skip to content

Commit

Permalink
Drop support for Julia < 1.9 and CUDA < 4. Remove Requires machinery.
Browse files Browse the repository at this point in the history
  • Loading branch information
GunnarFarneback committed Oct 12, 2023
1 parent 5f07cf3 commit a83257d
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
fail-fast: false
matrix:
version:
- '1.6'
- '1.9'
- '1'
- 'nightly'
os:
Expand Down
8 changes: 3 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ONNXRunTime"
uuid = "e034b28e-924e-41b2-b98f-d2bbeb830c6a"
authors = ["Jan Weidner <[email protected]> and contributors"]
version = "0.3.3"
version = "1.0.0"

[deps]
ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"
Expand All @@ -11,17 +11,15 @@ DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

[compat]
ArgCheck = "2"
CEnum = "0.4"
CUDA = "4, 5"
DataStructures = "0.18"
DocStringExtensions = "0.8, 0.9"
Requires = "1"
cuDNN = "1.1"
julia = "1.6"
julia = "1.9"

[extensions]
CUDAExt = ["CUDA", "cuDNN"]
Expand All @@ -32,7 +30,7 @@ CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd"

[targets]
test = ["Test"]
test = ["Test", "CUDA", "cuDNN"]

[weakdeps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Expand Down
11 changes: 0 additions & 11 deletions src/ONNXRunTime.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
module ONNXRunTime
if !isdefined(Base, :get_extension)
using Requires: @require
end

function _perm(arr::AbstractArray{T,N}) where {T,N}
ntuple(i->N+1-i, N)
Expand All @@ -16,12 +13,4 @@ end
include("capi.jl")
include("highlevel.jl")

@static if !isdefined(Base, :get_extension)
function __init__()
@require CUDA="052768ef-5323-5732-b1bb-66c8b64840ba" begin
CUDA.functional() && include("cuda.jl")
end
end
end

end #module
42 changes: 17 additions & 25 deletions src/highlevel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,23 @@ function load_inference(path::AbstractString; execution_provider::Symbol=:cpu,
if execution_provider === :cpu
session_options = CreateSessionOptions(api)
elseif execution_provider === :cuda
if isdefined(Base, :get_extension)
CUDAExt = Base.get_extension(@__MODULE__, :CUDAExt)
if isnothing(CUDAExt)
@warn """
The $(repr(execution_provider)) execution provider requires the CUDA.jl and cuDNN.jl packages to be available. Try adding `import CUDA, cuDNN` to your code.
"""
elseif !getfield(CUDAExt, :cuda_functional)()
@warn """
The $(repr(execution_provider)) execution provider requires CUDA to be functional. See `CUDA.functional`.
"""
elseif !(v"11.8" <= getfield(CUDAExt, :cuda_runtime_version)() < v"12")
# Note: The supported version range is a property
# inherited from the CUDA runtime library and needs to
# be updated when the library is updated. It may be a
# good idea to centralize this information somewhere.
@warn """
The $(repr(execution_provider)) execution provider requires a CUDA runtime version of at least 11.8 but less than 12. See `CUDA.set_runtime_version!`.
"""
end
else
if !isdefined(@__MODULE__, :CUDA)
@warn """
The $(repr(execution_provider)) execution provider requires the CUDA.jl package to be available. Try adding `import CUDA` to your code.
"""
end
CUDAExt = Base.get_extension(@__MODULE__, :CUDAExt)
if isnothing(CUDAExt)
@warn """
The $(repr(execution_provider)) execution provider requires the CUDA.jl and cuDNN.jl packages to be available. Try adding `import CUDA, cuDNN` to your code.
"""
elseif !getfield(CUDAExt, :cuda_functional)()
@warn """
The $(repr(execution_provider)) execution provider requires CUDA to be functional. See `CUDA.functional`.
"""
elseif !(v"11.8" <= getfield(CUDAExt, :cuda_runtime_version)() < v"12")
# Note: The supported version range is a property
# inherited from the CUDA runtime library and needs to
# be updated when the library is updated. It may be a
# good idea to centralize this information somewhere.
@warn """
The $(repr(execution_provider)) execution provider requires a CUDA runtime version of at least 11.8 but less than 12. See `CUDA.set_runtime_version!`.
"""
end
session_options = CreateSessionOptions(api)
cuda_options = OrtCUDAProviderOptions()
Expand Down
2 changes: 2 additions & 0 deletions test/LocalPreferences.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[CUDA_Runtime_jll]
version = "11.8"
7 changes: 6 additions & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
[deps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd"

[compat]
CUDA = "3"
CUDA = "5"
cuDNN = "1.2"

[extras]
CUDA_Runtime_jll = "76a88914-d11a-5bdc-97e0-2f5a05c973a2"
1 change: 1 addition & 0 deletions test/test_cuda.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module TestCUDA
import CUDA
import cuDNN
using Test
using ONNXRunTime
const ORT = ONNXRunTime
Expand Down
29 changes: 0 additions & 29 deletions test/test_cuda_extension.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,6 @@ function with_environment(f::Function; cuda_runtime_version)
end
end

@testset "Julia 1.6 CUDA 3" begin
with_environment(cuda_runtime_version = "11.8") do env
install_script = """
using Pkg
Pkg.develop(path = "$(package_path)")
Pkg.add(name = "CUDA", version = "3")
"""
@test success(run(`julia +1.6 --project=$(env) -e "$(install_script)"`))
# Correct dependency for :cuda.
test_script = """
using ONNXRunTime, CUDA
load_inference("$(onnx_path)", execution_provider = :cuda)
"""
@test success(run(`julia +1.6 --project=$(env) -e "$(test_script)"`))
# CUDA not loaded.
test_script = """
using ONNXRunTime
load_inference("$(onnx_path)", execution_provider = :cuda)
"""
@test_throws ProcessFailedException run(`julia +1.6 --project=$(env) -e "$(test_script)"`)
# CUDA not loaded but running on CPU, so it's fine.
test_script = """
using ONNXRunTime
load_inference("$(onnx_path)", execution_provider = :cpu)
"""
@test success(run(`julia +1.6 --project=$(env) -e "$(test_script)"`))
end
end

@testset "Julia 1.9 CUDA 3" begin
with_environment(cuda_runtime_version = "11.8") do env
install_script = """
Expand Down

0 comments on commit a83257d

Please sign in to comment.