cuda: get driver version after props (#12707)

Users on Windows without GPUs are reporting errors relating to
cudaDriverGetVersion with the device set to -1.  This ensures we only grab the
driver once we're enumerating actual devices.
This commit is contained in:
Daniel Hiltgen
2025-10-20 10:57:27 -07:00
committed by GitHub
parent d245dffed8
commit 5d22953ba7
2 changed files with 19 additions and 15 deletions

View File

@@ -4159,7 +4159,6 @@ ggml_backend_reg_t ggml_backend_cuda_reg() {
if (!initialized) {
ggml_backend_cuda_reg_context * ctx = new ggml_backend_cuda_reg_context;
int driverVersion = 0;
CUDA_CHECK(cudaDriverGetVersion(&driverVersion));
for (int i = 0; i < ggml_cuda_info().device_count; i++) {
ggml_backend_cuda_device_context * dev_ctx = new ggml_backend_cuda_device_context;
@@ -4177,6 +4176,9 @@ ggml_backend_reg_t ggml_backend_cuda_reg() {
dev_ctx->major = prop.major;
dev_ctx->minor = prop.minor;
if (driverVersion == 0) {
CUDA_CHECK(cudaDriverGetVersion(&driverVersion));
}
dev_ctx->driver_major = driverVersion / 1000;
dev_ctx->driver_minor = (driverVersion - (dev_ctx->driver_major * 1000)) / 10;
dev_ctx->integrated = prop.integrated;