Skip to content

Commit

Permalink
Merge pull request #491 from denizyuret/dy/comp542
Browse files Browse the repository at this point in the history
Use CuArrays.usage_limit[] to improve stability
  • Loading branch information
denizyuret authored Sep 20, 2019
2 parents ed1bae9 + 1d83431 commit 58c906f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/Knet.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,17 @@ dir(path...) = joinpath(dirname(@__DIR__),path...)
# See if we have a gpu at initialization:
function __init__()
try
r = gpu(true)
r >= 0 && AutoGrad.set_gc_function(knetgcnode)
#@info(r >= 0 ? "Knet using GPU $r" : "No GPU found, Knet using the CPU")
dev = gpu(true)
if dev >= 0
CuArrays.usage_limit[] = gpufree() - 100_000_000
AutoGrad.set_gc_function(knetgcnode)
@debug "Knet using GPU $dev"
else
@debug "No GPU found, Knet using the CPU"
end
catch e
gpu(false)
#@warn("Knet using the CPU: $e")
@warn "Knet cannot use the GPU: $e"
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/cuarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

if find_cuda_library("cuda", tk) != nothing # has_cuda()
try
using CuArrays: CuPtr, unsafe_free!
using CuArrays: CuArrays, CuPtr, unsafe_free!, usage_limit
import CuArrays: CuArray
catch ex
@warn "CUDA is installed, but CuArrays.jl fails to load" exception=(ex,catch_backtrace())
Expand Down
3 changes: 2 additions & 1 deletion test/binary.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
include("header.jl")
#using Dates
#date(x)=(join(stdout,[Dates.format(Dates.now(),"HH:MM:SS"), x,'\n'],' '); flush(stdout))
date(x)=(println(round(Int,time())%3600, ':', x); flush(stdout))
time0 = time()
date(x)=(println(round(Int,time()-time0), ':', x); flush(stdout))
macro dbg(_x); end
#macro dbg(_x); :(@show $(esc(_x))); end

Expand Down

2 comments on commit 58c906f

@denizyuret
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/3693

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v1.2.6 -m "<description of version>" 58c906f1eefcef4d3b9ed2e95cf6db62e10f612c
git push origin v1.2.6

Please sign in to comment.