diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 2504eddbcb1..9a87d423a45 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -96,6 +96,10 @@ jobs: # Doesn't exist on self-hosted runners if: matrix.os == 'windows-2022' + - name: CUDA toolchain + uses: Jimver/cuda-toolkit@v0.2.16 + if: runner.os == 'Linux' || runner.os == 'Windows' + - name: Configure cache uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: @@ -108,7 +112,13 @@ jobs: - name: cargo clippy run: | - cargo -Zgitoxide -Zgit clippy --locked --all-targets --features "runtime-benchmarks" -- -D warnings + cargo -Zgitoxide -Zgit clippy --locked --all-targets --features runtime-benchmarks -- -D warnings + if: runner.os == 'macOS' + + - name: cargo clippy + run: | + cargo -Zgitoxide -Zgit clippy --locked --all-targets --features runtime-benchmarks,cuda -- -D warnings + if: runner.os == 'Linux' || runner.os == 'Windows' cargo-docs: runs-on: ${{ fromJson(github.repository_owner == 'autonomys' && '["self-hosted", "ubuntu-20.04-x86-64"]' || '"ubuntu-22.04"') }} diff --git a/.github/workflows/rustdoc.yml b/.github/workflows/rustdoc.yml index 7f167599fb4..1afd06e9c24 100644 --- a/.github/workflows/rustdoc.yml +++ b/.github/workflows/rustdoc.yml @@ -37,9 +37,12 @@ jobs: restore-keys: | ${{ runner.os }}-cargo- + - name: CUDA toolchain + uses: Jimver/cuda-toolkit@v0.2.16 + # Build the rust crate docs - name: Build Documentation - run: cargo -Zgitoxide -Zgit doc --all --no-deps --lib + run: cargo -Zgitoxide -Zgit doc --all --no-deps --lib --features cuda env: RUSTDOCFLAGS: "-Z unstable-options --enable-index-page" diff --git a/.github/workflows/snapshot-build.yml b/.github/workflows/snapshot-build.yml index 4d93197512e..7590e2acac4 100644 --- a/.github/workflows/snapshot-build.yml +++ b/.github/workflows/snapshot-build.yml @@ -189,6 +189,10 @@ jobs: echo "PKG_CONFIG_ALLOW_CROSS=true" >> $GITHUB_ENV if: matrix.build.target == 'aarch64-unknown-linux-gnu' + - name: CUDA toolchain + uses: Jimver/cuda-toolkit@v0.2.16 + if: runner.os == 'Linux' || runner.os == 'Windows' + - name: Configure cache uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: @@ -202,6 +206,13 @@ jobs: - name: Build farmer run: | cargo -Zgitoxide -Zgit build --locked -Z build-std --target ${{ matrix.build.target }} --profile production --bin subspace-farmer + if: runner.os == 'macOS' + + - name: Build farmer + run: | + cargo -Zgitoxide -Zgit build --locked -Z build-std --target ${{ matrix.build.target }} --profile production --bin subspace-farmer --features cuda + # TODO: We don't configure CUDA for cross-compilation purposes, hence only x86-64 for now + if: (runner.os == 'Linux' || runner.os == 'Windows') && startsWith(matrix.build.target, 'x86_64') - name: Build node run: | diff --git a/Dockerfile-farmer b/Dockerfile-farmer index 6522be99511..415ede284c3 100644 --- a/Dockerfile-farmer +++ b/Dockerfile-farmer @@ -40,11 +40,24 @@ COPY test /code/test # Up until this line all Rust images in this repo should be the same to share the same layers RUN \ + CUDA_ARCH=$(uname -p | sed "s/aarch64/arm64/g") && \ + curl -OL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/$CUDA_ARCH/cuda-keyring_1.1-1_all.deb && \ + dpkg -i cuda-keyring_1.1-1_all.deb && \ + echo "deb [signed-by=/usr/share/keyrings/cuda-archive-keyring.gpg] https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/$CUDA_ARCH/ /" | tee /etc/apt/sources.list.d/cuda-ubuntu2004-$CUDA_ARCH.list && \ + curl -OL https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/$CUDA_ARCH/cuda-ubuntu2004.pin && \ + mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600 && \ + apt-get update && \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends cuda-toolkit + +RUN \ + export PATH=/usr/local/cuda/bin${PATH:+:${PATH}} && \ + export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} && \ /root/.cargo/bin/cargo -Zgitoxide -Zgit build \ --locked \ -Z build-std \ --profile $PROFILE \ --bin subspace-farmer \ + --features cuda \ --target $(uname -p)-unknown-linux-gnu && \ mv target/*/*/subspace-farmer subspace-farmer && \ rm -rf target