| 80 | // ---------------------------------------------------------------------------------------- |
| 81 | |
| 82 | void synchronize_stream(cudaStream_t stream) |
| 83 | { |
| 84 | #if !defined CUDA_VERSION |
| 85 | #error CUDA_VERSION not defined |
| 86 | #elif CUDA_VERSION >= 9020 && CUDA_VERSION < 11000 |
| 87 | // We will stop using this alternative version with cuda V11, hopefully the bug in |
| 88 | // cudaStreamSynchronize is fixed by then. |
| 89 | // |
| 90 | // This should be pretty much the same as cudaStreamSynchronize, which for some |
| 91 | // reason makes training freeze in some cases. |
| 92 | // (see https://github.com/davisking/dlib/issues/1513) |
| 93 | while (true) |
| 94 | { |
| 95 | cudaError_t err = cudaStreamQuery(stream); |
| 96 | switch (err) |
| 97 | { |
| 98 | case cudaSuccess: return; // now we are synchronized |
| 99 | case cudaErrorNotReady: break; // continue waiting |
| 100 | default: CHECK_CUDA(err); // unexpected error: throw |
| 101 | } |
| 102 | } |
| 103 | #else // CUDA_VERSION |
| 104 | CHECK_CUDA(cudaStreamSynchronize(stream)); |
| 105 | #endif // CUDA_VERSION |
| 106 | } |
| 107 | |
| 108 | void gpu_data:: |
| 109 | wait_for_transfer_to_finish() const |
no outgoing calls
no test coverage detected