Skip to content

Commit

Permalink
Build farmer with CUDA support
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Sep 7, 2024
1 parent 49245ef commit 45e93bd
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ jobs:
# Doesn't exist on self-hosted runners
if: matrix.os == 'windows-2022'

- name: CUDA toolchain
uses: Jimver/cuda-toolkit@9b295696791d75d658d8de64c4a85097ad8abeaf # v0.2.16
with:
method: network
sub-packages: '["nvcc", "cudart"]'
if: runner.os == 'Linux' || runner.os == 'Windows'

- name: Configure cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
Expand All @@ -108,7 +115,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"') }}
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/rustdoc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ jobs:
restore-keys: |
${{ runner.os }}-cargo-
- name: CUDA toolchain
uses: Jimver/cuda-toolkit@9b295696791d75d658d8de64c4a85097ad8abeaf # v0.2.16
with:
method: network
sub-packages: '["nvcc", "cudart"]'

# 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"

Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/snapshot-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,13 @@ jobs:
echo "PKG_CONFIG_ALLOW_CROSS=true" >> $GITHUB_ENV
if: matrix.build.target == 'aarch64-unknown-linux-gnu'

- name: CUDA toolchain
uses: Jimver/cuda-toolkit@9b295696791d75d658d8de64c4a85097ad8abeaf # v0.2.16
with:
method: network
sub-packages: '["nvcc", "cudart"]'
if: runner.os == 'Linux' || runner.os == 'Windows'

- name: Configure cache
uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
with:
Expand All @@ -202,6 +209,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' || !startsWith(matrix.build.target, 'x86_64')

- 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: |
Expand Down
13 changes: 13 additions & 0 deletions Dockerfile-farmer
Original file line number Diff line number Diff line change
Expand Up @@ -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-minimal-build-12-6

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
Expand Down

0 comments on commit 45e93bd

Please sign in to comment.