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

Commit

Permalink
Merge pull request #588 from JuliaGPU/tb/windows_versions
Browse files Browse the repository at this point in the history
Use correct versions for library discovery.
  • Loading branch information
maleadt committed Feb 11, 2020
2 parents 93493bc + a0367f4 commit b3df55f
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 76 deletions.
48 changes: 33 additions & 15 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
include:
- 'https://raw.githubusercontent.com/JuliaGPU/gitlab-ci/master/templates/v6.yml'

image: nvidia/cuda:10.1-cudnn7-devel
image: ubuntu:bionic

variables:
JULIA_CUDA_VERBOSE: 'true'
NVIDIA_VISIBLE_DEVICES: 'all'
NVIDIA_DRIVER_CAPABILITIES: 'compute,utility'


# Julia versions
Expand Down Expand Up @@ -37,29 +39,56 @@ julia:nightly:
# https://developer.nvidia.com/rdp/cudnn-archive

cuda:10.1:
image: nvidia/cuda:10.1-cudnn7-devel
extends:
- .julia:1.3
- .test
variables:
JULIA_CUDA_VERSION: '10.1'
tags:
- nvidia

cuda:10.0:
image: nvidia/cuda:10.0-cudnn7-devel
extends:
- .julia:1.3
- .test
variables:
JULIA_CUDA_VERSION: '10.0'
tags:
- nvidia

cuda:9.2:
image: nvidia/cuda:9.2-cudnn7-devel
extends:
- .julia:1.3
- .test
variables:
JULIA_CUDA_VERSION: '9.2'
tags:
- nvidia

# NOTE: CUDA 9.0 is broken

cuda:local:
extends:
- .julia:1.3
- .test
image: nvidia/cuda:10.1-devel-ubuntu18.04
variables:
JULIA_CUDA_USE_BINARYBUILDER: 'false'
tags:
- nvidia

cuda:none:
extends:
- .julia:1.3
- .test
variables:
JULIA_CUDA_USE_BINARYBUILDER: 'false'
script:
- julia --project -e 'using Pkg;
Pkg.instantiate();
Pkg.build();
Pkg.API.precompile()'


# hardware platforms

Expand Down Expand Up @@ -101,17 +130,6 @@ pool:split:
variables:
CUARRAYS_MEMORY_POOL: 'split'

precompile:
extends:
- .julia:1.3
- .test
image: ubuntu:bionic
script:
- julia --project -e 'using Pkg;
Pkg.instantiate();
Pkg.build();
Pkg.API.precompile()'

debug:
extends:
- .julia:1.3
Expand Down
12 changes: 7 additions & 5 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ version = "0.2.0"

[[CUDAapi]]
deps = ["Libdl", "Logging"]
git-tree-sha1 = "d9614968b9a13df433870115acff20f41e7b400a"
git-tree-sha1 = "d7ceadd8f821177d05b897c0517e94633db535fe"
uuid = "3895d2a7-ec45-59b8-82bb-cfc6a382f9b3"
version = "3.0.0"
version = "3.1.0"

[[CUDAdrv]]
deps = ["CEnum", "CUDAapi", "Printf"]
Expand All @@ -39,10 +39,12 @@ uuid = "c5f51814-7f29-56b8-a69c-e4d8f6be1fde"
version = "6.0.0"

[[CUDAnative]]
deps = ["Adapt", "CEnum", "CUDAapi", "CUDAdrv", "DataStructures", "InteractiveUtils", "LLVM", "Libdl", "Printf", "TimerOutputs"]
git-tree-sha1 = "59d6c3e313b874abc718f7d6ad02ea604f96db14"
deps = ["Adapt", "BinaryProvider", "CEnum", "CUDAapi", "CUDAdrv", "DataStructures", "InteractiveUtils", "LLVM", "Libdl", "Pkg", "Printf", "TimerOutputs"]
git-tree-sha1 = "52884ca07509c515d12fddc94e82270a2766702a"
repo-rev = "tb/binarybuilder"
repo-url = "https://github.com/JuliaGPU/CUDAnative.jl.git"
uuid = "be33ccc6-a3ff-5ff2-a52e-74243cff1e17"
version = "2.10.0"
version = "2.10.2"

[[DataStructures]]
deps = ["InteractiveUtils", "OrderedCollections"]
Expand Down
59 changes: 3 additions & 56 deletions src/CuArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ using Requires

## source code includes

include("bindeps.jl")

# core array functionality
include("memory.jl")
include("array.jl")
Expand Down Expand Up @@ -66,62 +68,7 @@ function __init__()
end

try
# discover libraries
toolkit = find_toolkit()
for name in ("cublas", "cusparse", "cusolver", "cufft", "curand", "cudnn", "cutensor")
mod = getfield(CuArrays, Symbol(uppercase(name)))
lib = Symbol("lib$name")
handle = getfield(mod, lib)

# on Windows, the library name is version dependent
if Sys.iswindows()
cuda = CUDAnative.version()
suffix = cuda >= v"10.1" ? "$(cuda.major)" : "$(cuda.major)$(cuda.minor)"
handle[] = "$(name)$(Sys.WORD_SIZE)_$(suffix)"
end

# check if we can't find the library
if Libdl.dlopen_e(handle[]) == C_NULL
path = find_cuda_library(name, CUDAnative.prefix(), [CUDAnative.version()])
if path !== nothing
handle[] = path
end
end
end

# library dependencies
CUBLAS.version()
CUSPARSE.version()
CUSOLVER.version()
CUFFT.version()
CURAND.version()
# CUDNN and CUTENSOR are optional

# library compatibility
if has_cutensor()
cutensor = CUTENSOR.version()
if cutensor < v"1"
silent || @warn("CuArrays.jl only supports CUTENSOR 1.0 or higher")
end

cuda = CUDAnative.version()
cutensor_cuda = CUTENSOR.cuda_version()
if cutensor_cuda.major != cuda.major || cutensor_cuda.minor != cuda.minor
silent || @warn("You are using CUTENSOR $cutensor for CUDA $cutensor_cuda with CUDA toolkit $cuda; these might be incompatible.")
end
end
if has_cudnn()
cudnn = CUDNN.version()
if cudnn < v"7.6"
silent || @warn("CuArrays.jl only supports CUDNN v7.6 or higher")
end

cuda = CUDAnative.version()
cudnn_cuda = CUDNN.cuda_version()
if cudnn_cuda.major != cuda.major || cudnn_cuda.minor != cuda.minor
silent || @warn("You are using CUDNN $cudnn for CUDA $cudnn_cuda with CUDA toolkit $cuda; these might be incompatible.")
end
end
__init_bindeps__(silent=silent, verbose=verbose)

# package integrations
@require ForwardDiff="f6369f11-7733-5829-9624-2563aa707210" include("forwarddiff.jl")
Expand Down
66 changes: 66 additions & 0 deletions src/bindeps.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# discovering binary CUDA dependencies

function __init_bindeps__(; silent=false, verbose=false)
# discover libraries
for (name,version) in (("cublas", CUDAnative.version()),
("cusparse", CUDAnative.version()),
("cusolver", CUDAnative.version()),
("cufft", CUDAnative.version()),
("curand", CUDAnative.version()),
("cudnn", v"7"),
("cutensor", v"1"))
mod = getfield(CuArrays, Symbol(uppercase(name)))
handle = getfield(mod, Symbol("lib$name"))

# on Windows, the library name is version dependent
if Sys.iswindows()
cuda = CUDAnative.version()
suffix = cuda >= v"10.1" ? "$(cuda.major)" : "$(cuda.major)$(cuda.minor)"
handle[] = "$(name)$(Sys.WORD_SIZE)_$(suffix)"
end

if CUDAnative.uses_artifacts[]
artifact = first(CUDAnative.prefix())
handle[] = CUDAnative.get_library(Sys.iswindows() ? handle[] : name, artifact)
else
path = find_cuda_library(name, CUDAnative.prefix(), [version])
if path !== nothing
handle[] = path
end
end
end

# library dependencies
CUBLAS.version()
CUSPARSE.version()
CUSOLVER.version()
CUFFT.version()
CURAND.version()
# CUDNN and CUTENSOR are optional

# library compatibility
if has_cutensor()
cutensor = CUTENSOR.version()
if cutensor < v"1"
silent || @warn("CuArrays.jl only supports CUTENSOR 1.0 or higher")
end

cuda = CUDAnative.version()
cutensor_cuda = CUTENSOR.cuda_version()
if cutensor_cuda.major != cuda.major || cutensor_cuda.minor != cuda.minor
silent || @warn("You are using CUTENSOR $cutensor for CUDA $cutensor_cuda with CUDA toolkit $cuda; these might be incompatible.")
end
end
if has_cudnn()
cudnn = CUDNN.version()
if cudnn < v"7.6"
silent || @warn("CuArrays.jl only supports CUDNN v7.6 or higher")
end

cuda = CUDAnative.version()
cudnn_cuda = CUDNN.cuda_version()
if cudnn_cuda.major != cuda.major || cudnn_cuda.minor != cuda.minor
silent || @warn("You are using CUDNN $cudnn for CUDA $cudnn_cuda with CUDA toolkit $cuda; these might be incompatible.")
end
end
end

0 comments on commit b3df55f

Please sign in to comment.