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

Memory management #14

@pearcemc

Description

@pearcemc

I was wondering if there was a way to modify the behaviour of CUBLAS.jl functions so that when a pointer is overridden in julia, the appropriate CUDArt.free(ptr) is called.

using CUBLAS
using CUDArt

N = 50
T = 193
V = 60 * 10^3
K = 100

hA = map(Float32, randn(N*T, K));
hS = map(Float32, randn(K, V));

dA = CudaArray(hA)
dS = CudaArray(hS)

for i in 1:10
    dY = CUBLAS.gemm('N', 'N', dA, dS)
end

Results in an out of memory error:

julia> for i in 1:10
           dY = CUBLAS.gemm('N', 'N', dA, dS)
       end
WARNING: CUDA error triggered from:

 [inlined code] from error.jl:26
 in checkerror at /home/mcp50/.julia/v0.5/CUDArt/src/libcudart-6.5.jl:15
 [inlined code] from essentials.jl:111
 in cudaMalloc at /home/mcp50/.julia/v0.5/CUDArt/src/../gen-6.5/gen_libcudart.jl:260
 in malloc at /home/mcp50/.julia/v0.5/CUDArt/src/pointer.jl:36
 in call at /home/mcp50/.julia/v0.5/CUDArt/src/arrays.jl:99
 [inlined code] from /home/mcp50/.julia/v0.5/CUDArt/src/arrays.jl:110
 in gemm at /home/mcp50/.julia/v0.5/CUBLAS/src/blas.jl:928
 [inlined code] from float.jl:24
 in gemm at /home/mcp50/.julia/v0.5/CUBLAS/src/blas.jl:936
 [inlined code] from none:2
 in anonymous at no file:0ERROR: "out of memory"
 [inlined code] from essentials.jl:111
 in checkerror at /home/mcp50/.julia/v0.5/CUDArt/src/libcudart-6.5.jl:16
 [inlined code] from essentials.jl:111
 in cudaMalloc at /home/mcp50/.julia/v0.5/CUDArt/src/../gen-6.5/gen_libcudart.jl:260
 in malloc at /home/mcp50/.julia/v0.5/CUDArt/src/pointer.jl:36
 in call at /home/mcp50/.julia/v0.5/CUDArt/src/arrays.jl:99
 [inlined code] from /home/mcp50/.julia/v0.5/CUDArt/src/arrays.jl:110
 in gemm at /home/mcp50/.julia/v0.5/CUBLAS/src/blas.jl:928
 [inlined code] from float.jl:24
 in gemm at /home/mcp50/.julia/v0.5/CUBLAS/src/blas.jl:936
 [inlined code] from none:2
 in anonymous at no file:0

It is straightforward to call CUDArt.free in the loop, so this is a 'nice to have' point.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions