From c7954e83ee90bd5908f6ea65eb7f8895ed21a174 Mon Sep 17 00:00:00 2001 From: Anton Smirnov Date: Fri, 17 Mar 2023 13:22:21 +0200 Subject: [PATCH 1/7] [NNlibAMDGPUExt] Load MIOpen module only if MIOpen is available --- ext/NNlibAMDGPUExt/NNlibAMDGPUExt.jl | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/ext/NNlibAMDGPUExt/NNlibAMDGPUExt.jl b/ext/NNlibAMDGPUExt/NNlibAMDGPUExt.jl index ba46f4468..6dec1811d 100644 --- a/ext/NNlibAMDGPUExt/NNlibAMDGPUExt.jl +++ b/ext/NNlibAMDGPUExt/NNlibAMDGPUExt.jl @@ -2,7 +2,6 @@ module NNlibAMDGPUExt using Adapt using AMDGPU -using AMDGPU.MIOpen using ChainRulesCore using NNlib using NNlib: BatchedAdjoint, BatchedTranspose, BatchedAdjOrTrans @@ -53,9 +52,15 @@ function nnlib_padding(dims) pd[1:2:end] end -include("conv.jl") -include("pool.jl") -include("softmax.jl") -include("activations.jl") +@static if AMDGPU.functional(:MIOpen) + using AMDGPU.MIOpen + + include("conv.jl") + include("pool.jl") + include("softmax.jl") + include("activations.jl") +else + @warn "ROCm MIOpen is not available for AMDGPU. NNlib has limited functionality for AMDGPU." +end end From 1db021c66e00d6a2a0fd185a7964d9824d4d0e0c Mon Sep 17 00:00:00 2001 From: Anton Smirnov Date: Sat, 18 Mar 2023 21:52:25 +0200 Subject: [PATCH 2/7] Use artifacts in CI --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 61fe79362..61074202f 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -80,7 +80,7 @@ steps: env: JULIA_AMDGPU_CORE_MUST_LOAD: "1" JULIA_AMDGPU_HIP_MUST_LOAD: "1" - JULIA_AMDGPU_DISABLE_ARTIFACTS: "1" + # JULIA_AMDGPU_DISABLE_ARTIFACTS: "1" NNLIB_TEST_AMDGPU: true # - label: "GPU julia nightly" From e8f7c720a43ada6348ba5788b5145a8235f2629f Mon Sep 17 00:00:00 2001 From: Anton Smirnov Date: Fri, 31 Mar 2023 22:43:57 +0300 Subject: [PATCH 3/7] Add MIOpen_jll on CI --- .buildkite/pipeline.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 61074202f..ddbb1ec5b 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -55,7 +55,7 @@ steps: if: build.pull_request.labels includes "benchmark" timeout_in_minutes: 30 - - label: "AMDGPU - Julia 1.9 - No Artifacts" + - label: "AMDGPU - Julia 1.9" plugins: - JuliaCI/julia#v1: version: 1.9-nightly @@ -76,18 +76,23 @@ steps: push!(conf[\"targets\"][\"test\"], \"AMDGPU\"); open(io -> TOML.print(io, conf), \"Project.toml\", \"w\"); """ + - julia --project=. -e """ + using Pkg; + Pkg.develop(\"AMDGPU\"); + Pkg.activate(joinpath(Pkg.devdir(), \"AMDGPU\")); + Pkg.add(\"MIOpen_jll\"); + """ timeout_in_minutes: 30 env: JULIA_AMDGPU_CORE_MUST_LOAD: "1" JULIA_AMDGPU_HIP_MUST_LOAD: "1" - # JULIA_AMDGPU_DISABLE_ARTIFACTS: "1" NNLIB_TEST_AMDGPU: true # - label: "GPU julia nightly" # plugins: # - JuliaCI/julia#v1: # version: "nightly" - # - JuliaCI/julia-test#v1: ~ + # - JuliaCI/julia-test#v1: ~ # - JuliaCI/julia-coverage#v1: # codecov: true # dirs: From 57b1c92575a7f3b0035c06e4b8f256cda09158ba Mon Sep 17 00:00:00 2001 From: Anton Smirnov Date: Fri, 31 Mar 2023 23:22:19 +0300 Subject: [PATCH 4/7] Use Project.toml for test --- .buildkite/pipeline.yml | 13 ------------- Project.toml | 15 --------------- test/Project.toml | 17 +++++++++++++++++ test/runtests.jl | 22 ++++++++++++++++------ 4 files changed, 33 insertions(+), 34 deletions(-) create mode 100644 test/Project.toml diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index ddbb1ec5b..2f0aaa667 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -69,19 +69,6 @@ steps: queue: "juliagpu" rocm: "*" rocmgpu: "*" - command: - - julia -e """ - using TOML; - conf = TOML.parse(read(\"Project.toml\", String)); - push!(conf[\"targets\"][\"test\"], \"AMDGPU\"); - open(io -> TOML.print(io, conf), \"Project.toml\", \"w\"); - """ - - julia --project=. -e """ - using Pkg; - Pkg.develop(\"AMDGPU\"); - Pkg.activate(joinpath(Pkg.devdir(), \"AMDGPU\")); - Pkg.add(\"MIOpen_jll\"); - """ timeout_in_minutes: 30 env: JULIA_AMDGPU_CORE_MUST_LOAD: "1" diff --git a/Project.toml b/Project.toml index af1c0bbd0..1892a1b43 100644 --- a/Project.toml +++ b/Project.toml @@ -26,18 +26,3 @@ julia = "1.6" [extras] AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e" -CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" -ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a" -Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" -FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000" -ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" -Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" -NNlibCUDA = "a00861dc-f156-4864-bf3c-e6376f28a68d" -Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" -StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" -Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" -UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" -Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" - -[targets] -test = ["ChainRulesTestUtils", "CUDA", "Documenter", "FiniteDifferences", "ForwardDiff", "Logging", "NNlibCUDA", "Random", "StableRNGs", "Test", "UnicodePlots", "Zygote"] diff --git a/test/Project.toml b/test/Project.toml new file mode 100644 index 000000000..d158aeae4 --- /dev/null +++ b/test/Project.toml @@ -0,0 +1,17 @@ +[deps] +CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" +ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a" +Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4" +FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000" +ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" +Logging = "56ddb016-857b-54e1-b83d-db4d58db5568" +NNlibCUDA = "a00861dc-f156-4864-bf3c-e6376f28a68d" +Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" +StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3" +Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" +UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228" +Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f" +Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" +ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" +LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" diff --git a/test/runtests.jl b/test/runtests.jl index b25dd328c..31d60e31a 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,7 +6,6 @@ import ForwardDiff import Zygote using Zygote: gradient using StableRNGs -using CUDA using Documenter DocMeta.setdocmeta!(NNlib, :DocTestSetup, :(using NNlib, UnicodePlots); recursive=true) @@ -14,24 +13,35 @@ const rng = StableRNG(123) include("test_utils.jl") @testset verbose=true "NNlib.jl" begin - if CUDA.functional() - if get(ENV, "NNLIB_TEST_CUDA", "false") == "true" + if get(ENV, "NNLIB_TEST_CUDA", "false") == "true" + using CUDA + if CUDA.functional() import Pkg using NNlibCUDA @testset "CUDA" begin Pkg.test("NNlibCUDA") end else - @info "Skipping CUDA tests, set NNLIB_TEST_CUDA=true to run them" + @info "Insufficient version or CUDA not found; Skipping CUDA tests" end else - @info "Insufficient version or CUDA not found; Skipping CUDA tests" + @info "Skipping CUDA tests, set NNLIB_TEST_CUDA=true to run them" end if get(ENV, "NNLIB_TEST_AMDGPU", "false") == "true" + # Hack to add MIOpen_jll to AMDGPU. + import Pkg + test_info = Pkg.project() + Pkg.develop("AMDGPU") + Pkg.activate(joinpath(Pkg.devdir(), "AMDGPU")) + Pkg.add("MIOpen_jll") + Pkg.update() + Pkg.activate(test_info.path) + Pkg.update() + using AMDGPU + AMDGPU.versioninfo() if AMDGPU.functional() && AMDGPU.functional(:MIOpen) - AMDGPU.versioninfo() @show AMDGPU.MIOpen.version() @testset "AMDGPU" begin include("ext_amdgpu/runtests.jl") From 2ad588e320a8ad1792f2367f30ce35d3485c6e09 Mon Sep 17 00:00:00 2001 From: Anton Smirnov Date: Sun, 2 Apr 2023 15:58:03 +0300 Subject: [PATCH 5/7] Increase timeout to 60 min --- .buildkite/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 2f0aaa667..398580897 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -69,7 +69,7 @@ steps: queue: "juliagpu" rocm: "*" rocmgpu: "*" - timeout_in_minutes: 30 + timeout_in_minutes: 60 env: JULIA_AMDGPU_CORE_MUST_LOAD: "1" JULIA_AMDGPU_HIP_MUST_LOAD: "1" From fb3da3392378d1d5001c321387f1da003a93caca Mon Sep 17 00:00:00 2001 From: Anton Smirnov Date: Mon, 3 Apr 2023 13:37:56 +0300 Subject: [PATCH 6/7] Trigger CI --- test/runtests.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/runtests.jl b/test/runtests.jl index 31d60e31a..38daea5e3 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -29,13 +29,15 @@ include("test_utils.jl") end if get(ENV, "NNLIB_TEST_AMDGPU", "false") == "true" - # Hack to add MIOpen_jll to AMDGPU. import Pkg test_info = Pkg.project() + + # Add MIOpen_jll to AMDGPU. Pkg.develop("AMDGPU") Pkg.activate(joinpath(Pkg.devdir(), "AMDGPU")) Pkg.add("MIOpen_jll") Pkg.update() + # Update test project. Pkg.activate(test_info.path) Pkg.update() From 988d35894569f455a9c1f72f1028e7d7094a6a21 Mon Sep 17 00:00:00 2001 From: Anton Smirnov Date: Wed, 5 Apr 2023 14:21:53 +0300 Subject: [PATCH 7/7] Trigger CI --- ext/NNlibAMDGPUExt/NNlibAMDGPUExt.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/NNlibAMDGPUExt/NNlibAMDGPUExt.jl b/ext/NNlibAMDGPUExt/NNlibAMDGPUExt.jl index 6dec1811d..5e7d007e6 100644 --- a/ext/NNlibAMDGPUExt/NNlibAMDGPUExt.jl +++ b/ext/NNlibAMDGPUExt/NNlibAMDGPUExt.jl @@ -60,7 +60,10 @@ end include("softmax.jl") include("activations.jl") else - @warn "ROCm MIOpen is not available for AMDGPU. NNlib has limited functionality for AMDGPU." + @warn """ + ROCm MIOpen is not available for AMDGPU. + NNlib has limited functionality for AMDGPU. + """ end end