From 913905028badc32a8283750c5342340113269865 Mon Sep 17 00:00:00 2001 From: Jeffrey Morgan Date: Mon, 5 May 2025 08:02:39 -0700 Subject: [PATCH] all: fix cgo compiler warnings on windows (#10563) --- discover/gpu_info_cudart.c | 8 ++++---- discover/gpu_info_nvcuda.c | 4 ++-- llama/llama.go | 1 + ml/backend/ggml/ggml/src/ggml.go | 1 + 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/discover/gpu_info_cudart.c b/discover/gpu_info_cudart.c index 03f15a2c3..79f19f27f 100644 --- a/discover/gpu_info_cudart.c +++ b/discover/gpu_info_cudart.c @@ -58,7 +58,7 @@ void cudart_init(char *cudart_lib_path, cudart_init_resp_t *resp) { LOG(resp->ch.verbose, "cudaSetDevice err: %d\n", ret); UNLOAD_LIBRARY(resp->ch.handle); resp->ch.handle = NULL; - if (ret == CUDA_ERROR_INSUFFICIENT_DRIVER) { + if (ret == CUDART_ERROR_INSUFFICIENT_DRIVER) { resp->err = strdup("your nvidia driver is too old or missing. If you have a CUDA GPU please upgrade to run ollama"); return; } @@ -168,9 +168,9 @@ void cudart_bootstrap(cudart_handle_t h, int i, mem_info_t *resp) { resp->free = memInfo.free; resp->used = memInfo.used; - LOG(h.verbose, "[%s] CUDA totalMem %lu\n", resp->gpu_id, resp->total); - LOG(h.verbose, "[%s] CUDA freeMem %lu\n", resp->gpu_id, resp->free); - LOG(h.verbose, "[%s] CUDA usedMem %lu\n", resp->gpu_id, resp->used); + LOG(h.verbose, "[%s] CUDA totalMem %llu\n", resp->gpu_id, resp->total); + LOG(h.verbose, "[%s] CUDA freeMem %llu\n", resp->gpu_id, resp->free); + LOG(h.verbose, "[%s] CUDA usedMem %llu\n", resp->gpu_id, resp->used); LOG(h.verbose, "[%s] Compute Capability %d.%d\n", resp->gpu_id, resp->major, resp->minor); } diff --git a/discover/gpu_info_nvcuda.c b/discover/gpu_info_nvcuda.c index 466e1ac24..636cba91c 100644 --- a/discover/gpu_info_nvcuda.c +++ b/discover/gpu_info_nvcuda.c @@ -193,8 +193,8 @@ void nvcuda_bootstrap(nvcuda_handle_t h, int i, mem_info_t *resp) { resp->total = memInfo.total; resp->free = memInfo.free; - LOG(h.verbose, "[%s] CUDA totalMem %lu mb\n", resp->gpu_id, resp->total / 1024 / 1024); - LOG(h.verbose, "[%s] CUDA freeMem %lu mb\n", resp->gpu_id, resp->free / 1024 / 1024); + LOG(h.verbose, "[%s] CUDA totalMem %llu mb\n", resp->gpu_id, resp->total / 1024 / 1024); + LOG(h.verbose, "[%s] CUDA freeMem %llu mb\n", resp->gpu_id, resp->free / 1024 / 1024); LOG(h.verbose, "[%s] Compute Capability %d.%d\n", resp->gpu_id, resp->major, resp->minor); diff --git a/llama/llama.go b/llama/llama.go index 5fce0a622..7f9f9549a 100644 --- a/llama/llama.go +++ b/llama/llama.go @@ -2,6 +2,7 @@ package llama /* #cgo CFLAGS: -std=c11 +#cgo windows CFLAGS: -Wno-dll-attribute-on-redeclaration #cgo CXXFLAGS: -std=c++17 #cgo CPPFLAGS: -I${SRCDIR}/llama.cpp/include #cgo CPPFLAGS: -I${SRCDIR}/llama.cpp/common diff --git a/ml/backend/ggml/ggml/src/ggml.go b/ml/backend/ggml/ggml/src/ggml.go index 678f55ca6..91f1f1ada 100644 --- a/ml/backend/ggml/ggml/src/ggml.go +++ b/ml/backend/ggml/ggml/src/ggml.go @@ -3,6 +3,7 @@ package ggml // #cgo CXXFLAGS: -std=c++17 // #cgo CPPFLAGS: -DNDEBUG -DGGML_USE_CPU // #cgo CPPFLAGS: -I${SRCDIR}/../include -I${SRCDIR}/ggml-cpu +// #cgo windows CFLAGS: -Wno-dll-attribute-on-redeclaration // #cgo windows LDFLAGS: -lmsvcrt -static -static-libgcc -static-libstdc++ // #include // #include "ggml-backend.h"