Skip to content
This repository was archived by the owner on Mar 12, 2021. It is now read-only.

Commit 455e24c

Browse files
committed
Defer initializing deps to actual run time.
1 parent c3d02fc commit 455e24c

File tree

11 files changed

+1707
-1666
lines changed

11 files changed

+1707
-1666
lines changed

.gitlab-ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ image: ubuntu:bionic
55

66
variables:
77
JULIA_DEBUG: 'CuArrays'
8-
JULIA_CUDA_VERBOSE: 'true'
98
CI_APT_INSTALL: 'libgomp1'
109
NVIDIA_VISIBLE_DEVICES: 'all'
1110
NVIDIA_DRIVER_CAPABILITIES: 'compute,utility'

Manifest.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@ version = "3.1.0"
3434

3535
[[CUDAdrv]]
3636
deps = ["CEnum", "CUDAapi", "Printf"]
37-
git-tree-sha1 = "01e90fa34e25776bc7c8661183d4519149ebfe59"
37+
git-tree-sha1 = "cdf9a88aae8f05df1b78b049ffafbdc6d41a650e"
38+
repo-rev = "ab4d8e3f449b71104c57f827c67567c34c04a5ff"
39+
repo-url = "https://github.com/JuliaGPU/CUDAdrv.jl.git"
3840
uuid = "c5f51814-7f29-56b8-a69c-e4d8f6be1fde"
3941
version = "6.0.0"
4042

4143
[[CUDAnative]]
4244
deps = ["Adapt", "BinaryProvider", "CEnum", "CUDAapi", "CUDAdrv", "DataStructures", "InteractiveUtils", "LLVM", "Libdl", "MacroTools", "Pkg", "Printf", "TimerOutputs"]
43-
git-tree-sha1 = "5beaa8e6a8fb65003b7b2555a73e7666468b22f6"
44-
repo-rev = "46d5331"
45+
git-tree-sha1 = "3dd3ef011ea2a8f5b0e915588f3c2a3cfd68aadd"
46+
repo-rev = "11146e91cb3bd1f86c32b936abc25dea10c7e6cc"
4547
repo-url = "https://github.com/JuliaGPU/CUDAnative.jl.git"
4648
uuid = "be33ccc6-a3ff-5ff2-a52e-74243cff1e17"
4749
version = "2.10.2"
@@ -79,6 +81,7 @@ uuid = "929cbde3-209d-540e-8aea-75f648917ca0"
7981
version = "1.3.3"
8082

8183
[[LibGit2]]
84+
deps = ["Printf"]
8285
uuid = "76f85450-5226-5b5a-8eaa-529ad045b433"
8386

8487
[[Libdl]]
@@ -114,7 +117,7 @@ uuid = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
114117
version = "1.1.0"
115118

116119
[[Pkg]]
117-
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "Test", "UUIDs"]
120+
deps = ["Dates", "LibGit2", "Libdl", "Logging", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"]
118121
uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
119122

120123
[[Printf]]

src/CuArrays.jl

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -49,43 +49,15 @@ include("deprecated.jl")
4949

5050
## initialization
5151

52-
const __initialized__ = Ref(false)
53-
functional() = __initialized__[]
52+
function __init__()
53+
# package integrations
54+
@require ForwardDiff="f6369f11-7733-5829-9624-2563aa707210" include("forwarddiff.jl")
5455

55-
export has_cudnn, has_cutensor
56-
has_cudnn() = Libdl.dlopen_e(CUDNN.libcudnn[]) !== C_NULL
57-
has_cutensor() = Libdl.dlopen_e(CUTENSOR.libcutensor[]) !== C_NULL
56+
__init_memory__()
5857

59-
function __init__()
60-
precompiling = ccall(:jl_generating_output, Cint, ()) != 0
61-
silent = parse(Bool, get(ENV, "JULIA_CUDA_SILENT", "false")) || precompiling
62-
verbose = parse(Bool, get(ENV, "JULIA_CUDA_VERBOSE", "false"))
63-
64-
# if any dependent GPU package failed, expect it to have logged an error and bail out
65-
if !CUDAdrv.functional() || !CUDAnative.functional()
66-
verbose && @warn "CuArrays.jl did not initialize because CUDAdrv.jl or CUDAnative.jl failed to"
67-
return
68-
end
69-
70-
try
71-
__init_bindeps__(silent=silent, verbose=verbose)
72-
73-
# package integrations
74-
@require ForwardDiff="f6369f11-7733-5829-9624-2563aa707210" include("forwarddiff.jl")
75-
76-
__init_memory__()
77-
78-
__initialized__[] = true
79-
catch ex
80-
# don't actually fail to keep the package loadable
81-
if !silent
82-
if verbose
83-
@error "CuArrays.jl failed to initialize" exception=(ex, catch_backtrace())
84-
else
85-
@info "CuArrays.jl failed to initialize and will be unavailable (set JULIA_CUDA_SILENT or JULIA_CUDA_VERBOSE to silence or expand this message)"
86-
end
87-
end
88-
end
58+
# NOTE: we only perform minimal initialization here that does not require CUDA or a GPU.
59+
# most of the actual initialization is deferred to run time:
60+
# see bindeps.jl for initialization of CUDA binary dependencies.
8961
end
9062

9163
end # module

0 commit comments

Comments
 (0)