Skip to content

Commit

Permalink
cicd: fix ubuntu pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
newfla committed Oct 15, 2024
1 parent 51c4859 commit d44bce0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 34 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Ubuntu build dependencies
run: apt update && apt install -y clang cmake
- name: Check Style
run: cargo fmt --check

cargo-test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Run tests
run: cargo test

build-no_feature:
runs-on: [ubuntu-latest, windows-latest, macos-latest]
build:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest, macos-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Ubuntu build dependencies
if: matrix.platform == 'ubuntu-latest'
run: apt update && apt install -y clang cmake
- name: Build
run: cargo build

Expand All @@ -54,9 +55,12 @@ jobs:
- uses: dtolnay/rust-toolchain@stable
- name: Install cuda toolkit
uses: Jimver/[email protected]
- name: install msvc deps (windows)
- name: Install Windows dependencies
if: matrix.platform == 'windows-2019'
uses: ilammy/msvc-dev-cmd@v1
- name: Ubuntu build dependencies
if: matrix.platform == 'ubuntu-22.04'
run: apt update && apt install -y clang cmake
- name: Build
env:
CUDA_COMPUTE_CAP: "75"
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ Cargo.lock
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
#.idea/
bin/act
1 change: 0 additions & 1 deletion sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,4 @@ flashattn = []
[build-dependencies]
cmake = "0.1.51"
bindgen = "0.70.1"
cfg-if = "1.0.0"
fs_extra = "1.3.0"
34 changes: 13 additions & 21 deletions sys/build.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
env,
fs::{copy, create_dir_all, read_dir},
fs::{create_dir_all, read_dir},
path::PathBuf,
};

Expand Down Expand Up @@ -36,24 +36,14 @@ fn main() {
// Bindgen
let bindings = bindgen::Builder::default().header("wrapper.h");

let bindings = bindings
bindings
.clang_arg("-I./stable-diffusion.cpp")
.clang_arg("-I./stable-diffusion.cpp/ggml/include")
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.generate();

match bindings {
Ok(b) => {
b.write_to_file(out.join("bindings.rs"))
.expect("Couldn't write bindings!");
}
Err(e) => {
println!("cargo:warning=Unable to generate bindings: {}", e);
println!("cargo:warning=Using bundled bindings.rs, which may be out of date");
// copy src/bindings.rs to OUT_DIR
copy("src/bindings.rs", out.join("bindings.rs")).expect("Unable to copy bindings.rs");
}
}
.generate()
.unwrap()
.write_to_file(out.join("bindings.rs"))
.expect("Couldn't write bindings!");

// stop if we're on docs.rs
if env::var("DOCS_RS").is_ok() {
Expand Down Expand Up @@ -81,8 +71,11 @@ fn main() {
println!("cargo:rustc-link-search=/opt/cuda/lib64");
println!("cargo:rustc-link-search=/opt/cuda/lib64/stubs");
}

config.define("SD_CUBLAS", "ON");
if let Ok(target) = env::var("CUDA_COMPUTE_CAP") {
config.define("CUDA_COMPUTE_CAP", target);
}
}

#[cfg(feature = "hipblas")]
Expand All @@ -93,21 +86,20 @@ fn main() {

if target.contains("msvc") {
panic!("Due to a problem with the last revision of the ROCm 5.7 library, it is not possible to compile the library for the windows environment.\nSee https://github.com/ggerganov/whisper.cpp/issues/2202 for more details.")

} else {
println!("cargo:rerun-if-env-changed=HIP_PATH");

let hip_path = match env::var("HIP_PATH") {
Ok(path) =>PathBuf::from(path),
Ok(path) => PathBuf::from(path),
Err(_) => PathBuf::from("/opt/rocm"),
};
let hip_lib_path = hip_path.join("lib");

println!("cargo:rustc-link-search={}",hip_lib_path.display());
println!("cargo:rustc-link-search={}", hip_lib_path.display());
}

config.define("SD_HIPBLAS", "ON");
if let Ok(target) = env::var("AMDGPU_TARGETS") {
if let Ok(target) = env::var("AMDGPU_TARGETS") {
config.define("AMDGPU_TARGETS", target);
}
}
Expand Down

0 comments on commit d44bce0

Please sign in to comment.