JuliaLang / PackageCompiler.jl

Compile your Julia Package
https://julialang.github.io/PackageCompiler.jl/dev/
MIT License
1.42k stars 189 forks source link

GPUCompiler problems. #896

Closed lpawela closed 3 months ago

lpawela commented 10 months ago

After compiling an app which uses CUDA.jl and moving to another machine I get

./test_comp/bin/TestCUDA 
fatal: error thrown and no exception handler available.
InitError(mod=:GPUCompiler, error=ErrorException("type Nothing has no field major"))
ijl_errorf at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/rtutils.c:77
ijl_has_no_field_error at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/rtutils.c:137
getproperty at ./Base.jl:37
__init__ at /tmp/TestCUDA/xxx/packages/GPUCompiler/U36Ed/src/GPUCompiler.jl:64
jfptr___init___56021.clone_1 at /solvers/test_comp/lib/julia/sys.so (unknown line)
_jl_invoke at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/gf.c:2758 [inlined]
ijl_apply_generic at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/gf.c:2940
jl_apply at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/julia.h:1880 [inlined]
jl_module_run_initializer at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/toplevel.c:75
_finish_julia_init at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/init.c:855
julia_init at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/init.c:804
ijl_init_with_image at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/jlapi.c:66 [inlined]
ijl_init_with_image at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/jlapi.c:55
ijl_init at /cache/build/builder-amdci4-4/julialang/julia-release-1-dot-9/src/jlapi.c:82
main at ./test_comp/bin/TestCUDA (unknown line)
unknown function (ip: 0x146198f87d8f)
__libc_start_main at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_start at ./test_comp/bin/TestCUDA (unknown line)

MWE Project.toml

name = "TestCUDA"
uuid = "721d7c47-4bfd-4d43-ae95-5398a80267cb"
version = "0.1.0"

[deps]
CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba"

src/TestCUDA.jl

module TestCUDA

using CUDA

function julia_main()::Cint
        a = CUDA.rand(100, 100)
        a * a
        return 0
end
end # module TestCUDA

Launch a clean instance of julia with JULIA_DEPOT_PATH=tmp julia, then install PackageCompiler and build app

]add PackageCompiler
julia> create_app(".", "test_comp", force=true)

Output of versioninfo()

julia> versioninfo()
Julia Version 1.9.4
Commit 8e5136fa297 (2023-11-14 08:46 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 20 × 12th Gen Intel(R) Core(TM) i7-12700KF
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, alderlake)
  Threads: 1 on 20 virtual cores
sjkelly commented 3 months ago

I think there is a string relocation issue from: https://github.com/JuliaGPU/GPUCompiler.jl/commit/c0c9ab7d2604c44dfb90a99332ba3eadad3679d7

cc @maleadt

maleadt commented 3 months ago

So Base.pkgversion isn't available (returns nothing) in compiled apps?

sjkelly commented 3 months ago

I think that is the case because the module comes from the sysimg instead. For example in the 1.10 REPL:

julia> using LinearAlgebra

julia> typeof(Base.pkgversion(LinearAlgebra))
Nothing
sjkelly commented 3 months ago

A proposed fix has been filed here: https://github.com/JuliaGPU/GPUCompiler.jl/pull/589

I am closing this since this is not likely a direct PackageCompiler issue.