Skip to content

Commit 6ea6ec9

Browse files
committed
Added check for CUDA
Signed-off-by: Scott Thornton <[email protected]>
1 parent 13e5c69 commit 6ea6ec9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

libs/qec/lib/decoders/plugins/trt_decoder/trt_decoder.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ class trt_decoder : public decoder {
124124
// Validate parameters
125125
trt_decoder_internal::validate_trt_decoder_parameters(params);
126126

127+
// Check if CUDA is available
128+
check_cuda();
129+
127130
bool has_engine_path = params.contains("engine_load_path");
128131

129132
if (has_engine_path) {
@@ -275,6 +278,20 @@ class trt_decoder : public decoder {
275278
}
276279
}
277280

281+
private:
282+
void check_cuda() {
283+
int deviceCount = 0;
284+
cudaError_t error = cudaGetDeviceCount(&deviceCount);
285+
if (error != cudaSuccess || deviceCount == 0) {
286+
throw std::runtime_error(
287+
"CUDA is not available or no CUDA-capable devices found. "
288+
"TensorRT decoder requires CUDA to be installed and at least one "
289+
"CUDA-capable GPU. Error: " +
290+
std::string(cudaGetErrorString(error)));
291+
}
292+
}
293+
294+
public:
278295
CUDAQ_EXTENSION_CUSTOM_CREATOR_FUNCTION(
279296
trt_decoder, static std::unique_ptr<decoder> create(
280297
const cudaqx::tensor<uint8_t> &H,

0 commit comments

Comments
 (0)