Skip to content

Commit 335ed1c

Browse files
authored
Merge pull request #483 from pxl-th/conditional-miopen
[NNlibAMDGPUExt] Load MIOpen module only if it is available
2 parents 5a1c42c + 988d358 commit 335ed1c

File tree

5 files changed

+51
-37
lines changed

5 files changed

+51
-37
lines changed

.buildkite/pipeline.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ steps:
5555
if: build.pull_request.labels includes "benchmark"
5656
timeout_in_minutes: 30
5757

58-
- label: "AMDGPU - Julia 1.9 - No Artifacts"
58+
- label: "AMDGPU - Julia 1.9"
5959
plugins:
6060
- JuliaCI/julia#v1:
6161
version: 1.9-nightly
@@ -69,25 +69,17 @@ steps:
6969
queue: "juliagpu"
7070
rocm: "*"
7171
rocmgpu: "*"
72-
command:
73-
- julia -e """
74-
using TOML;
75-
conf = TOML.parse(read(\"Project.toml\", String));
76-
push!(conf[\"targets\"][\"test\"], \"AMDGPU\");
77-
open(io -> TOML.print(io, conf), \"Project.toml\", \"w\");
78-
"""
79-
timeout_in_minutes: 30
72+
timeout_in_minutes: 60
8073
env:
8174
JULIA_AMDGPU_CORE_MUST_LOAD: "1"
8275
JULIA_AMDGPU_HIP_MUST_LOAD: "1"
83-
JULIA_AMDGPU_DISABLE_ARTIFACTS: "1"
8476
NNLIB_TEST_AMDGPU: true
8577

8678
# - label: "GPU julia nightly"
8779
# plugins:
8880
# - JuliaCI/julia#v1:
8981
# version: "nightly"
90-
# - JuliaCI/julia-test#v1: ~
82+
# - JuliaCI/julia-test#v1: ~
9183
# - JuliaCI/julia-coverage#v1:
9284
# codecov: true
9385
# dirs:

Project.toml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,3 @@ julia = "1.6"
2626

2727
[extras]
2828
AMDGPU = "21141c5a-9bdb-4563-92ae-f87d6854732e"
29-
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
30-
ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a"
31-
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
32-
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
33-
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
34-
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
35-
NNlibCUDA = "a00861dc-f156-4864-bf3c-e6376f28a68d"
36-
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
37-
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
38-
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
39-
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"
40-
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
41-
42-
[targets]
43-
test = ["ChainRulesTestUtils", "CUDA", "Documenter", "FiniteDifferences", "ForwardDiff", "Logging", "NNlibCUDA", "Random", "StableRNGs", "Test", "UnicodePlots", "Zygote"]

ext/NNlibAMDGPUExt/NNlibAMDGPUExt.jl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ module NNlibAMDGPUExt
22

33
using Adapt
44
using AMDGPU
5-
using AMDGPU.MIOpen
65
using ChainRulesCore
76
using NNlib
87
using NNlib: BatchedAdjoint, BatchedTranspose, BatchedAdjOrTrans
@@ -53,9 +52,18 @@ function nnlib_padding(dims)
5352
pd[1:2:end]
5453
end
5554

56-
include("conv.jl")
57-
include("pool.jl")
58-
include("softmax.jl")
59-
include("activations.jl")
55+
@static if AMDGPU.functional(:MIOpen)
56+
using AMDGPU.MIOpen
57+
58+
include("conv.jl")
59+
include("pool.jl")
60+
include("softmax.jl")
61+
include("activations.jl")
62+
else
63+
@warn """
64+
ROCm MIOpen is not available for AMDGPU.
65+
NNlib has limited functionality for AMDGPU.
66+
"""
67+
end
6068

6169
end

test/Project.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[deps]
2+
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"
3+
ChainRulesTestUtils = "cdddcdb0-9152-4a09-a978-84456f9df70a"
4+
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
5+
FiniteDifferences = "26cc04aa-876d-5657-8c51-4c34ba976000"
6+
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
7+
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
8+
NNlibCUDA = "a00861dc-f156-4864-bf3c-e6376f28a68d"
9+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
10+
StableRNGs = "860ef19b-820b-49d6-a774-d7a799459cd3"
11+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
12+
UnicodePlots = "b8865327-cd53-5732-bb35-84acbb429228"
13+
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
14+
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
15+
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
16+
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
17+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

test/runtests.jl

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,44 @@ import ForwardDiff
66
import Zygote
77
using Zygote: gradient
88
using StableRNGs
9-
using CUDA
109
using Documenter
1110
DocMeta.setdocmeta!(NNlib, :DocTestSetup, :(using NNlib, UnicodePlots); recursive=true)
1211

1312
const rng = StableRNG(123)
1413
include("test_utils.jl")
1514

1615
@testset verbose=true "NNlib.jl" begin
17-
if CUDA.functional()
18-
if get(ENV, "NNLIB_TEST_CUDA", "false") == "true"
16+
if get(ENV, "NNLIB_TEST_CUDA", "false") == "true"
17+
using CUDA
18+
if CUDA.functional()
1919
import Pkg
2020
using NNlibCUDA
2121
@testset "CUDA" begin
2222
Pkg.test("NNlibCUDA")
2323
end
2424
else
25-
@info "Skipping CUDA tests, set NNLIB_TEST_CUDA=true to run them"
25+
@info "Insufficient version or CUDA not found; Skipping CUDA tests"
2626
end
2727
else
28-
@info "Insufficient version or CUDA not found; Skipping CUDA tests"
28+
@info "Skipping CUDA tests, set NNLIB_TEST_CUDA=true to run them"
2929
end
3030

3131
if get(ENV, "NNLIB_TEST_AMDGPU", "false") == "true"
32+
import Pkg
33+
test_info = Pkg.project()
34+
35+
# Add MIOpen_jll to AMDGPU.
36+
Pkg.develop("AMDGPU")
37+
Pkg.activate(joinpath(Pkg.devdir(), "AMDGPU"))
38+
Pkg.add("MIOpen_jll")
39+
Pkg.update()
40+
# Update test project.
41+
Pkg.activate(test_info.path)
42+
Pkg.update()
43+
3244
using AMDGPU
45+
AMDGPU.versioninfo()
3346
if AMDGPU.functional() && AMDGPU.functional(:MIOpen)
34-
AMDGPU.versioninfo()
3547
@show AMDGPU.MIOpen.version()
3648
@testset "AMDGPU" begin
3749
include("ext_amdgpu/runtests.jl")

0 commit comments

Comments
 (0)