How can I create a CUDA context?
The first call of CUDA is slow and I want to create the context before I launch my kernel.
How can I create a CUDA context? The first call of CUDA is slow
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The canonical way to force runtime API context establishment is to call
cudaFree(0). If you have multiple devices, callcudaSetDevice()with the ID of the device you want to establish a context on, thencudaFree(0)to establish the context.EDIT: Note that as of CUDA 5.0, it appears that the heuristics of context establishment are slightly different andcudaSetDevice()itself establishes context on the device is it called on. So the explicitcudaFree(0)call is no longer necessary (although it won’t hurt anything).