95 lines
2.5 KiB
Docker
95 lines
2.5 KiB
Docker
# Lightweight Dockerfile for building RinHash with ROCm GPU support
|
|
FROM ubuntu:22.04
|
|
|
|
# Prevent interactive prompts during package installation
|
|
ENV DEBIAN_FRONTEND=noninteractive
|
|
|
|
# Install ROCm and build tools
|
|
RUN apt-get update && apt-get install -y \
|
|
wget \
|
|
gnupg2 \
|
|
software-properties-common \
|
|
&& wget https://repo.radeon.com/rocm/rocm.gpg.key \
|
|
&& apt-key add rocm.gpg.key \
|
|
&& echo 'deb [arch=amd64] https://repo.radeon.com/rocm/apt/5.7 jammy main' > /etc/apt/sources.list.d/rocm.list \
|
|
&& apt-get update \
|
|
&& apt-get install -y \
|
|
rocm-dev \
|
|
hip-dev \
|
|
rocm-smi \
|
|
build-essential \
|
|
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 simple test script
|
|
RUN echo '#!/bin/bash\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\
|
|
else\n\
|
|
echo "ROCm runtime not available - GPU acceleration disabled"\n\
|
|
fi\n\
|
|
echo "Built libraries:"\n\
|
|
ls -la *.so\n\
|
|
' > /output/test-rocm.sh && chmod +x /output/test-rocm.sh
|
|
|
|
# Default command
|
|
CMD ["sh", "-c", "echo 'ROCm GPU build completed successfully!' && ls -la /output/"]
|
|
|