From 3e3c377beac85b9f7fc874d66ad2c42f563eb487 Mon Sep 17 00:00:00 2001 From: "Dinh Truong (SlncTrZ)" <46520299+SlncTrZ@users.noreply.github.com> Date: Tue, 12 May 2026 16:11:12 +0700 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20resolve=20#4152=20=E2=80=94=20[Bug]?= =?UTF-8?q?=20C++=20API=20and=20core=20tests=20fail=20with=20"assert=203?= =?UTF-8?q?=20=3D=3D=200"=20across=20all=20GPUs=20and=20CUDA=2013.x=20vers?= =?UTF-8?q?ions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #4152 Signed-off-by: Dinh Truong (SlncTrZ) <46520299+SlncTrZ@users.noreply.github.com> --- core/conversion/conversionctx/ConversionCtx.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/conversion/conversionctx/ConversionCtx.cpp b/core/conversion/conversionctx/ConversionCtx.cpp index a566f5eb51..1fe319763b 100644 --- a/core/conversion/conversionctx/ConversionCtx.cpp +++ b/core/conversion/conversionctx/ConversionCtx.cpp @@ -44,6 +44,11 @@ ConversionCtx::ConversionCtx(BuilderSettings build_settings) util::logging::get_logger().get_is_colored_output_on()) { // TODO: Support FP16 and FP32 from JIT information if (settings.device.gpu_id) { + int device_count; + cudaError_t err = cudaGetDeviceCount(&device_count); + TORCHTRT_CHECK(err == cudaSuccess, "Failed to get CUDA device count"); + TORCHTRT_CHECK(device_count > 0, "No CUDA devices available but gpu_id specified: " << settings.device.gpu_id); + TORCHTRT_CHECK(settings.device.gpu_id < device_count, "gpu_id " << settings.device.gpu_id << " out of range, available devices: " << device_count); TORCHTRT_CHECK( cudaSetDevice(settings.device.gpu_id) == cudaSuccess, "Unable to set gpu id: " << settings.device.gpu_id); } From 1bfb0ad210facf654afabcbbf1d5e1c2e684105a Mon Sep 17 00:00:00 2001 From: "Dinh Truong (SlncTrZ)" <46520299+SlncTrZ@users.noreply.github.com> Date: Tue, 12 May 2026 16:11:13 +0700 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20resolve=20#4152=20=E2=80=94=20[Bug]?= =?UTF-8?q?=20C++=20API=20and=20core=20tests=20fail=20with=20"assert=203?= =?UTF-8?q?=20=3D=3D=200"=20across=20all=20GPUs=20and=20CUDA=2013.x=20vers?= =?UTF-8?q?ions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #4152 Signed-off-by: Dinh Truong (SlncTrZ) <46520299+SlncTrZ@users.noreply.github.com> --- core/version.h | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 core/version.h diff --git a/core/version.h b/core/version.h new file mode 100644 index 0000000000..b76fa03a12 --- /dev/null +++ b/core/version.h @@ -0,0 +1,7 @@ +#pragma once + +#ifdef CUDA_VERSION +#define TORCHTRT_CUDA_13_WORKAROUND (CUDA_VERSION >= 13000) +#else +#define TORCHTRT_CUDA_13_WORKAROUND 0 +#endif