Skip to content

Commit 0ef6c8c

Browse files
committed
fixed cuda build
1 parent a0f643b commit 0ef6c8c

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

llama-cpp-2/src/context/params.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
use std::fmt::Debug;
33
use std::num::NonZeroU32;
44

5-
use llama_cpp_sys_2;
6-
75
/// A rusty wrapper around `rope_scaling_type`.
86
#[repr(i8)]
97
#[derive(Copy, Clone, Debug, PartialEq, Eq)]

llama-cpp-sys-2/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ include = [
3333
"/llama.cpp/llama.h",
3434
"/llama.cpp/unicode.h",
3535
"/llama.cpp/unicode.cpp",
36+
"/llama.cpp/unicode-data.h",
37+
"/llama.cpp/unicode-data.h",
38+
"/llama.cpp/unicode-data.cpp",
3639
"/llama.cpp/ggml-common.h"
3740
]
3841

llama-cpp-sys-2/build.rs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::env;
2+
use std::ffi::OsStr;
23
use std::path::Path;
34
use std::path::PathBuf;
45

@@ -67,6 +68,12 @@ fn main() {
6768
.cuda(true)
6869
.flag("-arch=all")
6970
.file("llama.cpp/ggml-cuda.cu")
71+
.files(std::fs::read_dir("llama.cpp/ggml-cuda")
72+
.expect("failed to read 'llama.cpp/ggml-cuda'")
73+
.map(|e| e.expect("failed to ready entry").path())
74+
.filter(|p| p.extension().is_some_and(|it| it == OsStr::new("cu")))
75+
)
76+
.include("llama.cpp/ggml-cuda")
7077
.include("llama.cpp");
7178

7279
if ggml_cuda.get_compiler().is_like_msvc() {
@@ -75,9 +82,9 @@ fn main() {
7582
ggml_cuda.flag("-std=c++11").std("c++11");
7683
}
7784

78-
ggml.define("GGML_USE_CUBLAS", None);
79-
ggml_cuda.define("GGML_USE_CUBLAS", None);
80-
llama_cpp.define("GGML_USE_CUBLAS", None);
85+
ggml.define("GGML_USE_CUDA", None);
86+
ggml_cuda.define("GGML_USE_CUDA", None);
87+
llama_cpp.define("GGML_USE_CUDA", None);
8188
}
8289

8390
for build in [&mut ggml, &mut llama_cpp] {
@@ -177,7 +184,8 @@ fn main() {
177184
.include("llama.cpp")
178185
.std("c++11")
179186
.file("llama.cpp/llama.cpp")
180-
.file("llama.cpp/unicode.cpp");
187+
.file("llama.cpp/unicode.cpp")
188+
.file("llama.cpp/unicode-data.cpp");
181189

182190
// Remove debug log output from `llama.cpp`
183191
let is_release = env::var("PROFILE").unwrap() == "release";
@@ -193,18 +201,18 @@ fn main() {
193201
}
194202

195203
if let Some(ggml_cuda) = ggml_cuda {
196-
println!("compiling ggml-cuda");
204+
eprintln!("compiling ggml-cuda");
197205
ggml_cuda.compile("ggml-cuda");
198-
println!("compiled ggml-cuda");
206+
eprintln!("compiled ggml-cuda");
199207
}
200208

201-
println!("compiling ggml");
209+
eprintln!("compiling ggml");
202210
ggml.compile("ggml");
203-
println!("compiled ggml");
211+
eprintln!("compiled ggml");
204212

205-
println!("compiling llama");
213+
eprintln!("compiling llama");
206214
llama_cpp.compile("llama");
207-
println!("compiled llama");
215+
eprintln!("compiled llama");
208216

209217
let header = "llama.cpp/llama.h";
210218

0 commit comments

Comments
 (0)