Files
mines/rin/miner/build-rocm-official.sh
Dobromir Popov f62fbd3730 wip- to clean
2025-09-05 22:27:58 +03:00

149 lines
4.1 KiB
Bash

#!/bin/bash
# Build script for RinHash ROCm GPU support using official ROCm Docker containers
# Based on https://github.com/ROCm/ROCm-docker
set -e
echo "=================================================="
echo " RinHash ROCm GPU Official Docker 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 "Using official ROCm Docker containers from:"
echo "https://github.com/ROCm/ROCm-docker"
echo ""
echo "This build includes:"
echo " - Official ROCm/HIP development environment"
echo " - RinHash HIP GPU implementation"
echo " - Shared libraries for GPU acceleration"
echo " - Integration documentation"
echo ""
# Pull the official ROCm terminal image first
echo "Pulling official ROCm terminal image..."
sudo docker pull rocm/rocm-terminal:latest
if [ $? -ne 0 ]; then
echo ""
echo "==============================================="
echo " FAILED TO PULL ROCm IMAGE!"
echo "==============================================="
echo ""
echo "Common issues:"
echo "1. Network connectivity problems"
echo "2. Docker daemon not running"
echo "3. Insufficient permissions"
echo ""
echo "Try running: sudo systemctl start docker"
echo ""
exit 1
fi
echo "ROCm image pulled successfully!"
echo ""
# Build the Docker image
echo "Building Docker image with RinHash ROCm support..."
sudo docker build -f Dockerfile.rocm-official -t rinhash-rocm-official .
if [ $? -ne 0 ]; then
echo ""
echo "==============================================="
echo " DOCKER BUILD FAILED!"
echo "==============================================="
echo ""
echo "Common issues:"
echo "1. Source files not found"
echo "2. Build dependencies missing"
echo "3. ROCm compilation errors"
echo ""
exit 1
fi
echo ""
echo "Docker image built successfully!"
echo ""
# Create output directory
mkdir -p rocm-official-output
echo "Extracting built binaries from container..."
echo ""
# Run the container and extract binaries
sudo docker run --rm \
-v "$(pwd)/rocm-official-output:/output" \
rinhash-rocm-official
if [ $? -eq 0 ]; then
echo ""
echo "==============================================="
echo " BUILD SUCCESSFUL!"
echo "==============================================="
echo ""
echo "ROCm GPU libraries created in rocm-official-output/:"
ls -la rocm-official-output/
echo ""
# Test the built libraries
echo "Testing built ROCm libraries..."
if [ -f "rocm-official-output/librinhash_hip.so" ]; then
echo "ROCm GPU library found:"
file rocm-official-output/librinhash_hip.so
echo ""
echo "Library size:"
du -h rocm-official-output/librinhash_hip.so
fi
echo ""
echo "Integration files created:"
echo " - librinhash_hip.so (shared library)"
echo " - test-rocm.sh (test script)"
echo " - INTEGRATION.md (integration guide)"
echo ""
echo "Next steps:"
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-official-output/librinhash_hip.so /usr/local/lib/"
echo " sudo ldconfig"
echo ""
echo " 3. Test ROCm support:"
echo " ./rocm-official-output/test-rocm.sh"
echo ""
echo " 4. Read integration guide:"
echo " cat rocm-official-output/INTEGRATION.md"
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!"
echo ""
echo "For more information about ROCm Docker containers, visit:"
echo "https://github.com/ROCm/ROCm-docker"