mirror of
https://github.com/huggingface/candle.git
synced 2025-06-17 02:58:50 +00:00
Removing cuda default.
Seems very important for a lot of exploring users usually on laptop without GPUs. Adding more README instructions in a follow up.
This commit is contained in:
@ -2,13 +2,15 @@
|
|||||||
members = [
|
members = [
|
||||||
"candle-core",
|
"candle-core",
|
||||||
"candle-examples",
|
"candle-examples",
|
||||||
"candle-kernels",
|
|
||||||
"candle-hub",
|
"candle-hub",
|
||||||
"candle-nn",
|
"candle-nn",
|
||||||
"candle-pyo3",
|
|
||||||
"candle-transformers",
|
"candle-transformers",
|
||||||
"candle-wasm-example",
|
"candle-wasm-example",
|
||||||
]
|
]
|
||||||
|
exclude = [
|
||||||
|
"candle-kernels",
|
||||||
|
"candle-pyo3",
|
||||||
|
]
|
||||||
|
|
||||||
[profile.release-with-debug]
|
[profile.release-with-debug]
|
||||||
inherits = "release"
|
inherits = "release"
|
||||||
|
@ -34,6 +34,6 @@ zip = { version = "0.6.6", default-features=false }
|
|||||||
anyhow = { version = "1", features = ["backtrace"] }
|
anyhow = { version = "1", features = ["backtrace"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["cuda"]
|
default = []
|
||||||
cuda = ["dep:cudarc", "dep:candle-kernels"]
|
cuda = ["dep:cudarc", "dep:candle-kernels"]
|
||||||
mkl = ["dep:libc", "dep:intel-mkl-src"]
|
mkl = ["dep:libc", "dep:intel-mkl-src"]
|
||||||
|
@ -28,6 +28,6 @@ tokenizers = { version = "0.13.3", default-features=false, features=["onig"] }
|
|||||||
wav = "1.0.0"
|
wav = "1.0.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["cuda"]
|
default = []
|
||||||
cuda = ["candle/cuda", "candle-nn/cuda", "candle-transformers/cuda"]
|
cuda = ["candle/cuda", "candle-nn/cuda", "candle-transformers/cuda"]
|
||||||
mkl = ["dep:intel-mkl-src", "candle/mkl", "candle-nn/mkl", "candle-transformers/mkl"]
|
mkl = ["dep:intel-mkl-src", "candle/mkl", "candle-nn/mkl", "candle-transformers/mkl"]
|
||||||
|
@ -495,10 +495,19 @@ struct Args {
|
|||||||
|
|
||||||
impl Args {
|
impl Args {
|
||||||
fn build_model_and_tokenizer(&self) -> Result<(BertModel, Tokenizer)> {
|
fn build_model_and_tokenizer(&self) -> Result<(BertModel, Tokenizer)> {
|
||||||
|
#[cfg(feature = "cuda")]
|
||||||
|
let default_device = Device::new_cuda(0)?;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "cuda"))]
|
||||||
|
let default_device = {
|
||||||
|
println!("Running on CPU, to run on GPU, run this example with `--features cuda`");
|
||||||
|
Device::Cpu
|
||||||
|
};
|
||||||
|
|
||||||
let device = if self.cpu {
|
let device = if self.cpu {
|
||||||
Device::Cpu
|
Device::Cpu
|
||||||
} else {
|
} else {
|
||||||
Device::new_cuda(0)?
|
default_device
|
||||||
};
|
};
|
||||||
let default_model = "sentence-transformers/all-MiniLM-L6-v2".to_string();
|
let default_model = "sentence-transformers/all-MiniLM-L6-v2".to_string();
|
||||||
let default_revision = "refs/pr/21".to_string();
|
let default_revision = "refs/pr/21".to_string();
|
||||||
|
@ -119,10 +119,19 @@ struct Args {
|
|||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
|
#[cfg(feature = "cuda")]
|
||||||
|
let default_device = Device::new_cuda(0)?;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "cuda"))]
|
||||||
|
let default_device = {
|
||||||
|
println!("Running on CPU, to run on GPU, run this example with `--features cuda`");
|
||||||
|
Device::Cpu
|
||||||
|
};
|
||||||
let device = if args.cpu {
|
let device = if args.cpu {
|
||||||
Device::Cpu
|
Device::Cpu
|
||||||
} else {
|
} else {
|
||||||
Device::new_cuda(0)?
|
default_device
|
||||||
};
|
};
|
||||||
|
|
||||||
let start = std::time::Instant::now();
|
let start = std::time::Instant::now();
|
||||||
|
@ -133,10 +133,20 @@ fn main() -> Result<()> {
|
|||||||
use tokenizers::Tokenizer;
|
use tokenizers::Tokenizer;
|
||||||
|
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
|
#[cfg(feature = "cuda")]
|
||||||
|
let default_device = Device::new_cuda(0)?;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "cuda"))]
|
||||||
|
let default_device = {
|
||||||
|
println!("Running on CPU, to run on GPU, run this example with `--features cuda`");
|
||||||
|
Device::Cpu
|
||||||
|
};
|
||||||
|
|
||||||
let device = if args.cpu {
|
let device = if args.cpu {
|
||||||
Device::Cpu
|
Device::Cpu
|
||||||
} else {
|
} else {
|
||||||
Device::new_cuda(0)?
|
default_device
|
||||||
};
|
};
|
||||||
let config = Config::config_7b();
|
let config = Config::config_7b();
|
||||||
let cache = model::Cache::new(!args.no_kv_cache, &config, &device);
|
let cache = model::Cache::new(!args.no_kv_cache, &config, &device);
|
||||||
|
@ -41,10 +41,18 @@ fn main() -> Result<()> {
|
|||||||
use tokenizers::Tokenizer;
|
use tokenizers::Tokenizer;
|
||||||
|
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
#[cfg(feature = "cuda")]
|
||||||
|
let default_device = Device::new_cuda(0)?;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "cuda"))]
|
||||||
|
let default_device = {
|
||||||
|
println!("Running on CPU, to run on GPU, run this example with `--features cuda`");
|
||||||
|
Device::Cpu
|
||||||
|
};
|
||||||
let device = if args.cpu {
|
let device = if args.cpu {
|
||||||
Device::Cpu
|
Device::Cpu
|
||||||
} else {
|
} else {
|
||||||
Device::new_cuda(0)?
|
default_device
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut tokenizer = Tokenizer::from_file(args.tokenizer).map_err(E::msg)?;
|
let mut tokenizer = Tokenizer::from_file(args.tokenizer).map_err(E::msg)?;
|
||||||
|
@ -257,10 +257,20 @@ struct Args {
|
|||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let args = Args::parse();
|
let args = Args::parse();
|
||||||
|
|
||||||
|
#[cfg(feature = "cuda")]
|
||||||
|
let default_device = Device::new_cuda(0)?;
|
||||||
|
|
||||||
|
#[cfg(not(feature = "cuda"))]
|
||||||
|
let default_device = {
|
||||||
|
println!("Running on CPU, to run on GPU, run this example with `--features cuda`");
|
||||||
|
Device::Cpu
|
||||||
|
};
|
||||||
|
|
||||||
let device = if args.cpu {
|
let device = if args.cpu {
|
||||||
Device::Cpu
|
Device::Cpu
|
||||||
} else {
|
} else {
|
||||||
Device::new_cuda(0)?
|
default_device
|
||||||
};
|
};
|
||||||
let default_model = "openai/whisper-tiny.en".to_string();
|
let default_model = "openai/whisper-tiny.en".to_string();
|
||||||
let path = std::path::PathBuf::from(default_model.clone());
|
let path = std::path::PathBuf::from(default_model.clone());
|
||||||
|
@ -19,6 +19,6 @@ intel-mkl-src = {version="0.8.1", optional=true, features = ["mkl-dynamic-lp64-i
|
|||||||
anyhow = { version = "1", features = ["backtrace"] }
|
anyhow = { version = "1", features = ["backtrace"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["cuda"]
|
default = []
|
||||||
cuda = ["candle/cuda"]
|
cuda = ["candle/cuda"]
|
||||||
mkl = ["dep:intel-mkl-src", "candle/mkl"]
|
mkl = ["dep:intel-mkl-src", "candle/mkl"]
|
||||||
|
@ -21,5 +21,5 @@ pyo3 = { version = "0.19.0", features = ["extension-module"] }
|
|||||||
half = { version = "2.3.1", features = ["num-traits"] }
|
half = { version = "2.3.1", features = ["num-traits"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["cuda"]
|
default = []
|
||||||
cuda = ["candle/cuda"]
|
cuda = ["candle/cuda"]
|
||||||
|
@ -20,6 +20,6 @@ rand = "0.8.5"
|
|||||||
wav = "1.0.0"
|
wav = "1.0.0"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["cuda"]
|
default = []
|
||||||
cuda = ["candle/cuda", "candle-nn/cuda"]
|
cuda = ["candle/cuda", "candle-nn/cuda"]
|
||||||
mkl = ["dep:intel-mkl-src", "candle/mkl", "candle-nn/mkl"]
|
mkl = ["dep:intel-mkl-src", "candle/mkl", "candle-nn/mkl"]
|
||||||
|
@ -14,8 +14,8 @@ readme = "README.md"
|
|||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
candle = { path = "../candle-core", default-features=false }
|
candle = { path = "../candle-core" }
|
||||||
candle-nn = { path = "../candle-nn", default-features=false }
|
candle-nn = { path = "../candle-nn" }
|
||||||
wasm-bindgen = "0.2.87"
|
wasm-bindgen = "0.2.87"
|
||||||
getrandom = { version = "0.2", features = ["js"] }
|
getrandom = { version = "0.2", features = ["js"] }
|
||||||
tokenizers = { version = "0.13.3", default-features=false, features=["unstable_wasm"] }
|
tokenizers = { version = "0.13.3", default-features=false, features=["unstable_wasm"] }
|
||||||
|
Reference in New Issue
Block a user