132 lines
3.5 KiB
Docker
132 lines
3.5 KiB
Docker
# Dockerfile for building RinHash with ROCm GPU support using official ROCm containers
|
|
# Based on https://github.com/ROCm/ROCm-docker
|
|
FROM rocm/rocm-terminal:latest
|
|
|
|
# Install additional build tools
|
|
RUN apt-get update && apt-get install -y \
|
|
cmake \
|
|
ninja-build \
|
|
git \
|
|
autotools-dev \
|
|
autoconf \
|
|
automake \
|
|
libtool \
|
|
libcurl4-openssl-dev \
|
|
libjansson-dev \
|
|
libssl-dev \
|
|
libgmp-dev \
|
|
zlib1g-dev \
|
|
pkg-config \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
# Set environment variables for ROCm
|
|
ENV ROCM_PATH=/opt/rocm
|
|
ENV HIP_PATH=/opt/rocm
|
|
ENV PATH=$PATH:/opt/rocm/bin
|
|
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/rocm/lib
|
|
|
|
# Create build directories
|
|
WORKDIR /build
|
|
|
|
# Copy RinHash HIP source files
|
|
COPY gpu/RinHash-hip/ /build/rinhash-hip/
|
|
|
|
# Build RinHash HIP library
|
|
WORKDIR /build/rinhash-hip
|
|
RUN mkdir -p build && \
|
|
cd build && \
|
|
cmake -G "Ninja" \
|
|
-DHIP_PLATFORM=amd \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_INSTALL_PREFIX=/usr/local \
|
|
.. && \
|
|
cmake --build . -j$(nproc) && \
|
|
cmake --install .
|
|
|
|
# Create shared library for integration
|
|
RUN cd /build/rinhash-hip && \
|
|
hipcc -shared -fPIC -O3 \
|
|
-I. \
|
|
rinhash.hip.cu sha3-256.hip.cu \
|
|
-o /usr/local/lib/librinhash_hip.so \
|
|
-lhip_hcc -lhip_device
|
|
|
|
# Create output directory
|
|
RUN mkdir -p /output
|
|
|
|
# Copy built binaries to output
|
|
RUN cp /usr/local/lib/librinhash_hip.so /output/ && \
|
|
cp /usr/local/bin/rinhash-hip-miner /output/ 2>/dev/null || true
|
|
|
|
# Create header files for integration
|
|
RUN mkdir -p /output/include && \
|
|
cp /build/rinhash-hip/*.cuh /output/include/ 2>/dev/null || true
|
|
|
|
# Create a comprehensive test script
|
|
RUN echo '#!/bin/bash\n\
|
|
echo "==============================================="\n\
|
|
echo " RinHash ROCm GPU Test Script"\n\
|
|
echo "==============================================="\n\
|
|
echo ""\n\
|
|
echo "Testing ROCm GPU support..."\n\
|
|
if command -v rocm-smi &> /dev/null; then\n\
|
|
echo "ROCm devices found:"\n\
|
|
rocm-smi --showid\n\
|
|
echo ""\n\
|
|
echo "GPU memory info:"\n\
|
|
rocm-smi --showmeminfo vram\n\
|
|
else\n\
|
|
echo "ROCm runtime not available - GPU acceleration disabled"\n\
|
|
fi\n\
|
|
echo ""\n\
|
|
echo "Built libraries:"\n\
|
|
ls -la *.so\n\
|
|
echo ""\n\
|
|
echo "Library dependencies:"\n\
|
|
ldd librinhash_hip.so 2>/dev/null || echo "Could not check dependencies"\n\
|
|
echo ""\n\
|
|
echo "HIP compiler version:"\n\
|
|
hipcc --version 2>/dev/null || echo "HIP compiler not available"\n\
|
|
' > /output/test-rocm.sh && chmod +x /output/test-rocm.sh
|
|
|
|
# Create integration guide
|
|
RUN echo '# RinHash ROCm GPU Integration Guide\n\
|
|
\n\
|
|
## Prerequisites\n\
|
|
1. Install ROCm runtime on host system:\n\
|
|
sudo apt install rocm-dev hip-runtime-amd\n\
|
|
\n\
|
|
2. Install ROCm kernel modules (if not already installed):\n\
|
|
sudo apt install rocm-dkms\n\
|
|
\n\
|
|
## Integration Steps\n\
|
|
\n\
|
|
1. Copy the shared library:\n\
|
|
sudo cp librinhash_hip.so /usr/local/lib/\n\
|
|
sudo ldconfig\n\
|
|
\n\
|
|
2. Test ROCm support:\n\
|
|
./test-rocm.sh\n\
|
|
\n\
|
|
3. For cpuminer integration:\n\
|
|
- Copy include files to your build system\n\
|
|
- Link against librinhash_hip.so\n\
|
|
- Use HIP runtime functions for GPU acceleration\n\
|
|
\n\
|
|
## Usage Example\n\
|
|
```c\n\
|
|
#include "rinhash_device.cuh"\n\
|
|
\n\
|
|
// Initialize HIP\n\
|
|
hipInit(0);\n\
|
|
\n\
|
|
// Call RinHash GPU function\n\
|
|
rinhash_cuda(input, input_len, output);\n\
|
|
```\n\
|
|
' > /output/INTEGRATION.md
|
|
|
|
# Default command
|
|
CMD ["sh", "-c", "echo 'ROCm GPU build completed successfully!' && ls -la /output/ && echo '' && echo 'Integration guide available in INTEGRATION.md'"]
|
|
|
|
|