-
Notifications
You must be signed in to change notification settings - Fork 57
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
GPU kernel error #1129
Comments
|
@jgreener64 can you retry on main now that I added: #1131 |
The error is similar to before, error_2.txt and printall_error_2.txt. |
Yeah it's the same and I see why it didn't fix, can you try: #1132 |
A similar error is thrown: error_3.txt and printall_error_3.txt. |
The MWE is fixed on latest main. Now I get a related error, which seems to be due to using Enzyme, CUDA, Atomix, StaticArrays, LinearAlgebra
struct HarmonicAngle{K, D}
k::K
θ0::D
end
Base.zero(::HarmonicAngle{K, D}) where {K, D} = HarmonicAngle(zero(K), zero(D))
Base.:+(a1::HarmonicAngle, a2::HarmonicAngle) = HarmonicAngle(a1.k + a2.k, a1.θ0 + a2.θ0)
function f(a::HarmonicAngle, coords_i, coords_j, coords_k)
vec_ji = coords_i - coords_j
vec_jk = coords_k - coords_j
θ = acos(dot(vec_ji, vec_jk) / (norm(vec_ji) * norm(vec_jk)))
return (a.k / 2) * (θ - a.θ0) ^ 2
end
function kernel!(energy, coords_var, is_var, js_var, ks_var, inters_var)
coords = CUDA.Const(coords_var)
is = CUDA.Const(is_var)
js = CUDA.Const(js_var)
ks = CUDA.Const(ks_var)
inters = CUDA.Const(inters_var)
inter_i = (blockIdx().x - 1) * blockDim().x + threadIdx().x
@inbounds if inter_i <= length(is)
i, j, k = is[inter_i], js[inter_i], ks[inter_i]
pe = f(inters[inter_i], coords[i], coords[j], coords[k])
Atomix.@atomic :monotonic energy[1] += pe
end
return nothing
end
function grad_kernel!(energy, d_energy, coords, d_coords, is, js, ks, inters, d_inters)
Enzyme.autodiff_deferred(
Enzyme.Reverse,
kernel!,
Const,
Duplicated(energy, d_energy),
Duplicated(coords, d_coords),
Const(is),
Const(js),
Const(ks),
Duplicated(inters, d_inters),
)
return nothing
end
pe_vec = CuArray([0.0])
d_pe_vec = CuArray([1.0])
coords = CuArray([
SVector(1.0, 1.0, 1.0),
SVector(2.0, 2.1, 2.0),
SVector(3.0, 3.2, 3.3),
SVector(4.0, 4.1, 4.5),
])
d_coords = zero(coords)
is = CuArray([1, 2])
js = CuArray([2, 3])
ks = CuArray([3, 4])
inters = CuArray([
HarmonicAngle(100.0, deg2rad(90.0)),
HarmonicAngle(100.0, deg2rad(90.0)),
])
d_inters = CuArray([
HarmonicAngle(0.0, 0.0),
HarmonicAngle(0.0, 0.0),
])
CUDA.@sync @cuda threads=128 kernel!(pe_vec, coords, is, js, ks, inters) # Works
CUDA.@sync @cuda threads=128 grad_kernel!(
pe_vec, d_pe_vec, coords, d_coords, is, js, ks, inters, d_inters) |
I'm not sure if Enzyme_jll v0.0.93 is valid with Enzyme.jl main (4329953) since the Project.toml hasn't been bumped. However if I jump the gun and try it then I get a new error with the above code, might be a problem with
|
And the printall_error.txt. |
I am on Julia 1.9.2, Enzyme main (31012f8), CUDA 4.4.1, Atomix 0.1.0, StaticArrays 1.6.5. The following used to work but now errors:
The error.txt and printall_error.txt are attached.
The text was updated successfully, but these errors were encountered: