Skip to content

Commit 91ce830

Browse files
committed
add some preliminary gpu test CI code
1 parent 04ed88a commit 91ce830

File tree

2 files changed

+53
-25
lines changed

2 files changed

+53
-25
lines changed

.buildkite/pipeline.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
env:
2+
# SECRET_CODECOV_TOKEN: "nkcRFVXdaPNAbiI0x3qK/XUG8rWjBc8fU73YEyP35SeS465XORqrIYrHUbHuJTRyeyqNRdsHaBcV1P7TBbKAaTQAjHQ1Q0KYfd0uRMSWpZSCgTBz5AwttAxVfFrX+Ky3PzTi2TfDe0uPFZtFo0Asq6sUEr1on+Oo+j+q6br2NK6CrA5yKKuTX4Q2V/UPOIK4vNXY3+zDTKSNtr+HQOlcVEeRIk/0ZQ78Cjd52flEaVw8GWo/CC4YBzLtcOZgaFdgOTEDNHMr0mw6zLE4Y6nxq4lHVSoraSjxjhkB0pXTZ1c51yHX8Jc+q6HC5s87+2Zq5YtsuQSGao+eMtkTAYwfLw==;U2FsdGVkX18z27J3+gNgxsPNnXA0ad4LvZnXeohTam7/6UPqX5+3BYI0tAiVkCho4vlJyL7dd8JEyNtk9BFXsg=="
3+
4+
steps:
5+
- label: "Julia v{{matrix.version}}, {{matrix.label}}"
6+
plugins:
7+
- JuliaCI/julia#v1:
8+
version: "{{matrix.version}}"
9+
# - JuliaCI/julia-coverage#v1:
10+
# dirs:
11+
# - src
12+
# - ext
13+
command: julia --eval='include("test/run_extra.jl")'
14+
agents:
15+
queue: "juliagpu"
16+
cuda: "*"
17+
if: build.message !~ /\[skip tests\]/
18+
timeout_in_minutes: 60
19+
env:
20+
LABEL: "{{matrix.label}}"
21+
TEST_TYPE: ext
22+
matrix:
23+
setup:
24+
version:
25+
- "1"
26+
- "1.10"
27+
label:
28+
- "cuda"

test/ext/cuda.jl

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
1-
using CUDA, Test, LinearAlgebra, Distributions
2-
using Flux
1+
using Pkg
2+
Pkg.activate(@__DIR__)
3+
Pkg.develop(; path=joinpath(@__DIR__, "..", "..", ".."))
34

4-
if CUDA.functional()
5-
@testset "rand with CUDA" begin
6-
dists = [
7-
MvNormal(CUDA.zeros(2), I), MvNormal(CUDA.zeros(2), cu([1.0 0.5; 0.5 1.0]))
8-
]
5+
using NormalizingFlows
6+
using CUDA, Test, LinearAlgebra, Distributions, Flux
97

10-
@testset "$dist" for dist in dists
11-
x = rand_device(CUDA.default_rng(), dist)
12-
xs = rand_device(CUDA.default_rng(), dist, 100)
13-
@info logpdf(dist, x)
14-
@test x isa CuArray
15-
@test xs isa CuArray
16-
end
8+
@testset "rand with CUDA" begin
9+
dists = [MvNormal(CUDA.zeros(2), I), MvNormal(CUDA.zeros(2), cu([1.0 0.5; 0.5 1.0]))]
1710

18-
@testset "$dist" for dist in dists
19-
CUDA.allowscalar(true)
20-
ts = reduce(, [Bijectors.PlanarLayer(2) for _ in 1:2])
21-
ts_g = gpu(ts)
22-
flow = Bijectors.transformed(dist, ts_g)
11+
@testset "$dist" for dist in dists
12+
x = rand_device(CUDA.default_rng(), dist)
13+
xs = rand_device(CUDA.default_rng(), dist, 100)
14+
@info logpdf(dist, x)
15+
@test x isa CuArray
16+
@test xs isa CuArray
17+
end
18+
19+
@testset "$dist" for dist in dists
20+
CUDA.allowscalar(true)
21+
ts = reduce(, [Bijectors.PlanarLayer(2) for _ in 1:2])
22+
ts_g = gpu(ts)
23+
flow = Bijectors.transformed(dist, ts_g)
2324

24-
y = rand_device(CUDA.default_rng(), flow)
25-
ys = rand_device(CUDA.default_rng(), flow, 100)
26-
@info logpdf(flow, y)
27-
@test y isa CuArray
28-
@test ys isa CuArray
29-
end
25+
y = rand_device(CUDA.default_rng(), flow)
26+
ys = rand_device(CUDA.default_rng(), flow, 100)
27+
@info logpdf(flow, y)
28+
@test y isa CuArray
29+
@test ys isa CuArray
3030
end
3131
end

0 commit comments

Comments
 (0)