From 435a736af116ad974b635febb214bfe63dd72f83 Mon Sep 17 00:00:00 2001 From: Jonathan Newnham Date: Thu, 25 May 2023 11:39:33 +1200 Subject: [PATCH 1/3] Fix windows cuda build * add ggml-cuda.cu * sort out linker paths using CUDA_PATH --- sys/Cargo.toml | 2 ++ sys/build.rs | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/sys/Cargo.toml b/sys/Cargo.toml index e8d78ad..5bbc6dd 100644 --- a/sys/Cargo.toml +++ b/sys/Cargo.toml @@ -17,6 +17,8 @@ include = [ "whisper.cpp/ggml.h", "whisper.cpp/ggml-opencl.c", "whisper.cpp/ggml-opencl.h", + "whisper.cpp/ggml-cuda.cu", + "whisper.cpp/ggml-cuda.h", "whisper.cpp/LICENSE", "whisper.cpp/whisper.cpp", "whisper.cpp/whisper.h", diff --git a/sys/build.rs b/sys/build.rs index 98b0512..86cc7ed 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -34,11 +34,20 @@ fn main() { #[cfg(feature = "cuda")] { println!("cargo:rustc-link-lib=cublas"); - println!("cargo:rustc-link-lib=culibos"); println!("cargo:rustc-link-lib=cudart"); println!("cargo:rustc-link-lib=cublasLt"); - println!("cargo:rustc-link-search=/usr/local/cuda/lib64"); - println!("cargo:rustc-link-search=/opt/cuda/lib64"); + #[cfg(target_os = "windows")] + { + let cuda_path = PathBuf::from(env::var("CUDA_PATH").unwrap()).join("lib/x64"); + println!("cargo:rustc-link-search={}", cuda_path.display()); + } + #[cfg(not(target_os = "windows"))] + { + println!("cargo:rustc-link-lib=culibos"); + println!("cargo:rustc-link-search=/usr/local/cuda/lib64"); + println!("cargo:rustc-link-search=/opt/cuda/lib64"); + + } } println!("cargo:rerun-if-changed=wrapper.h"); From ffa9655a066314e806dfcd5f9b0d00d262716105 Mon Sep 17 00:00:00 2001 From: jnnnnn Date: Thu, 25 May 2023 15:05:05 +1200 Subject: [PATCH 2/3] fmt --- sys/build.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/sys/build.rs b/sys/build.rs index 86cc7ed..02461a5 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -46,7 +46,6 @@ fn main() { println!("cargo:rustc-link-lib=culibos"); println!("cargo:rustc-link-search=/usr/local/cuda/lib64"); println!("cargo:rustc-link-search=/opt/cuda/lib64"); - } } println!("cargo:rerun-if-changed=wrapper.h"); From a4e303ef3f48510b2e41b6d307e3ddaac43eb606 Mon Sep 17 00:00:00 2001 From: jnnnnn Date: Mon, 29 May 2023 19:17:48 +1200 Subject: [PATCH 3/3] cfg_if --- sys/build.rs | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/sys/build.rs b/sys/build.rs index 02461a5..170a1d4 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -36,16 +36,15 @@ fn main() { println!("cargo:rustc-link-lib=cublas"); println!("cargo:rustc-link-lib=cudart"); println!("cargo:rustc-link-lib=cublasLt"); - #[cfg(target_os = "windows")] - { - let cuda_path = PathBuf::from(env::var("CUDA_PATH").unwrap()).join("lib/x64"); - println!("cargo:rustc-link-search={}", cuda_path.display()); - } - #[cfg(not(target_os = "windows"))] - { - println!("cargo:rustc-link-lib=culibos"); - println!("cargo:rustc-link-search=/usr/local/cuda/lib64"); - println!("cargo:rustc-link-search=/opt/cuda/lib64"); + cfg_if! { + if #[cfg(target_os = "windows")] { + let cuda_path = PathBuf::from(env::var("CUDA_PATH").unwrap()).join("lib/x64"); + println!("cargo:rustc-link-search={}", cuda_path.display()); + } else { + println!("cargo:rustc-link-lib=culibos"); + println!("cargo:rustc-link-search=/usr/local/cuda/lib64"); + println!("cargo:rustc-link-search=/opt/cuda/lib64"); + } } } println!("cargo:rerun-if-changed=wrapper.h");