Copilot commented on code in PR #11830:
URL: https://github.com/apache/gluten/pull/11830#discussion_r3713841690
##########
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 hasCudaRuntimeAndDevice() {
+#ifdef GLUTEN_ENABLE_GPU
+ int count = 0;
+ cudaError_t err = cudaGetDeviceCount(&count);
+ return err == cudaSuccess && count > 0;
Review Comment:
`cudaGetDeviceCount` can trigger CUDA driver initialization and be
relatively expensive. If `VeloxBackend::init` can be called multiple times per
process, consider memoizing the result (e.g., `static std::once_flag` + cached
bool) so this detection is performed at most once.
##########
cpp/velox/compute/VeloxBackend.cc:
##########
@@ -194,7 +204,8 @@ void VeloxBackend::init(
#endif
#ifdef GLUTEN_ENABLE_GPU
- if (backendConf_->get<bool>(kCudfEnabled, kCudfEnabledDefault)) {
+ const auto enableCudf = backendConf_->get<bool>(kCudfEnabled,
kCudfEnabledDefault) && hasCudaRuntimeAndDevice();
+ if (enableCudf) {
Review Comment:
This change can silently disable cuDF even when `kCudfEnabled` is set, which
may be confusing operationally. Consider emitting a warning/info log when
`kCudfEnabled` is true but `hasCudaRuntimeAndDevice()` is false (include the
CUDA error code/message if available) so misconfiguration or missing
drivers/devices are diagnosable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]