#!/bin/bash # Complete Docker-based build script for RinHash with ROCm GPU support # This script builds everything in Docker containers for proper encapsulation set -e echo "==================================================" echo " RinHash ROCm GPU Complete Build Script" echo "==================================================" # Check if Docker is available if ! command -v docker &> /dev/null; then echo "ERROR: Docker not found in PATH" echo "Please install Docker first" exit 1 fi echo "Docker found:" docker --version echo "" # Build directory setup BUILD_DIR="$(dirname "$0")" cd "$BUILD_DIR" || exit 1 echo "Building complete Docker image with ROCm GPU support..." echo "This includes:" echo " - ROCm/HIP development environment" echo " - RinHash HIP GPU implementation" echo " - cpuminer with ROCm integration" echo " - Shared libraries for GPU acceleration" echo "" # Build the complete Docker image echo "Building Docker image (this may take several minutes)..." sudo docker build -f Dockerfile.rocm-complete -t rinhash-rocm-complete . if [ $? -ne 0 ]; then echo "" echo "===============================================" echo " DOCKER BUILD FAILED!" echo "===============================================" echo "" echo "Common issues:" echo "1. Docker not properly installed" echo "2. Insufficient permissions" echo "3. Network connectivity issues" echo "4. ROCm base image not available" echo "5. Missing dependencies" echo "" exit 1 fi echo "" echo "Docker image built successfully!" echo "" # Create output directory mkdir -p rocm-complete-output echo "Extracting built binaries from container..." echo "" # Run the container and extract binaries sudo docker run --rm \ -v "$(pwd)/rocm-complete-output:/output" \ rinhash-rocm-complete if [ $? -eq 0 ]; then echo "" echo "===============================================" echo " BUILD SUCCESSFUL!" echo "===============================================" echo "" echo "Binaries created in rocm-complete-output/:" ls -la rocm-complete-output/ echo "" # Test the built cpuminer echo "Testing built cpuminer..." if [ -f "rocm-complete-output/cpuminer" ]; then echo "cpuminer binary found:" file rocm-complete-output/cpuminer echo "" echo "Available algorithms:" ./rocm-complete-output/cpuminer --help | grep -A 10 "algorithms:" || echo "Could not get algorithm list" fi echo "" echo "To use the ROCm-enabled cpuminer:" echo " 1. Install ROCm runtime on your system:" echo " sudo apt install rocm-dev hip-runtime-amd" echo "" echo " 2. Copy the shared library:" echo " sudo cp rocm-complete-output/librinhash_hip.so /usr/local/lib/" echo " sudo ldconfig" echo "" echo " 3. Run the miner:" echo " ./rocm-complete-output/cpuminer -a rinhash -o -u -p " echo "" echo " 4. Test ROCm support:" echo " ./rocm-complete-output/test-rocm.sh" echo "" else echo "" echo "===============================================" echo " BUILD FAILED!" echo "===============================================" echo "" echo "Check the error messages above for details." echo "" exit 1 fi echo "ROCm GPU build completed successfully!"