Calling CUBLAS GEMM in Julia 0.6


#1

I had some code using CUBLAS.jl for matrix multiplication in the GPU.

I updated some packages, and now my code is breaking apparently because CUDAdrv.jl does not support OwnedPtr anymore, and CUBLAS.jl relies heavily on OwnedPtrs to move data around.

Since it seems like CUBLAS.jl is being phased out, I decided to switch to CuArrays.jl, but I couldn’t get it to work with Julia 0.6 without building from source, and I also got some errors with the Julia nightly build.

Given this information, what do you think is the fastest way to update my code to call GEMM from CUBLAS? I would prefer to stay in Julia 0.6, but I’m open to moving to Julia 0.7 if CuArrays.jl is stable enough.


#2

CuArrays.jl is definitely the way to go, on both - Julia 0.6 and 0.7: not only this package is the only supported way to use CUBLAS, but it also provides a lot of other high-performance features like broadcasting and custom kernels.

Right now the easiest way is indeed to build Julia 0.6 from source. It might sound complicated, but in fact it’s quite easy (even for users of your package) and has to be done only once.

On the other hand, development of some key packages in JuliaGPU organization have already been moved to Julia 0.7, so if you don’t have many dependencies (which might not be 0.7-compatible yet), it may be an equally good alternative. Feel free to post errors you are getting with the nightly build.


#3

Thanks @dfdx. I can speak of a happy built and use of CuArrays.jl with Julia 0.6.


#4

Hi,
I can’t get CuArrays.jl built in julia 0.7. Is it still being maintained regularly?

julia> using CuArrays
[ Info: Precompiling module CuArrays
ERROR: LoadError: CuArrays.jl has not been built, please run Pkg.build("CuArrays").
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] top-level scope at none:0
 [3] include at ./boot.jl:317 [inlined]
 [4] include_relative(::Module, ::String) at ./loading.jl:1075
 [5] include(::Module, ::String) at ./sysimg.jl:29
 [6] top-level scope at none:0
 [7] eval at ./boot.jl:319 [inlined]
 [8] eval(::Expr) at ./client.jl:394
 [9] top-level scope at ./none:3 [inlined]
 [10] top-level scope at ./<missing>:0
in expression starting at /home/yunlong/.julia7/packages/CuArrays/eSZG/src/CuArrays.jl:11
ERROR: Failed to precompile CuArrays to /home/yunlong/.julia7/compiled/v0.7/CuArrays/7YFE.ji.
Stacktrace:
 [1] error at ./error.jl:33 [inlined]
 [2] compilecache(::Base.PkgId) at ./loading.jl:1205
 [3] _require(::Base.PkgId) at ./loading.jl:1007
 [4] require(::Base.PkgId) at ./loading.jl:879
 [5] require(::Module, ::Symbol) at ./loading.jl:874

(v0.7) pkg> build CuArrays
ERROR: MethodError: no method matching haskey(::Nothing, ::String)
Closest candidates are:
  haskey(::Base.Iterators.Pairs, ::Any) at iterators.jl:246
  haskey(::Dict, ::Any) at dict.jl:555
  haskey(::Base.ImmutableDict, ::Any) at dict.jl:740
  ...
Stacktrace:
 [1] _get_deps!(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}, ::Array{Base.UUID,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:362
 [2] _get_deps!(::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}, ::Array{Base.UUID,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:366 (repeats 3 times)
 [3] #build#51(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:400
 [4] build at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:377 [inlined]
 [5] do_build!(::Pkg.Types.Context, ::Array{Union{Pkg.Types.VersionRange, String, Pkg.REPLMode.Command, Pkg.REPLMode.Option, Pkg.REPLMode.Rev},1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/REPLMode.jl:730
 [6] #invokelatest#1 at ./essentials.jl:670 [inlined]
 [7] invokelatest at ./essentials.jl:669 [inlined]
 [8] do_cmd!(::Array{Union{Pkg.Types.VersionRange, String, Pkg.REPLMode.Command, Pkg.REPLMode.Option, Pkg.REPLMode.Rev},1}, ::REPL.LineEditREPL) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/REPLMode.jl:264
 [9] #do_cmd#8(::Bool, ::Function, ::REPL.LineEditREPL, ::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/REPLMode.jl:224
 [10] do_cmd at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/REPLMode.jl:221 [inlined]
 [11] (::getfield(Pkg.REPLMode, Symbol("##27#30")){REPL.LineEditREPL,REPL.LineEdit.Prompt})(::REPL.LineEdit.MIState, ::Base.GenericIOBuffer{Array{UInt8,1}}, ::Bool) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/REPLMode.jl:979
 [12] top-level scope at none:0



#5

I would not expect many commits to CuArrays.jl while Belgium is still in the world cup :stuck_out_tongue: