#!/bin/bash # Lightweight Docker-based build script for RinHash ROCm GPU support # This script builds ROCm GPU support in a lightweight Docker container set -e echo "==================================================" echo " RinHash ROCm GPU Lightweight 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 lightweight Docker image with ROCm GPU support..." echo "This includes:" echo " - ROCm/HIP development environment" echo " - RinHash HIP GPU implementation" echo " - Shared libraries for GPU acceleration" echo "" # Build the lightweight Docker image echo "Building Docker image..." sudo docker build -f Dockerfile.rocm-lightweight -t rinhash-rocm-lightweight . 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 repository not accessible" echo "" exit 1 fi echo "" echo "Docker image built successfully!" echo "" # Create output directory mkdir -p rocm-gpu-output echo "Extracting built binaries from container..." echo "" # Run the container and extract binaries sudo docker run --rm \ -v "$(pwd)/rocm-gpu-output:/output" \ rinhash-rocm-lightweight if [ $? -eq 0 ]; then echo "" echo "===============================================" echo " BUILD SUCCESSFUL!" echo "===============================================" echo "" echo "ROCm GPU libraries created in rocm-gpu-output/:" ls -la rocm-gpu-output/ echo "" # Test the built libraries echo "Testing built ROCm libraries..." if [ -f "rocm-gpu-output/librinhash_hip.so" ]; then echo "ROCm GPU library found:" file rocm-gpu-output/librinhash_hip.so echo "" echo "Library dependencies:" ldd rocm-gpu-output/librinhash_hip.so 2>/dev/null || echo "Could not check dependencies" fi echo "" echo "Next steps to integrate with 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-gpu-output/librinhash_hip.so /usr/local/lib/" echo " sudo ldconfig" echo "" echo " 3. Test ROCm support:" echo " ./rocm-gpu-output/test-rocm.sh" echo "" echo " 4. Build cpuminer with ROCm integration (see next step)" 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!"