From d644fe3eb61d75b228804bc060a5c863a6f5215f Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Tue, 31 Oct 2023 13:38:28 -0300 Subject: [PATCH 01/21] wip build: NIF binaries targeting CUDA --- .github/workflows/binaries.yml | 53 ++++++++++++++++++++++++++++++---- README.md | 20 ++++++++++++- config/config.exs | 16 +--------- lib/candlex/native.ex | 7 +++-- 4 files changed, 73 insertions(+), 23 deletions(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 210508c..846687d 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -14,8 +14,14 @@ on: - ".github/workflows/binaries.yml" workflow_dispatch: +env: + PROJECT_NAME: "candlex" + PROJECT_DIR: "native/candlex" + PROJECT_VERSION: "0.1.2" + NIF_VERSION: "2.16" + jobs: - build_binary: + build_cpu: name: ${{ matrix.target }} / ${{ matrix.os }} runs-on: ${{ matrix.os }} permissions: @@ -40,12 +46,49 @@ jobs: - uses: philss/rustler-precompiled-action@main id: precompile with: - project-dir: "native/candlex" - project-name: candlex - project-version: "0.1.2" + project-dir: ${{ env.PROJECT_DIR }} + project-name: ${{ env.PROJECT_NAME }} + project-version: ${{ env.PROJECT_VERSION }} target: ${{ matrix.target }} use-cross: ${{ matrix.use-cross }} - nif-version: "2.16" + nif-version: ${{ env.NIF_VERSION }} + + - uses: softprops/action-gh-release@v1 + with: + draft: true + files: ${{ steps.precompile.outputs.file-path }} + if: startsWith(github.ref, 'refs/tags/') + + build_cuda: + name: ${{ matrix.job.target }} + runs-on: ubuntu-22.04 + permissions: + contents: write + strategy: + fail-fast: false + matrix: + include: + - target: x86_64-unknown-linux-gnu + os: ubuntu-22.04 + + container: + image: nvidia/cuda:12.2.2-devel-ubuntu22.04 + + steps: + - uses: actions/checkout@v4 + - run: rustup target add ${{ matrix.job.target }} + + - uses: philss/rustler-precompiled-action@main + id: precompile + with: + project-dir: ${{ env.PROJECT_DIR }} + project-name: ${{ env.PROJECT_NAME }} + project-version: ${{ env.PROJECT_VERSION }} + target: ${{ matrix.target }} + use-cross: null + nif-version: ${{ env.NIF_VERSION }} + variant: cuda + cargo-args: "--features cuda" - uses: softprops/action-gh-release@v1 with: diff --git a/README.md b/README.md index bf1e782..9f789af 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,19 @@ if no precompiled binary is available for your target environment. Once set, you must run `mix deps.clean candlex --build` explicitly to force to recompile. Building has a number of dependencies, see *Building from source* below. +#### `NATIVE_TARGET` + +The default value is `cpu`, which implies the final the binary supports targeting +only the host CPU. + +| Value | Target environment | +| --- | --- | +| cpu | | +| cuda | CUDA 12.x | + +To use Candlex with NVidia GPU you need [CUDA](https://developer.nvidia.com/cuda-downloads) compatible with your +GPU drivers. + ## Building from source To build the native binary locally you need to set `NATIVE_BUILD=true`. @@ -58,11 +71,16 @@ You will need the following installed in your system for the compilation: * [Git](https://git-scm.com) for fetching candle-core source * [Rust](https://www.rust-lang.org) with cargo to compile rustler NIFs +### GPU support + +To build native binary with GPU support, you need to run in an environment that has CUDA installed, +then you can build with either `NATIVE_TARGET=cuda`. See the `NATIVE_TARGET` for more details. + ## Releasing To publish a new version of this package: -1. Update `@version` in `mix.exs` and `project-version` in `.github/workflows/binaries.yml`. +1. Update `@version` in `mix.exs` and `PROJECT_VERSION` in `.github/workflows/binaries.yml`. 1. `git tag -s ` to create new signed tag. 1. `git push origin ` to push the tag. 1. Wait for the `binaries.yml` GitHub workflow to build all the NIF binaries. diff --git a/config/config.exs b/config/config.exs index aecd8ea..ef75dd4 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,17 +1,3 @@ import Config -enable_cuda = - case System.get_env("CUDA") do - nil -> System.find_executable("nvcc") && System.find_executable("nvidia-smi") - "false" -> false - _ -> true - end - -crate_features = - if enable_cuda do - [:cuda] - else - [] - end - -config :candlex, crate_features: crate_features +config :candlex, use_cuda: (System.get_env("NATIVE_TARGET") == "cuda") diff --git a/lib/candlex/native.ex b/lib/candlex/native.ex index bdceb36..d5c2326 100644 --- a/lib/candlex/native.ex +++ b/lib/candlex/native.ex @@ -8,7 +8,7 @@ defmodule Candlex.Native do use RustlerPrecompiled, otp_app: :candlex, - features: Application.compile_env(:candlex, :crate_features, []), + features: if(Application.compile_env(:candlex, :use_cuda), do: [:cuda], else: []), base_url: "#{source_url}/releases/download/v#{version}", force_build: System.get_env("NATIVE_BUILD") in ["1", "true"], mode: mode, @@ -19,7 +19,10 @@ defmodule Candlex.Native do "aarch64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-unknown-linux-gnu" - ] + ], + variants: %{ + "x86_64-unknown-linux-gnu" => [cuda: fn -> Application.compile_env(:candlex, :use_cuda) end] + } # Rustler will override all the below stub functions with real NIFs def from_binary(_binary, _dtype, _shape, _device), do: error() From 11cf986acbf35ce851b739bacc7701f22fce0a2d Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Tue, 31 Oct 2023 14:10:35 -0300 Subject: [PATCH 02/21] mix format --- config/config.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.exs b/config/config.exs index ef75dd4..74eca25 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,3 +1,3 @@ import Config -config :candlex, use_cuda: (System.get_env("NATIVE_TARGET") == "cuda") +config :candlex, use_cuda: System.get_env("NATIVE_TARGET") == "cuda" From daba9dc2f3095ac197f88b69ac7ac433bafa2082 Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Tue, 31 Oct 2023 14:11:52 -0300 Subject: [PATCH 03/21] fixes --- .github/workflows/binaries.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 846687d..6dc667c 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -22,7 +22,7 @@ env: jobs: build_cpu: - name: ${{ matrix.target }} / ${{ matrix.os }} + name: cpu / ${{ matrix.target }} / ${{ matrix.os }} runs-on: ${{ matrix.os }} permissions: contents: write @@ -60,7 +60,7 @@ jobs: if: startsWith(github.ref, 'refs/tags/') build_cuda: - name: ${{ matrix.job.target }} + name: cuda / ${{ matrix.target }} / ${{ matrix.os }} runs-on: ubuntu-22.04 permissions: contents: write @@ -76,7 +76,7 @@ jobs: steps: - uses: actions/checkout@v4 - - run: rustup target add ${{ matrix.job.target }} + - run: rustup target add ${{ matrix.target }} - uses: philss/rustler-precompiled-action@main id: precompile From 61a1e8f23bff4b4118eb43552f81d76336324ca6 Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Tue, 31 Oct 2023 14:31:11 -0300 Subject: [PATCH 04/21] rust in nvidia/cuda container --- .github/workflows/binaries.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 6dc667c..7f047aa 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -76,6 +76,7 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable - run: rustup target add ${{ matrix.target }} - uses: philss/rustler-precompiled-action@main From 08583f659bcf5ff82c5a24b8eb80db6d0866cfee Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Tue, 31 Oct 2023 14:38:12 -0300 Subject: [PATCH 05/21] curl --- .github/workflows/binaries.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 7f047aa..38ae012 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -76,6 +76,7 @@ jobs: steps: - uses: actions/checkout@v4 + - run: apt update && apt install -y curl - uses: dtolnay/rust-toolchain@stable - run: rustup target add ${{ matrix.target }} From e6ae47b0235cbd6d60c9ab3b1851cfe3e1ff6f5d Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Tue, 31 Oct 2023 14:46:23 -0300 Subject: [PATCH 06/21] bash --- .github/workflows/binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 38ae012..9aa3d13 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -76,7 +76,7 @@ jobs: steps: - uses: actions/checkout@v4 - - run: apt update && apt install -y curl + - run: apt update && apt install -y bash curl - uses: dtolnay/rust-toolchain@stable - run: rustup target add ${{ matrix.target }} From c057bda0f8ba1f93c252a0aea695d072fb7bc331 Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Tue, 31 Oct 2023 14:53:48 -0300 Subject: [PATCH 07/21] debug --- .github/workflows/binaries.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 9aa3d13..5f0d9ec 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -76,8 +76,10 @@ jobs: steps: - uses: actions/checkout@v4 - - run: apt update && apt install -y bash curl + - run: apt update && apt install -y curl - uses: dtolnay/rust-toolchain@stable + - run: cargo --version + shell: bash - run: rustup target add ${{ matrix.target }} - uses: philss/rustler-precompiled-action@main From 4debd9aaa40f131af99bb835ee5ccab48c061c1b Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Tue, 31 Oct 2023 15:02:02 -0300 Subject: [PATCH 08/21] git --- .github/workflows/binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 5f0d9ec..89d7d07 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -76,7 +76,7 @@ jobs: steps: - uses: actions/checkout@v4 - - run: apt update && apt install -y curl + - run: apt update && apt install -y curl git - uses: dtolnay/rust-toolchain@stable - run: cargo --version shell: bash From e3e1eb0f1c499a64ed7fb879d16de49b75fe7f73 Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Tue, 31 Oct 2023 15:09:19 -0300 Subject: [PATCH 09/21] order --- .github/workflows/binaries.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 89d7d07..8c39a51 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -75,11 +75,9 @@ jobs: image: nvidia/cuda:12.2.2-devel-ubuntu22.04 steps: - - uses: actions/checkout@v4 - run: apt update && apt install -y curl git + - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - run: cargo --version - shell: bash - run: rustup target add ${{ matrix.target }} - uses: philss/rustler-precompiled-action@main From 4e61cd2e48be6312bd35f569967a5772841283bc Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Tue, 31 Oct 2023 15:16:13 -0300 Subject: [PATCH 10/21] debug rusterl-precompiled-action --- .github/workflows/binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 8c39a51..48cd553 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -80,7 +80,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - run: rustup target add ${{ matrix.target }} - - uses: philss/rustler-precompiled-action@main + - uses: mimiquate/rustler-precompiled-action@debug id: precompile with: project-dir: ${{ env.PROJECT_DIR }} From dec8fcf36288af58500fd055a3b9da2db464370e Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Tue, 31 Oct 2023 15:47:05 -0300 Subject: [PATCH 11/21] fix build sh --- .github/workflows/binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 48cd553..fcb5cff 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -80,7 +80,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - run: rustup target add ${{ matrix.target }} - - uses: mimiquate/rustler-precompiled-action@debug + - uses: mimiquate/rustler-precompiled-action@fix-build-sh-with-container id: precompile with: project-dir: ${{ env.PROJECT_DIR }} From 0ea23d5e513e5209157505226db9c487a001ed68 Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Tue, 31 Oct 2023 15:48:29 -0300 Subject: [PATCH 12/21] also test fix without container --- .github/workflows/binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index fcb5cff..1a6d2ab 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -43,7 +43,7 @@ jobs: - uses: actions/checkout@v4 - run: rustup target add ${{ matrix.target }} - - uses: philss/rustler-precompiled-action@main + - uses: mimiquate/rustler-precompiled-action@fix-build-sh-with-container id: precompile with: project-dir: ${{ env.PROJECT_DIR }} From d4fb7ca6601b9317858915ab35581094cf9efe4f Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Thu, 2 Nov 2023 17:22:19 -0300 Subject: [PATCH 13/21] try to fake compute cap and avoid nvidia-smi dep --- .github/workflows/binaries.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 1a6d2ab..efb9029 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -73,6 +73,8 @@ jobs: container: image: nvidia/cuda:12.2.2-devel-ubuntu22.04 + env: + CUDA_COMPUTE_CAP: "7.0" steps: - run: apt update && apt install -y curl git From 585778d3220313952a59dd5b9441fa900d41bdf1 Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Thu, 2 Nov 2023 17:30:30 -0300 Subject: [PATCH 14/21] fix? --- .github/workflows/binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index efb9029..32bd84e 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -74,7 +74,7 @@ jobs: container: image: nvidia/cuda:12.2.2-devel-ubuntu22.04 env: - CUDA_COMPUTE_CAP: "7.0" + CUDA_COMPUTE_CAP: "7" steps: - run: apt update && apt install -y curl git From 16b2660bf97661d047c51e64a891d51a338e6853 Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Thu, 2 Nov 2023 17:35:37 -0300 Subject: [PATCH 15/21] fix2 --- .github/workflows/binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 32bd84e..bf184dd 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -74,7 +74,7 @@ jobs: container: image: nvidia/cuda:12.2.2-devel-ubuntu22.04 env: - CUDA_COMPUTE_CAP: "7" + CUDA_COMPUTE_CAP: "70" steps: - run: apt update && apt install -y curl git From 4fb627c7a5aa22f594dacd01d8cafda346117e2d Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Fri, 3 Nov 2023 09:59:31 -0300 Subject: [PATCH 16/21] test --- .github/workflows/binaries.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index bf184dd..1ab90ab 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -84,6 +84,8 @@ jobs: - uses: mimiquate/rustler-precompiled-action@fix-build-sh-with-container id: precompile + env: + CUDA_COMPUTE_CAP: "70" with: project-dir: ${{ env.PROJECT_DIR }} project-name: ${{ env.PROJECT_NAME }} From d2407532c62236f1cc57d10d8b0d68dfb91e811c Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Fri, 3 Nov 2023 10:46:35 -0300 Subject: [PATCH 17/21] update compute_cap parsing with upstream --- native/candlex/build.rs | 67 +++++++++++++++++++++-------------------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/native/candlex/build.rs b/native/candlex/build.rs index 86a9c61..33c4b9d 100644 --- a/native/candlex/build.rs +++ b/native/candlex/build.rs @@ -180,13 +180,21 @@ fn set_cuda_include_dir() -> Result<()> { #[allow(unused)] fn compute_cap() -> Result { - // Grab compute code from nvidia-smi - let mut compute_cap = { + println!("cargo:rerun-if-env-changed=CUDA_COMPUTE_CAP"); + + // Try to parse compute caps from env + let mut compute_cap = if let Ok(compute_cap_str) = std::env::var("CUDA_COMPUTE_CAP") { + println!("cargo:rustc-env=CUDA_COMPUTE_CAP={compute_cap_str}"); + compute_cap_str + .parse::() + .context("Could not parse code")? + } else { + // Use nvidia-smi to get the current compute cap let out = std::process::Command::new("nvidia-smi") - .arg("--query-gpu=compute_cap") - .arg("--format=csv") - .output() - .context("`nvidia-smi` failed. Ensure that you have CUDA installed and that `nvidia-smi` is in your PATH.")?; + .arg("--query-gpu=compute_cap") + .arg("--format=csv") + .output() + .context("`nvidia-smi` failed. Ensure that you have CUDA installed and that `nvidia-smi` is in your PATH.")?; let out = std::str::from_utf8(&out.stdout).context("stdout is not a utf8 string")?; let mut lines = out.lines(); assert_eq!( @@ -197,16 +205,19 @@ fn compute_cap() -> Result { .next() .context("missing line in stdout")? .replace('.', ""); - cap.parse::() - .with_context(|| format!("cannot parse as int {cap}"))? + let cap = cap + .parse::() + .with_context(|| format!("cannot parse as int {cap}"))?; + println!("cargo:rustc-env=CUDA_COMPUTE_CAP={cap}"); + cap }; // Grab available GPU codes from nvcc and select the highest one - let max_nvcc_code = { + let (supported_nvcc_codes, max_nvcc_code) = { let out = std::process::Command::new("nvcc") - .arg("--list-gpu-code") - .output() - .expect("`nvcc` failed. Ensure that you have CUDA installed and that `nvcc` is in your PATH."); + .arg("--list-gpu-code") + .output() + .expect("`nvcc` failed. Ensure that you have CUDA installed and that `nvcc` is in your PATH."); let out = std::str::from_utf8(&out.stdout).unwrap(); let out = out.lines().collect::>(); @@ -220,31 +231,21 @@ fn compute_cap() -> Result { } } codes.sort(); - if !codes.contains(&compute_cap) { - anyhow::bail!( - "nvcc cannot target gpu arch {compute_cap}. Available nvcc targets are {codes:?}." - ); - } - *codes.last().unwrap() + let max_nvcc_code = *codes.last().context("no gpu codes parsed from nvcc")?; + (codes, max_nvcc_code) }; - // If nvidia-smi compute_cap is higher than the highest gpu code from nvcc, - // then choose the highest gpu code in nvcc + // Check that nvcc supports the asked compute caps + if !supported_nvcc_codes.contains(&compute_cap) { + anyhow::bail!( + "nvcc cannot target gpu arch {compute_cap}. Available nvcc targets are {supported_nvcc_codes:?}." + ); + } if compute_cap > max_nvcc_code { - println!( - "cargo:warning=Lowering gpu arch {compute_cap} to max nvcc target {max_nvcc_code}." - ); - compute_cap = max_nvcc_code; + anyhow::bail!( + "CUDA compute cap {compute_cap} is higher than the highest gpu code from nvcc {max_nvcc_code}" + ); } - println!("cargo:rerun-if-env-changed=CUDA_COMPUTE_CAP"); - - if let Ok(compute_cap_str) = std::env::var("CUDA_COMPUTE_CAP") { - compute_cap = compute_cap_str - .parse::() - .with_context(|| format!("cannot parse as usize '{compute_cap_str}'"))?; - println!("cargo:warning=Using gpu arch {compute_cap} from $CUDA_COMPUTE_CAP"); - } - println!("cargo:rustc-env=CUDA_COMPUTE_CAP=sm_{compute_cap}"); Ok(compute_cap) } From 2e31ce82cd1e4f07ef0a404b0f9a34decef4516b Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Fri, 3 Nov 2023 11:09:09 -0300 Subject: [PATCH 18/21] update env var name --- README.md | 4 ++-- config/config.exs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6643cdc..710c6cb 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ if no precompiled binary is available for your target environment. Once set, you must run `mix deps.clean candlex --build` explicitly to force to recompile. Building has a number of dependencies, see *Building from source* below. -#### `NATIVE_TARGET` +#### `CANDLEX_NIF_TARGET` The default value is `cpu`, which implies the final the binary supports targeting only the host CPU. @@ -74,7 +74,7 @@ You will need the following installed in your system for the compilation: ### GPU support To build native binary with GPU support, you need to run in an environment that has CUDA installed, -then you can build with either `NATIVE_TARGET=cuda`. See the `NATIVE_TARGET` for more details. +then you can build with `CANDLEX_NIF_TARGET=cuda`. See the `CANDLEX_NIF_TARGET` for more details. ## Releasing diff --git a/config/config.exs b/config/config.exs index 74eca25..aff71b9 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,3 +1,3 @@ import Config -config :candlex, use_cuda: System.get_env("NATIVE_TARGET") == "cuda" +config :candlex, use_cuda: System.get_env("CANDLEX_NIF_TARGET") == "cuda" From 5a9c63b1074492603c2907d14806a7e9af907f98 Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Fri, 3 Nov 2023 12:31:01 -0300 Subject: [PATCH 19/21] back to philss/rustler-precompiled-action@main after merged PR --- .github/workflows/binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 1ab90ab..3a9fc92 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -82,7 +82,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable - run: rustup target add ${{ matrix.target }} - - uses: mimiquate/rustler-precompiled-action@fix-build-sh-with-container + - uses: philss/rustler-precompiled-action@main id: precompile env: CUDA_COMPUTE_CAP: "70" From f22b57232ba21e881aacd6c826f24ec6798477f3 Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Fri, 3 Nov 2023 13:15:05 -0300 Subject: [PATCH 20/21] fix action --- .github/workflows/binaries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index 3a9fc92..ae01b10 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -43,7 +43,7 @@ jobs: - uses: actions/checkout@v4 - run: rustup target add ${{ matrix.target }} - - uses: mimiquate/rustler-precompiled-action@fix-build-sh-with-container + - uses: philss/rustler-precompiled-action@main id: precompile with: project-dir: ${{ env.PROJECT_DIR }} From 938472510de7d38d548f5a5d2f56356a40d12ea3 Mon Sep 17 00:00:00 2001 From: Gonzalo <456459+grzuy@users.noreply.github.com> Date: Fri, 3 Nov 2023 13:12:49 -0300 Subject: [PATCH 21/21] removes repeated env var --- .github/workflows/binaries.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/binaries.yml b/.github/workflows/binaries.yml index ae01b10..bdaddc6 100644 --- a/.github/workflows/binaries.yml +++ b/.github/workflows/binaries.yml @@ -73,8 +73,6 @@ jobs: container: image: nvidia/cuda:12.2.2-devel-ubuntu22.04 - env: - CUDA_COMPUTE_CAP: "70" steps: - run: apt update && apt install -y curl git