-
Notifications
You must be signed in to change notification settings - Fork 11
Support CUDA on Julia 1.9+ via a package extension. #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5f07cf3
Support CUDA on Julia 1.9+ via a package extension.
GunnarFarneback ab407a3
Drop support for Julia < 1.9 and CUDA < 4. Remove Requires machinery.
GunnarFarneback 34d7e7e
Error instead of warn in cases where a later error is unavoidable.
GunnarFarneback 2d699db
Remove stray Julia 1.6 installation step.
GunnarFarneback 7cc0816
Update README.md.
GunnarFarneback dbe6498
Stricter CUDA runtime version checks and version consistency tests.
GunnarFarneback 0a99758
Bump version to 0.4.
GunnarFarneback 73e0b51
Update README.md
GunnarFarneback bd6a35b
Remove no longer used file.
GunnarFarneback File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ jobs: | |
| fail-fast: false | ||
| matrix: | ||
| version: | ||
| - '1.6' | ||
| - '1.9' | ||
| - '1' | ||
| - 'nightly' | ||
| os: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 = "0.4.0" | ||
|
|
||
| [deps] | ||
| ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197" | ||
|
|
@@ -11,18 +11,27 @@ 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" | ||
| julia = "1.6" | ||
| cuDNN = "1.1" | ||
| julia = "1.9" | ||
|
|
||
| [extensions] | ||
| CUDAExt = ["CUDA", "cuDNN"] | ||
|
|
||
| [extras] | ||
| Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
| 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" | ||
| cuDNN = "02a925ec-e4fe-4b08-9a7e-0d78e3d38ccd" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| module CUDAExt | ||
|
|
||
| # These functions are only defined for diagnostic purposes. Otherwise | ||
| # the CUDA extension only relies on the CUDA and cuDNN dependencies to | ||
| # have loaded the libraries needed by ONNXRunTime's CUDA execution | ||
| # provider. | ||
| import CUDA | ||
| cuda_functional() = CUDA.functional() | ||
| cuda_runtime_version() = CUDA.runtime_version() | ||
|
|
||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # Version number of the ONNXRunTime library and supported versions of | ||
| # the CUDA runtime for GPU processing with the CUDA execution | ||
| # provider. | ||
| # | ||
| # * `onnxruntime_version`: This number must match the version number | ||
| # reported by the ONNXRunTime library, which is verified in the | ||
| # tests. The only real purpose of this variable is to help keep the | ||
| # next one up to date when the library is updated. | ||
| # | ||
| # * `cuda_runtime_supported_version`: This is the lowest supported | ||
| # version of the ONNX runtime library, which should match the | ||
| # information from | ||
| # https://onnxruntime.ai/docs/execution-providers/CUDA-ExecutionProvider.html#requirements | ||
| # | ||
| # * `cuda_runtime_upper_bound`: The lowest CUDA runtime version which | ||
| # is *not* accepted. Presumably CUDA runtime follows semantic | ||
| # versioning so this can automatically be set to the next major | ||
| # version. | ||
| const onnxruntime_version = v"1.15.1" | ||
| const cuda_runtime_supported_version = v"11.8" | ||
| const cuda_runtime_upper_bound = VersionNumber(cuda_runtime_supported_version.major + 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| [CUDA_Runtime_jll] | ||
| version = "11.8" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| include("test_versions.jl") | ||
| include("test_highlevel.jl") | ||
| include("test_capi.jl") | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,128 @@ | ||
| # This file is neither included from `runtests.jl` nor run in CI. | ||
| # | ||
| # Run it with `julia tests/test_cuda_extension.jl`. This requires that | ||
| # Julia is installed with juliaup and will involve downloading of a | ||
| # lot of big artifacts. The output will contain lots of error messages | ||
| # from caught errors; what matters is that all testsets pass. | ||
|
|
||
| using Test | ||
|
|
||
| juliaup_found = false | ||
| try run(pipeline(`juliaup --version`, stdout = devnull, stderr = devnull)) | ||
| global juliaup_found = true | ||
| catch e | ||
| end | ||
|
|
||
| if !juliaup_found | ||
| error("`juliaup` needs to be installed for the CUDA extension tests") | ||
| end | ||
|
|
||
| wait(run(`juliaup add 1.9`, wait = false)) | ||
|
|
||
| package_path = dirname(@__DIR__) | ||
| onnx_path = joinpath(@__DIR__, "data", "copy2d.onnx") | ||
|
|
||
| function with_environment(f::Function; cuda_runtime_version) | ||
| mktempdir() do env | ||
| write(joinpath(env, "LocalPreferences.toml"), | ||
| """ | ||
| [CUDA_Runtime_jll] | ||
| version = "$(cuda_runtime_version)" | ||
| """) | ||
| write(joinpath(env, "Project.toml"), | ||
| """ | ||
| [extras] | ||
| CUDA_Runtime_jll = "76a88914-d11a-5bdc-97e0-2f5a05c973a2" | ||
| """) | ||
| f(env) | ||
| end | ||
| end | ||
|
|
||
| @testset "Julia 1.9 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") | ||
| """ | ||
| # CUDA 3 is not possible to install together with ONNXRunTime | ||
| # on Julia 1.9 due to Compat requirements. | ||
| @test_throws ProcessFailedException run(`julia +1.9 --project=$(env) -e "$(install_script)"`) | ||
| end | ||
| end | ||
|
|
||
| @testset "Julia 1.9 CUDA.jl $(cuda_version) CUDA runtime 11.8" for cuda_version in (4, 5) | ||
| with_environment(cuda_runtime_version = "11.8") do env | ||
| install_script = """ | ||
| using Pkg | ||
| Pkg.develop(path = "$(package_path)") | ||
| Pkg.add(name = "CUDA", version = "$(cuda_version)") | ||
| Pkg.add(name = "cuDNN") | ||
| """ | ||
| @test success(run(`julia +1.9 --project=$(env) -e "$(install_script)"`)) | ||
| # Correct dependencies for :cuda. | ||
| test_script = """ | ||
| using ONNXRunTime, CUDA, cuDNN | ||
| load_inference("$(onnx_path)", execution_provider = :cuda) | ||
| """ | ||
| @test success(run(`julia +1.9 --project=$(env) -e "$(test_script)"`)) | ||
| # Neither CUDA nor cuDNN loaded. | ||
| test_script = """ | ||
| using ONNXRunTime | ||
| load_inference("$(onnx_path)", execution_provider = :cuda) | ||
| """ | ||
| @test_throws ProcessFailedException run(`julia +1.9 --project=$(env) -e "$(test_script)"`) | ||
| # Neither CUDA nor cuDNN loaded but running on CPU, so it's fine. | ||
| test_script = """ | ||
| using ONNXRunTime | ||
| load_inference("$(onnx_path)", execution_provider = :cpu) | ||
| """ | ||
| # CUDA not loaded. Well, cuDNN pulls in CUDA so this passes anyway. | ||
| test_script = """ | ||
| using ONNXRunTime | ||
| using cuDNN | ||
| load_inference("$(onnx_path)", execution_provider = :cuda) | ||
| """ | ||
| @test success(run(`julia +1.9 --project=$(env) -e "$(test_script)"`)) | ||
| # CUDA not loaded but running on CPU, so it's fine. | ||
| test_script = """ | ||
| using ONNXRunTime | ||
| using cuDNN | ||
| load_inference("$(onnx_path)", execution_provider = :cpu) | ||
| """ | ||
| @test success(run(`julia +1.9 --project=$(env) -e "$(test_script)"`)) | ||
| # cuDNN not loaded. | ||
| test_script = """ | ||
| using ONNXRunTime | ||
| using CUDA | ||
| load_inference("$(onnx_path)", execution_provider = :cuda) | ||
| """ | ||
| @test_throws ProcessFailedException run(`julia +1.9 --project=$(env) -e "$(test_script)"`) | ||
| # cuDNN not loaded but running on CPU, so it's fine. | ||
| test_script = """ | ||
| using ONNXRunTime | ||
| using CUDA | ||
| load_inference("$(onnx_path)", execution_provider = :cpu) | ||
| """ | ||
| @test success(run(`julia +1.9 --project=$(env) -e "$(test_script)"`)) | ||
| end | ||
| end | ||
|
|
||
| @testset "Julia 1.9 CUDA.jl $(cuda_version) CUDA runtime $(cuda_runtime_version)" for cuda_version in (4, 5), cuda_runtime_version in ("11.6", "12.1") | ||
| with_environment(; cuda_runtime_version) do env | ||
| install_script = """ | ||
| using Pkg | ||
| Pkg.develop(path = "$(package_path)") | ||
| Pkg.add(name = "CUDA", version = "$(cuda_version)") | ||
| Pkg.add(name = "cuDNN") | ||
| """ | ||
| @test success(run(`julia +1.9 --project=$(env) -e "$(install_script)"`)) | ||
| # Correct dependencies for :cuda but fails due to bad version | ||
| # of CUDA runtime. | ||
| test_script = """ | ||
| using ONNXRunTime, CUDA, cuDNN | ||
| load_inference("$(onnx_path)", execution_provider = :cuda) | ||
| """ | ||
| @test_throws ProcessFailedException run(`julia +1.9 --project=$(env) -e "$(test_script)"`) | ||
| end | ||
| end | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.