From 9b2f4919ee8d6a4c9d8254b4786d7e1d6e64ceec Mon Sep 17 00:00:00 2001 From: Ian Date: Sun, 1 Mar 2020 19:33:16 -0500 Subject: [PATCH 1/2] includ cuda/cuda.jl during precompile, even if cuda isn't detected --- src/Flux.jl | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/Flux.jl b/src/Flux.jl index 78670e65..8fb0f406 100644 --- a/src/Flux.jl +++ b/src/Flux.jl @@ -39,24 +39,14 @@ include("data/Data.jl") include("deprecations.jl") +include(joinpath(@__DIR__, "cuda/cuda.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." + 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 From 7555e488c626e45b9e0b4d91e56ecb6775384b06 Mon Sep 17 00:00:00 2001 From: Ian Date: Sun, 1 Mar 2020 19:40:03 -0500 Subject: [PATCH 2/2] tweaks --- src/Flux.jl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Flux.jl b/src/Flux.jl index 8fb0f406..5afa1fc0 100644 --- a/src/Flux.jl +++ b/src/Flux.jl @@ -39,11 +39,10 @@ include("data/Data.jl") include("deprecations.jl") -include(joinpath(@__DIR__, "cuda/cuda.jl")) - +include("cuda/cuda.jl") function __init__() - use_cuda[] = CuArrays.functional() # Can be overridden after load with Flux.use_cuda[] = false + 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."