NVIDIALibraries.jl was designed to allow full low level access by providing wrapper functions to the CUDA Toolkit libraries.
This package is a Julia library written for Julia 1.0 and onwards.
NVIDIALibraries.jl defines C definitions and functions as they would appear in a C project.
- CUDA library (NVIDIALibraries.CUDA)
- CUDA Runtime library (NVIDIALibraries.CUDARuntime)
- CUBLAS library (NVIDIALibraries.CUBLAS)
- 8.0
- 9.0
- 9.1
- 9.2
- 10.0
- 10.1
Enter the Pkg REPL-mode from the Julia REPL by using the key ].
Now add the Julia package by using the add command:
(v1.0) pkg> add https://github.com/Blackbody-Research/NVIDIALibraries.jl
The CUDAArray datatype uses the CUDA Runtime library to allocate and free GPU device memory.
CUDAArrays can be constructed with initial values by passing a Julia array to cuda_allocate(::Array).
In addition, CUDAArrays can be explicitly freed by calling deallocate!(::CUDAArray).
Use cuModuleLoad() to load kernel by filename.
example_module = cuModuleLoad("example.ptx")Alternatively, you can use the CUDA JIT linker to compile a PTX file into a cubin format.
jit_options = [CU_JIT_TARGET, CU_JIT_OPTIMIZATION_LEVEL]
jit_option_values = [CU_TARGET_COMPUTE_70, Cuint(4)]
jit_link_state = cuLinkCreate(2, jit_options, jit_option_values)
cuLinkAddFile(jit_link_state, CU_JIT_INPUT_PTX, "example.ptx")
cubin_array = cuLinkComplete(jit_link_state)
# cleanup CUDA JIT linker
result = cuLinkDestroy(jit_link_state)
@assert (result == CUDA_SUCCESS) ("cuLinkDestroy() error: " * cuGetErrorString(result))Then, load the kernel from the new cubin image as a CUDA module.
example_module = cuModuleLoadData(Base.unsafe_convert(Ptr{Nothing}, cubin_array))The update command in Pkg REPL-mode can be used to add recent commits made to NVIDIALibraries.jl:
(v1.0) pkg> update NVIDIALibrariesThe license can be found in LICENSE.