mirror of
https://github.com/huggingface/candle.git
synced 2025-06-17 19:18:50 +00:00
Add small customization to the build (#768)
* Add ability to override the compiler used by NVCC from an environment variable * Allow relative paths in CANDLE_FLASH_ATTN_BUILD_DIR * Add the compilation failure to the readme, with a possible solution * Adjust the error message, and remove the special handling of the relative paths
This commit is contained in:
11
README.md
11
README.md
@ -243,6 +243,17 @@ authentication token. See issue
|
|||||||
git submodule update --init
|
git submodule update --init
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Compiling with flash-attention fails
|
||||||
|
|
||||||
|
```
|
||||||
|
/usr/include/c++/11/bits/std_function.h:530:146: error: parameter packs not expanded with ‘...’:
|
||||||
|
```
|
||||||
|
|
||||||
|
This is a bug in gcc-11 triggered by the Cuda compiler. To fix this, install a different, supported gcc version - for example gcc-10, and specify the path to the compiler in the CANDLE_NVCC_CCBIN environment variable.
|
||||||
|
```
|
||||||
|
env CANDLE_NVCC_CCBIN=/usr/lib/gcc/x86_64-linux-gnu/10 cargo ...
|
||||||
|
```
|
||||||
|
|
||||||
#### Tracking down errors
|
#### Tracking down errors
|
||||||
|
|
||||||
You can set `RUST_BACKTRACE=1` to be provided with backtraces when a candle
|
You can set `RUST_BACKTRACE=1` to be provided with backtraces when a candle
|
||||||
|
@ -57,9 +57,17 @@ fn main() -> Result<()> {
|
|||||||
#[allow(clippy::redundant_clone)]
|
#[allow(clippy::redundant_clone)]
|
||||||
out_dir.clone()
|
out_dir.clone()
|
||||||
}
|
}
|
||||||
Ok(build_dir) => PathBuf::from(build_dir),
|
Ok(build_dir) =>
|
||||||
|
{
|
||||||
|
let path = PathBuf::from(build_dir);
|
||||||
|
path.canonicalize().expect(&format!("Directory doesn't exists: {} (the current directory is {})", &path.display(), std::env::current_dir()?.display()))
|
||||||
|
}
|
||||||
};
|
};
|
||||||
set_cuda_include_dir()?;
|
set_cuda_include_dir()?;
|
||||||
|
|
||||||
|
let ccbin_env = std::env::var("CANDLE_NVCC_CCBIN");
|
||||||
|
println!("cargo:rerun-if-env-changed=CANDLE_NVCC_CCBIN");
|
||||||
|
|
||||||
let compute_cap = compute_cap()?;
|
let compute_cap = compute_cap()?;
|
||||||
|
|
||||||
let out_file = build_dir.join("libflashattention.a");
|
let out_file = build_dir.join("libflashattention.a");
|
||||||
@ -95,14 +103,21 @@ fn main() -> Result<()> {
|
|||||||
.args(["--default-stream", "per-thread"])
|
.args(["--default-stream", "per-thread"])
|
||||||
.arg("-Icutlass/include")
|
.arg("-Icutlass/include")
|
||||||
.arg("--expt-relaxed-constexpr")
|
.arg("--expt-relaxed-constexpr")
|
||||||
.arg(cu_file);
|
.arg("--verbose");
|
||||||
|
if let Ok(ccbin_path) = &ccbin_env {
|
||||||
|
command
|
||||||
|
.arg("-allow-unsupported-compiler")
|
||||||
|
.args(["-ccbin", ccbin_path]);
|
||||||
|
}
|
||||||
|
command.arg(cu_file);
|
||||||
let output = command
|
let output = command
|
||||||
.spawn()
|
.spawn()
|
||||||
.context("failed spawning nvcc")?
|
.context("failed spawning nvcc")?
|
||||||
.wait_with_output()?;
|
.wait_with_output()?;
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
anyhow::bail!(
|
anyhow::bail!(
|
||||||
"nvcc error while compiling:\n\n# stdout\n{:#}\n\n# stderr\n{:#}",
|
"nvcc error while executing compiling: {:?}\n\n# stdout\n{:#}\n\n# stderr\n{:#}",
|
||||||
|
&command,
|
||||||
String::from_utf8_lossy(&output.stdout),
|
String::from_utf8_lossy(&output.stdout),
|
||||||
String::from_utf8_lossy(&output.stderr)
|
String::from_utf8_lossy(&output.stderr)
|
||||||
)
|
)
|
||||||
@ -122,7 +137,8 @@ fn main() -> Result<()> {
|
|||||||
.wait_with_output()?;
|
.wait_with_output()?;
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
anyhow::bail!(
|
anyhow::bail!(
|
||||||
"nvcc error while linking:\n\n# stdout\n{:#}\n\n# stderr\n{:#}",
|
"nvcc error while linking: {:?}\n\n# stdout\n{:#}\n\n# stderr\n{:#}",
|
||||||
|
&command,
|
||||||
String::from_utf8_lossy(&output.stdout),
|
String::from_utf8_lossy(&output.stdout),
|
||||||
String::from_utf8_lossy(&output.stderr)
|
String::from_utf8_lossy(&output.stderr)
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user