Skip to content

Lock CUDNN descriptor cache lookups. - #1430

Merged
maleadt merged 1 commit into
masterfrom
tb/cudnn_lock
Mar 4, 2022
Merged

maleadt merged 1 commit into
masterfrom
tb/cudnn_lock

Conversation

@maleadt

@maleadt maleadt commented Mar 4, 2022

Copy link
Copy Markdown
Member

Fixes #1421 (comment).

Ideally the CUDNN wrappers should integrate with the HandleCache machinery we use for the other libraries, but this is a quick fix to get things working.

cc @DhairyaLGandhi @ToucheSir

@codecov

codecov Bot commented Mar 4, 2022 •

Copy link
Copy Markdown

Codecov Report

Merging #1430 (0452682) into master (12da74b) will decrease coverage by 0.70%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1430      +/-   ##
==========================================
- Coverage   77.32%   76.62%   -0.71%     
==========================================
  Files         121      121              
  Lines        9186     9188       +2     
==========================================
- Hits         7103     7040      -63     
- Misses       2083     2148      +65     
Impacted Files Coverage Δ
lib/cudnn/convolution.jl 69.31% <100.00%> (+1.08%) ⬆️
lib/cudnn/descriptors.jl 100.00% <100.00%> (ø)
lib/cudnn/CUDNN.jl 40.00% <0.00%> (-35.81%) ⬇️
lib/cublas/CUBLAS.jl 50.00% <0.00%> (-25.90%) ⬇️
src/utilities.jl 68.91% <0.00%> (-4.06%) ⬇️
lib/cudadrv/CUDAdrv.jl 61.66% <0.00%> (-3.34%) ⬇️
lib/cudadrv/module/linker.jl 68.75% <0.00%> (-3.13%) ⬇️
lib/cudadrv/state.jl 77.84% <0.00%> (-2.28%) ⬇️
lib/cudadrv/events.jl 93.87% <0.00%> (-2.05%) ⬇️
lib/cudadrv/memory.jl 80.75% <0.00%> (-1.04%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 12da74b...0452682. Read the comment docs.

@maleadt
maleadt merged commit 146ad00 into master Mar 4, 2022
@maleadt
maleadt deleted the tb/cudnn_lock branch March 4, 2022 12:51
@DhairyaLGandhi

Copy link
Copy Markdown
Member

Thank you! I'm going to try with the training now. I'm assuming the locking can mean multiple threads accessing the dictionaries now have to wait to get the lock? Do you think there would be a significant performance hit with that?

@maleadt

maleadt commented Mar 4, 2022

Copy link
Copy Markdown
Member Author

I'm assuming the locking can mean multiple threads accessing the dictionaries now have to wait to get the lock? Do you think there would be a significant performance hit with that?

Correct. I don't expect this to be very costly; if it is, we can always introduce a task-local cache.

@DhairyaLGandhi

Copy link
Copy Markdown
Member

Seems like with this branch I get

    nested task error: Unhandled Task ERROR: CUDNNError: CUDNN_STATUS_EXECUTION_FAILED (code 8)
Stacktrace:
  [1] throw_api_error(res::CUDA.CUDNN.cudnnStatus_t)
    @ CUDA.CUDNN ~/.julia/packages/CUDA/qzBIx/lib/cudnn/error.jl:22
  [2] macro expansion
    @ ~/.julia/packages/CUDA/qzBIx/lib/cudnn/error.jl:35 [inlined]
  [3] cudnnActivationForward(handle::Ptr{Nothing}, activationDesc::CUDA.CUDNN.cudnnActivationDescriptor, alpha::Base.RefValue{Floa
t32}, xDesc::CUDA.CUDNN.cudnnTensorDescriptor, x::CuArray{Float32, 4, CUDA.Mem.DeviceBuffer}, beta::Base.RefValue{Float32}, yDesc:
:CUDA.CUDNN.cudnnTensorDescriptor, y::CuArray{Float32, 4, CUDA.Mem.DeviceBuffer})
    @ CUDA.CUDNN ~/.julia/packages/CUDA/qzBIx/lib/utils/call.jl:26
  [4] #cudnnActivationForwardAD#1215
    @ ~/.julia/packages/CUDA/qzBIx/lib/cudnn/activation.jl:48 [inlined]
  [5] #cudnnActivationForwardWithDefaults#1214
    @ ~/.julia/packages/CUDA/qzBIx/lib/cudnn/activation.jl:42 [inlined]
  [6] #cudnnActivationForward!#1211
    @ ~/.julia/packages/CUDA/qzBIx/lib/cudnn/activation.jl:22 [inlined]
  [7] #67
    @ ~/.julia/packages/NNlibCUDA/IeeBk/src/cudnn/activations.jl:13 [inlined]
  [8] materialize(bc::Base.Broadcast.Broadcasted{CUDA.CuArrayStyle{4}, Nothing, typeof(relu), Tuple{CuArray{Float32, 4, CUDA.Mem.D
eviceBuffer}}})
    @ NNlibCUDA ~/.julia/packages/NNlibCUDA/IeeBk/src/cudnn/activations.jl:30

with ResNet-50. I haven't dug very deep into this yet.

maleadt added a commit that referenced this pull request Mar 11, 2022
simonbyrne pushed a commit to simonbyrne/CUDA.jl that referenced this pull request Nov 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

@cudnnDescriptor is not threadsafe

2 participants