[Solved] RuntimeError: CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling `cublasCreate(handle)`

Today, I encountered a speechless mistake and tossed it for a long time… I mentioned the feature network with Bert, but it didn’t work… I checked the size and found that it wasn’t, and later found that it wasn’t on CUDA

Specific error reporting

RuntimeError: Caught RuntimeError in replica 0 on device 0.
RuntimeError: CUDA error: CUBLAS_ STATUS_ ALLOC_ FAILED when calling `cublasCreate(handle)


ext_hashCodes.unsqueeze(1).repeat(1, B, 1)
#change to
ext_hashCodes.unsqueeze(1).repeat(1, B, 1).cuda()
#It's OK

Read More: