includ cuda/cuda.jl during precompile, even if cuda isn't detected

This commit is contained in:
Ian 2020-03-01 19:33:16 -05:00
parent 3cf131b8de
commit 9b2f4919ee
1 changed files with 7 additions and 17 deletions

View File

@ -39,24 +39,14 @@ include("data/Data.jl")
include("deprecations.jl")
function __init__()
precompiling = ccall(:jl_generating_output, Cint, ()) != 0
# we don't want to include the CUDA module when precompiling,
# or we could end up replacing it at run time (triggering a warning)
precompiling && return
if !CuArrays.functional()
# nothing to do here, and either CuArrays or one of its dependencies will have warned
else
use_cuda[] = true
# FIXME: this functionality should be conditional at run time by checking `use_cuda`
# (or even better, get moved to CuArrays.jl as much as possible)
if CuArrays.has_cudnn()
include(joinpath(@__DIR__, "cuda/cuda.jl"))
else
@warn "CuArrays.jl did not find libcudnn. Some functionality will not be available."
function __init__()
use_cuda[] = CuArrays.functional() # Can be overridden after load with Flux.use_cuda[] = false
if CuArrays.functional()
if !CuArrays.has_cudnn()
@warn "CuArrays.jl found cuda, but did not find libcudnn. Some functionality will not be available."
end
end
end