This is an automated email from the ASF dual-hosted git repository.

marin-ma pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gluten.git


The following commit(s) were added to refs/heads/main by this push:
     new 13ac7e49d3 [GLUTEN-11828][VL] Add cuda device detection (#11830)
13ac7e49d3 is described below

commit 13ac7e49d36503f347c405b45394c7a585bcb2f9
Author: Rong Ma <[email protected]>
AuthorDate: Wed Aug 5 16:34:34 2026 +0100

    [GLUTEN-11828][VL] Add cuda device detection (#11830)
---
 cpp/velox/compute/VeloxBackend.cc | 46 +++++++++++++++++++++++++--------------
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/cpp/velox/compute/VeloxBackend.cc 
b/cpp/velox/compute/VeloxBackend.cc
index 0d45559f0e..3b735601a1 100644
--- a/cpp/velox/compute/VeloxBackend.cc
+++ b/cpp/velox/compute/VeloxBackend.cc
@@ -120,6 +120,16 @@ ThreadManager* veloxThreadManagerFactory(const 
std::string& kind, std::unique_pt
 void veloxThreadManagerReleaser(ThreadManager* threadManager) {
   delete threadManager;
 }
+
+bool hasCudaDevice() {
+#ifdef GLUTEN_ENABLE_GPU
+  int count = 0;
+  cudaError_t err = cudaGetDeviceCount(&count);
+  return err == cudaSuccess && count > 0;
+#else
+  return false;
+#endif
+}
 } // namespace
 
 void VeloxBackend::init(
@@ -195,22 +205,26 @@ void VeloxBackend::init(
 
 #ifdef GLUTEN_ENABLE_GPU
   if (backendConf_->get<bool>(kCudfEnabled, kCudfEnabledDefault)) {
-    
configureGpuTaskConcurrency(backendConf_->get<uint32_t>(kCudfConcurrentGpuTasks,
 kCudfConcurrentGpuTasksDefault));
-    std::unordered_map<std::string, std::string> options = {
-        {velox::cudf_velox::CudfConfig::kCudfEnabled, "true"},
-        {velox::cudf_velox::CudfConfig::kCudfDebugEnabled, 
backendConf_->get(kDebugCudf, kDebugCudfDefault)},
-        {velox::cudf_velox::CudfConfig::kCudfMemoryResource,
-         backendConf_->get(kCudfMemoryResource, kCudfMemoryResourceDefault)},
-        {velox::cudf_velox::CudfConfig::kCudfMemoryPercent,
-         backendConf_->get(kCudfMemoryPercent, kCudfMemoryPercentDefault)},
-        {velox::cudf_velox::CudfConfig::kCudfAllowCpuFallback,
-         backendConf_->get(kCudfAllowCpuFallback, 
kCudfAllowCpuFallbackDefault)}};
-    auto& cudfConfig = velox::cudf_velox::CudfConfig::getInstance();
-    cudfConfig.initialize(std::move(options));
-    velox::cudf_velox::registerCudf();
-    
velox::exec::Operator::registerOperator(std::make_unique<CudfVectorStreamOperatorTranslator>());
-    velox::cudf_velox::registerSparkFunctions("");
-    velox::cudf_velox::registerSparkAggregateFunctions("");
+    if (hasCudaDevice()) {
+      
configureGpuTaskConcurrency(backendConf_->get<uint32_t>(kCudfConcurrentGpuTasks,
 kCudfConcurrentGpuTasksDefault));
+      std::unordered_map<std::string, std::string> options = {
+          {velox::cudf_velox::CudfConfig::kCudfEnabled, "true"},
+          {velox::cudf_velox::CudfConfig::kCudfDebugEnabled, 
backendConf_->get(kDebugCudf, kDebugCudfDefault)},
+          {velox::cudf_velox::CudfConfig::kCudfMemoryResource,
+           backendConf_->get(kCudfMemoryResource, kCudfMemoryResourceDefault)},
+          {velox::cudf_velox::CudfConfig::kCudfMemoryPercent,
+           backendConf_->get(kCudfMemoryPercent, kCudfMemoryPercentDefault)},
+          {velox::cudf_velox::CudfConfig::kCudfAllowCpuFallback,
+           backendConf_->get(kCudfAllowCpuFallback, 
kCudfAllowCpuFallbackDefault)}};
+      auto& cudfConfig = velox::cudf_velox::CudfConfig::getInstance();
+      cudfConfig.initialize(std::move(options));
+      velox::cudf_velox::registerCudf();
+      
velox::exec::Operator::registerOperator(std::make_unique<CudfVectorStreamOperatorTranslator>());
+      velox::cudf_velox::registerSparkFunctions("");
+      velox::cudf_velox::registerSparkAggregateFunctions("");
+    } else {
+      LOG(WARNING) << "No Cuda device found. Skip Cudf initialization.";
+    }
   }
 #endif
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to