Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions onnxruntime/test/common/cuda_op_test_utils.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#ifdef USE_CUDA
#if defined(USE_CUDA) || defined(USE_NV)
#include "cuda_runtime_api.h"
#endif

Expand All @@ -13,7 +13,7 @@ int GetCudaArchitecture() {
// Usually, we test on a single GPU or multiple GPUs of same architecture, so it's fine to cache the result.
static int cuda_arch = -1;

#ifdef USE_CUDA
#if defined(USE_CUDA) || defined(USE_NV)
if (cuda_arch == -1) {
int current_device_id = 0;
cudaGetDevice(&current_device_id);
Expand Down
30 changes: 30 additions & 0 deletions onnxruntime/test/providers/nv_tensorrt_rtx/nv_basic_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "test/util/include/scoped_env_vars.h"
#include "test/common/trt_op_test_utils.h"
#include "test/common/random_generator.h"
#include "test/common/cuda_op_test_utils.h"
#include "test/providers/nv_tensorrt_rtx/test_nv_trt_rtx_ep_util.h"

#include <thread>
Expand All @@ -22,6 +23,27 @@ namespace onnxruntime {

namespace test {

// Helper function to check if GPU is Blackwell (SM 12.0+) or above
// Logs GPU compute capability and returns true if requirement is met
// Returns false if CUDA is unavailable or GPU is below SM 12.0
static bool IsBlackwellOrAbove() {
constexpr int kBlackwellMinCapability = 1200; // SM 12.0 = 12 * 100 + 0 * 10
int cuda_arch = GetCudaArchitecture();

// Check if CUDA is available
if (cuda_arch == -1) {
std::cout << "WARNING: CUDA is not available or failed to initialize" << std::endl;
return false;
}

// Log GPU compute capability
std::cout << "GPU Compute Capability: SM "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will print for each test case that using this function. It can be moved to GetCudaArchitecture to print only once.

<< cuda_arch / 100 << "." << (cuda_arch % 100) / 10
<< " (value: " << cuda_arch << ")" << std::endl;

return cuda_arch >= kBlackwellMinCapability;
}

TEST(NvExecutionProviderTest, ContextEmbedAndReload) {
PathString model_name = ORT_TSTR("nv_execution_provider_test.onnx");
PathString model_name_ctx = ORT_TSTR("nv_execution_provider_test_ctx.onnx");
Expand Down Expand Up @@ -442,6 +464,10 @@ TEST(NvExecutionProviderTest, DataTransfer) {
}

TEST(NvExecutionProviderTest, FP8CustomOpModel) {
if (!IsBlackwellOrAbove()) {
GTEST_SKIP() << "Test requires SM 12.0+ GPU (Blackwell+)";
}

PathString model_name = ORT_TSTR("nv_execution_provider_fp8_quantize_dequantize_test.onnx");
clearFileIfExists(model_name);
std::string graph_name = "nv_execution_provider_fp8_quantize_dequantize_graph";
Expand Down Expand Up @@ -509,6 +535,10 @@ TEST(NvExecutionProviderTest, FP8CustomOpModel) {
}

TEST(NvExecutionProviderTest, FP4CustomOpModel) {
if (!IsBlackwellOrAbove()) {
GTEST_SKIP() << "Test requires SM 12.0+ GPU (Blackwell+)";
}

PathString model_name = ORT_TSTR("nv_execution_provider_fp4_dynamic_quantize_test.onnx");
clearFileIfExists(model_name);
std::string graph_name = "nv_execution_provider_fp4_dynamic_quantize_graph";
Expand Down
Loading