Steps to Reproduce
- Run any Livekit SDK that uses the latest FFI server (version 0.12.33)
- Be on a CUDA compatible environment with cuda installed.
- Use CUDA api BEFORE using any LiveKit (works perfectly fine)
- Do something that causes the LiveKit client to create the FFI server (for example create a VideoStream Track)
- Use CUDA api again -> It will crash, saying "Invalid CUDA context."
The error happens when the FFI server finds CUDA and tries to initialize its own context. It does it regardless that you need Nvidia encoding or not. The specific function that causes it is the following:
bool NvidiaVideoEncoderFactory::IsSupported() {
// Check if the CUDA context can be initialized.
auto cu_context = std::make_unique<livekit::CudaContext>();
if (!cu_context->Initialize()) {
std::cout << "Failed to initialize CUDA context." << std::endl;
return false;
}
std::cout << "Nvidia Encoder is supported." << std::endl;
return true;
}
The moment you see the print "Nvidia Encoder/Decoder is supported", you can be sure that your code is doomed to crash at the next CUDA api call.
All of this buggy behavior comes from @cloudwebrtc's commit #638
The current quick solution is to just downgrade to the latest version that doesn't use the version 0.12.33 FFI Server, which is the one that introduces this bug.
Steps to Reproduce
The error happens when the FFI server finds CUDA and tries to initialize its own context. It does it regardless that you need Nvidia encoding or not. The specific function that causes it is the following:
The moment you see the print "Nvidia Encoder/Decoder is supported", you can be sure that your code is doomed to crash at the next CUDA api call.
All of this buggy behavior comes from @cloudwebrtc's commit #638
The current quick solution is to just downgrade to the latest version that doesn't use the version 0.12.33 FFI Server, which is the one that introduces this bug.