Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cudaErrorStreamCaptureUnsupported in cudagraph in multi-threads #2888

Closed
lix19937 opened this issue Apr 19, 2023 · 6 comments
Closed

cudaErrorStreamCaptureUnsupported in cudagraph in multi-threads #2888

lix19937 opened this issue Apr 19, 2023 · 6 comments
Labels
triaged Issue has been triaged by maintainers

Comments

@lix19937
Copy link

lix19937 commented Apr 19, 2023

Description

When I use cudagraph in multi-threads(CPU threads), each thread has preprocess (default stream, with cudaDeviceSynchronize), and infer(create stream, not default stream), cudagraph only capture enqueueV2 .

Now it report error: cuda error code=900 cudaErrorStreamCaptureUnsupported. cudaDeviceSynchronize()


Question

In the case of 1 GPU and multiple CPU threads, if I call cudaDeviceSynchronize() from one CPU thread, will it wait for other CPU threads to complete their work on the GPU device ?

And A-thread(CPU) cudaDeviceSynchronize will break the B-thread(CPU) graph, so it report error code=900 ?

Thanks !

@nvpohanh
Copy link
Collaborator

Could you try capturing using cudaStreamCaptureModeThreadLocal mode?
See: https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__TYPES.html#group__CUDART__TYPES_1g24ae5ae00cc50614957ff8eba43e560e

@lix19937
Copy link
Author

@nvpohanh yes I has set
GpuErrChk(cudaStreamBeginCapture(mStream, cudaStreamCaptureModeThreadLocal)); or
GpuErrChk(cudaStreamBeginCapture(mStream, cudaStreamCaptureModeGlobal)); both error

@nvpohanh
Copy link
Collaborator

I see... then it seems that cudaDeviceSynchronize() will break cuda stream capture regardless of the modes.

Is it possible to replace the cudaDeviceSynchronize() with something else?

@zerollzeng zerollzeng added the triaged Issue has been triaged by maintainers label Apr 20, 2023
@lix19937
Copy link
Author

lix19937 commented May 4, 2023

@nvpohanh Now I use cudaStreamSynchronize(0) replace of cudaDeviceSynchronize() , and no error report. Now closed, thanks

@lix19937 lix19937 closed this as completed May 5, 2023
@lix19937 lix19937 reopened this May 10, 2023
@lix19937
Copy link
Author

@nvpohanh sometimes, error still exist, cuda error code=900 cudaErrorStreamCaptureUnsupported. cudaStreamSynchronize(0)

@lix19937
Copy link
Author

lix19937 commented Apr 2, 2024

Fixed, closed.

@lix19937 lix19937 closed this as completed Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triaged Issue has been triaged by maintainers
Projects
None yet
Development

No branches or pull requests

3 participants