Skip to content

Commit

Permalink
When freeing memory, use the high-level device getter. (#2029)
Browse files Browse the repository at this point in the history
`current_device()` can throw an error when the current thread does
not have a context bound, and at the point we free memory there's
no guarantee that a context is bound: The preceding call to
`context()` only primes the *task* local state, and doesn't set
CUDA's *thread* local state. The latter is only set before any
API call that needs it, and `cuCtxGetDevice` is explicitly
exempt from that so that we can check whether a device is bound.
  • Loading branch information
maleadt authored Aug 16, 2023
1 parent 91c0dc0 commit 435ade3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/pool.jl
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ end
error("Trying to free $buf from an unrelated context")
end

dev = current_device()
dev = device()
if stream_ordered(dev)
# mark the pool as active
pool_mark(dev)
Expand Down

0 comments on commit 435ade3

Please sign in to comment.