Installation Guide - ruvnet/ruv-FANN GitHub Wiki
Complete installation instructions for ruv-FANN across all platforms and use cases.
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
# Add to your Rust project
cargo add ruv-fann semantic-cartan-matrix ruv-swarm
# Install Node.js SDK
npm install ruv-swarm
# Install CLI tools globally
npm install -g claude-flow ruv-swarm
# Install Python bindings
pip install ruv-swarm-py
# Install with ML dependencies
pip install ruv-swarm-py[ml,neural,async]
# Install system dependencies
sudo apt update
sudo apt install build-essential pkg-config libssl-dev
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
# Install SIMD support
sudo apt install libc6-dev
# Verify installation
cargo --version
rustc --version
# Install Xcode command line tools
xcode-select --install
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
# Install via Homebrew (alternative)
brew install rust
# Download and run rustup-init.exe from https://rustup.rs/
# Or use Chocolatey
choco install rust
# Or use Scoop
scoop install rust
# Install Microsoft C++ Build Tools
# Download from: https://visualstudio.microsoft.com/visual-cpp-build-tools/
# Use official Rust image
FROM rust:1.75-slim
# Install system dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# Set working directory
WORKDIR /app
# Copy and build project
COPY Cargo.toml Cargo.lock ./
COPY src ./src
RUN cargo build --release
# Runtime stage
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
COPY --from=0 /app/target/release/ruv-fann /usr/local/bin/
CMD ["ruv-fann"]
[dependencies]
ruv-fann = { version = "0.3", features = ["default"] }
# Available features:
# "std" - Standard library support (default)
# "simd" - SIMD acceleration (recommended)
# "parallel" - Multi-threading support
# "wasm" - WebAssembly compilation
# "gpu" - GPU acceleration
# "embedded" - Embedded/no_std support
[dependencies]
ruv-fann = { version = "0.3", features = ["simd", "avx2"] }
# Platform-specific SIMD:
# "sse2" - Basic SSE2 (x86/x64)
# "sse4.1" - Advanced SSE (x86/x64)
# "avx" - AVX support (x86/x64)
# "avx2" - AVX2 support (x86/x64)
# "neon" - ARM NEON support
# Install wasm-pack
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
# Build for web
wasm-pack build --target web --features wasm
# Build for Node.js
wasm-pack build --target nodejs --features wasm,simd
[dependencies]
ruv-fann = { version = "0.3", features = ["gpu", "cuda"] }
# GPU features:
# "opencl" - OpenCL support
# "cuda" - NVIDIA CUDA support
# "vulkan" - Vulkan compute
# "webgpu" - WebGPU (WASM only)
# Clone repository
git clone https://github.com/ruvnet/ruv-FANN.git
cd ruv-FANN
# Install development dependencies
rustup component add clippy rustfmt
cargo install cargo-watch cargo-audit cargo-tarpaulin
# Install pre-commit hooks
pip install pre-commit
pre-commit install
# Run development setup
make dev-setup
{
"extensions.recommendations": [
"rust-lang.rust-analyzer",
"serayuzgur.crates",
"tamasfe.even-better-toml",
"vadimcn.vscode-lldb"
],
"rust-analyzer.cargo.features": [
"std", "simd", "parallel"
],
"rust-analyzer.checkOnSave.command": "clippy"
}
<!-- In .idea/runConfigurations/ruv_fann.xml -->
<configuration name="ruv-fann" type="CargoCommandRunConfiguration">
<option name="command" value="run --features std,simd,parallel" />
<option name="workingDirectory" value="$PROJECT_DIR$" />
<option name="emulateTerminal" value="true" />
</configuration>
# Build optimized WASM
wasm-pack build --release --target web \
--features wasm,simd \
--out-dir pkg
# Optimize with wasm-opt
wasm-opt -Oz -o pkg/ruv_fann_bg.wasm pkg/ruv_fann_bg.wasm
# Create HTML wrapper
cat > index.html << 'EOF'
<!DOCTYPE html>
<html>
<head>
<title>ruv-FANN Demo</title>
<script type="module">
import init, { NeuralNetwork } from './pkg/ruv_fann.js';
async function run() {
await init();
const net = new NeuralNetwork(3, [4, 2], 1);
console.log('Neural network created!');
}
run().catch(console.error);
</script>
</head>
<body>
<h1>ruv-FANN WebAssembly Demo</h1>
<p>Check browser console for output.</p>
</body>
</html>
EOF
# Serve locally
python -m http.server 8000
# Build for Node.js
wasm-pack build --target nodejs --features wasm
# Install in Node project
npm install ./pkg
# Use in Node.js
cat > demo.js << 'EOF'
const { NeuralNetwork } = require('./pkg');
async function main() {
const net = new NeuralNetwork(3, [4, 2], 1);
console.log('Neural network ready!');
}
main().catch(console.error);
EOF
node demo.js
[dependencies]
ruv-fann = {
version = "0.3",
default-features = false,
features = ["embedded", "arm"]
}
# Target configuration
[target.thumbv7em-none-eabihf]
rustflags = ["-C", "target-cpu=cortex-m4", "-C", "target-feature=+fp"]
[dependencies]
ruv-fann = {
version = "0.3",
default-features = false,
features = ["embedded", "riscv"]
}
# Install ESP-IDF
curl -LO https://github.com/esp-rs/rust-build/releases/latest/download/install-rust-toolchain.sh
chmod +x install-rust-toolchain.sh
./install-rust-toolchain.sh
# Configure for ESP32
cat > .cargo/config.toml << 'EOF'
[target.xtensa-esp32-espidf]
linker = "ldproxy"
[env]
ESP_IDF_VERSION = "v4.4"
EOF
# Test Rust installation
cat > test_installation.rs << 'EOF'
use ruv_fann::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("๐งช Testing ruv-FANN installation...");
let mut net = NeuralNetwork::builder()
.input_size(2)
.hidden_layers(&[3])
.output_size(1)
.build()?;
let input = vec![0.5, 0.3];
let output = net.run(&input)?;
println!("โ
Neural network test successful!");
println!(" Input: {:?}", input);
println!(" Output: {:?}", output);
Ok(())
}
EOF
rustc test_installation.rs -o test_install
./test_install
# Test SIMD capabilities
cat > test_simd.rs << 'EOF'
use ruv_fann::simd::*;
fn main() {
println!("๐ SIMD Capability Detection:");
#[cfg(target_feature = "sse2")]
println!("โ
SSE2 supported");
#[cfg(target_feature = "avx")]
println!("โ
AVX supported");
#[cfg(target_feature = "avx2")]
println!("โ
AVX2 supported");
println!("๐ SIMD features compiled in");
}
EOF
rustc --cfg 'feature="simd"' test_simd.rs -o test_simd
./test_simd
# Test swarm functionality
npx ruv-swarm test --self-check --verbose
# Expected output:
# โ
WASM runtime initialized
# โ
Agent spawning functional
# โ
Task orchestration working
# โ
Memory coordination active
# โ
All systems operational
# Update Rust toolchain
rustup update
# Clear cargo cache
cargo clean
# Rebuild with verbose output
cargo build --verbose
# Check CPU capabilities
lscpu | grep -i simd
cat /proc/cpuinfo | grep flags
# Compile with specific CPU target
RUSTFLAGS="-C target-cpu=native" cargo build --release
# Install required targets
rustup target add wasm32-unknown-unknown
rustup target add wasm32-wasi
# Update wasm-pack
cargo install wasm-pack --force
# Clear WASM cache
rm -rf pkg/ target/
# Fix cargo permissions
sudo chown -R $USER:$USER ~/.cargo
# Add user to relevant groups
sudo usermod -a -G docker $USER
# Install Visual Studio Build Tools
# https://visualstudio.microsoft.com/visual-cpp-build-tools/
# Set environment variables
$env:RUSTFLAGS="-C target-feature=+crt-static"
# Use stable MSVC toolchain
rustup default stable-x86_64-pc-windows-msvc
# Run benchmarks to verify performance
cargo bench --features bench,simd
# Expected results:
# Neural Network Training: ~2.5ms
# SIMD Vector Operations: ~15ns
# Swarm Coordination: ~50ms
# Memory Allocation: ~100ns
# Test all features
cargo test --all-features --verbose
# Test specific components
cargo test --package ruv-fann --features simd
cargo test --package semantic-cartan-matrix
cargo test --package ruv-swarm --features std
After successful installation:
- Quick Start - Get running in 5 minutes
- Getting Started Guide - Comprehensive tutorial
- API Reference - Complete API documentation
- Examples - Working code samples
Need help with installation?
- Troubleshooting - Common issues and solutions
- GitHub Issues - Report installation problems
- Community Resources - Get help from the community
Installation complete! ๐ Ready to build the future of AI with ruv-FANN.