cossio / RestrictedBoltzmannMachines.jl

Train and sample Restricted Boltzmann machines in Julia
MIT License
15 stars 3 forks source link

CUDA doesn't support falses #20

Closed cossio closed 1 year ago

cossio commented 1 year ago

This line:

https://github.com/cossio/RestrictedBoltzmannMachines.jl/blob/c6622d4b316988cc6b18021f7ed03887762604ce/src/train/pcd.jl#L29

gives errors with CUDA, because BitArray are not supported on the GPU (the falses is the culprit). Here is an example:

julia> cu(randn(5,5)) .+ falses(5,5)
ERROR: GPU compilation of kernel #broadcast_kernel#17(CUDA.CuKernelContext, CuDeviceMatrix{Float32, 1}, Base.Broadcast.Broadcasted{CUDA.CuArrayStyle{2}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}, typeof(+), Tuple{Base.Broadcast.Extruded{CuDeviceMatrix{Float32, 1}, Tuple{Bool, Bool}, Tuple{Int64, Int64}}, Base.Broadcast.Extruded{BitMatrix, Tuple{Bool, Bool}, Tuple{Int64, Int64}}}}, Int64) failed
KernelError: passing and using non-bitstype argument

Argument 4 to your kernel function is of type Base.Broadcast.Broadcasted{CUDA.CuArrayStyle{2}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}, typeof(+), Tuple{Base.Broadcast.Extruded{CuDeviceMatrix{Float32, 1}, Tuple{Bool, Bool}, Tuple{Int64, Int64}}, Base.Broadcast.Extruded{BitMatrix, Tuple{Bool, Bool}, Tuple{Int64, Int64}}}}, which is not isbits:
  .args is of type Tuple{Base.Broadcast.Extruded{CuDeviceMatrix{Float32, 1}, Tuple{Bool, Bool}, Tuple{Int64, Int64}}, Base.Broadcast.Extruded{BitMatrix, Tuple{Bool, Bool}, Tuple{Int64, Int64}}} which is not isbits.
    .2 is of type Base.Broadcast.Extruded{BitMatrix, Tuple{Bool, Bool}, Tuple{Int64, Int64}} which is not isbits.
      .x is of type BitMatrix which is not isbits.
        .chunks is of type Vector{UInt64} which is not isbits.