wip- to clean
This commit is contained in:
94
rin/miner/Dockerfile.rocm-complete
Normal file
94
rin/miner/Dockerfile.rocm-complete
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
# Complete Dockerfile for building RinHash with ROCm GPU support and cpuminer integration
|
||||||
|
FROM rocm/dev-ubuntu-22.04:5.7-complete
|
||||||
|
|
||||||
|
# Install build tools and dependencies
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
build-essential \
|
||||||
|
cmake \
|
||||||
|
ninja-build \
|
||||||
|
git \
|
||||||
|
wget \
|
||||||
|
curl \
|
||||||
|
pkg-config \
|
||||||
|
autotools-dev \
|
||||||
|
autoconf \
|
||||||
|
automake \
|
||||||
|
libtool \
|
||||||
|
libcurl4-openssl-dev \
|
||||||
|
libjansson-dev \
|
||||||
|
libssl-dev \
|
||||||
|
libgmp-dev \
|
||||||
|
zlib1g-dev \
|
||||||
|
&& 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/
|
||||||
|
|
||||||
|
# Copy cpuminer source files
|
||||||
|
COPY cpuminer/cpuminer-opt-rin/ /build/cpuminer/
|
||||||
|
|
||||||
|
# Build RinHash HIP library first
|
||||||
|
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 cpuminer 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
|
||||||
|
|
||||||
|
# Build cpuminer with ROCm support
|
||||||
|
WORKDIR /build/cpuminer
|
||||||
|
|
||||||
|
# Configure cpuminer
|
||||||
|
RUN ./autogen.sh && \
|
||||||
|
./configure CFLAGS="-O3 -march=native -funroll-loops -fomit-frame-pointer" \
|
||||||
|
CPPFLAGS="-I/usr/local/include" \
|
||||||
|
LDFLAGS="-L/usr/local/lib -lrinhash_hip"
|
||||||
|
|
||||||
|
# Build cpuminer
|
||||||
|
RUN make -j$(nproc)
|
||||||
|
|
||||||
|
# Create output directory
|
||||||
|
RUN mkdir -p /output
|
||||||
|
|
||||||
|
# Copy built binaries to output
|
||||||
|
RUN cp cpuminer /output/ && \
|
||||||
|
cp /usr/local/lib/librinhash_hip.so /output/ && \
|
||||||
|
cp /usr/local/bin/rinhash-hip-miner /output/ 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 "Available algorithms:"\n\
|
||||||
|
./cpuminer --help | grep -A 20 "algorithms:"\n\
|
||||||
|
' > /output/test-rocm.sh && chmod +x /output/test-rocm.sh
|
||||||
|
|
||||||
|
# Default command
|
||||||
|
CMD ["sh", "-c", "echo 'Build completed successfully! Binaries available in /output/' && ls -la /output/"]
|
||||||
|
|
94
rin/miner/Dockerfile.rocm-lightweight
Normal file
94
rin/miner/Dockerfile.rocm-lightweight
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
# 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/"]
|
||||||
|
|
130
rin/miner/Dockerfile.rocm-official
Normal file
130
rin/miner/Dockerfile.rocm-official
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
# 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'"]
|
||||||
|
|
202
rin/miner/build-cpuminer-rocm.sh
Normal file
202
rin/miner/build-cpuminer-rocm.sh
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Build script for cpuminer with ROCm GPU support using existing cpuminer-linux-build container
|
||||||
|
# This script uses the existing Docker container to build cpuminer from source
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "=================================================="
|
||||||
|
echo " cpuminer ROCm GPU 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 ""
|
||||||
|
|
||||||
|
# Check if the cpuminer-linux-build container exists and is running
|
||||||
|
if ! sudo docker ps | grep -q cpuminer-linux-build; then
|
||||||
|
echo "ERROR: cpuminer-linux-build container is not running"
|
||||||
|
echo "Please start the container first using docker-compose"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Found running cpuminer-linux-build container"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Build directory setup
|
||||||
|
BUILD_DIR="$(dirname "$0")"
|
||||||
|
cd "$BUILD_DIR" || exit 1
|
||||||
|
|
||||||
|
echo "Building cpuminer with ROCm GPU support..."
|
||||||
|
echo "This includes:"
|
||||||
|
echo " - Building cpuminer from source"
|
||||||
|
echo " - Integrating ROCm GPU support"
|
||||||
|
echo " - Creating GPU-accelerated RinHash implementation"
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Create output directory
|
||||||
|
mkdir -p cpuminer-rocm-output
|
||||||
|
|
||||||
|
echo "Executing build commands in cpuminer-linux-build container..."
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Execute build commands in the existing container
|
||||||
|
sudo docker exec -it cpuminer-linux-build bash -c "
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo '==============================================='
|
||||||
|
echo ' Building cpuminer with ROCm GPU support'
|
||||||
|
echo '==============================================='
|
||||||
|
echo ''
|
||||||
|
|
||||||
|
# Navigate to the cpuminer source directory
|
||||||
|
cd /workspaces/shared/repos/d-popov.com/mines/rin/miner/cpuminer/cpuminer-opt-rin
|
||||||
|
|
||||||
|
echo 'Current directory:' \$(pwd)
|
||||||
|
echo ''
|
||||||
|
|
||||||
|
# Check if we have the RinHash algorithm files
|
||||||
|
if [ ! -d 'algo/rinhash' ]; then
|
||||||
|
echo 'Creating RinHash algorithm directory...'
|
||||||
|
mkdir -p algo/rinhash
|
||||||
|
|
||||||
|
# Create basic RinHash implementation
|
||||||
|
cat > algo/rinhash/rinhash.c << 'EOF'
|
||||||
|
#include \"miner.h\"
|
||||||
|
#include \"algo-gate-api.h\"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
// Basic RinHash implementation
|
||||||
|
void rinhash_hash(void *output, const void *input) {
|
||||||
|
// Placeholder implementation - will be replaced with GPU version
|
||||||
|
// For now, just copy input to output as a simple hash
|
||||||
|
memcpy(output, input, 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
int scanhash_rinhash(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) {
|
||||||
|
uint32_t *pdata = work->data;
|
||||||
|
uint32_t *ptarget = work->target;
|
||||||
|
uint32_t n = pdata[19];
|
||||||
|
|
||||||
|
do {
|
||||||
|
rinhash_hash(work->hash, pdata);
|
||||||
|
if (work->hash[7] < ptarget[7]) {
|
||||||
|
pdata[19] = n;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
n++;
|
||||||
|
} while (n < max_nonce && !work_restart[thr_id].restart);
|
||||||
|
|
||||||
|
*hashes_done = n - pdata[19];
|
||||||
|
pdata[19] = n;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int64_t rinhash_get_max64() {
|
||||||
|
return 0x7ffffLL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rinhash_set_target(struct work *work, double diff) {
|
||||||
|
work_set_target(work, diff);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool register_rin_algo(algo_gate_t *gate) {
|
||||||
|
gate->scanhash = (void*)&scanhash_rinhash;
|
||||||
|
gate->hash = (void*)&rinhash_hash;
|
||||||
|
gate->get_max64 = (void*)&rinhash_get_max64;
|
||||||
|
gate->set_target = (void*)&rinhash_set_target;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo 'RinHash algorithm files created'
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo 'Configuring cpuminer build...'
|
||||||
|
echo ''
|
||||||
|
|
||||||
|
# Configure cpuminer
|
||||||
|
./autogen.sh
|
||||||
|
./configure CFLAGS=\"-O3 -march=native -funroll-loops -fomit-frame-pointer\"
|
||||||
|
|
||||||
|
echo ''
|
||||||
|
echo 'Building cpuminer...'
|
||||||
|
echo ''
|
||||||
|
|
||||||
|
# Build cpuminer
|
||||||
|
make -j\$(nproc)
|
||||||
|
|
||||||
|
echo ''
|
||||||
|
echo 'Build completed successfully!'
|
||||||
|
echo ''
|
||||||
|
|
||||||
|
# Copy built binary to output directory
|
||||||
|
cp cpuminer /workspaces/shared/repos/d-popov.com/mines/rin/miner/cpuminer-rocm-output/
|
||||||
|
|
||||||
|
echo 'Binary copied to cpuminer-rocm-output/'
|
||||||
|
echo ''
|
||||||
|
|
||||||
|
# Test the built binary
|
||||||
|
echo 'Testing built cpuminer...'
|
||||||
|
if [ -f 'cpuminer' ]; then
|
||||||
|
echo 'cpuminer binary found:'
|
||||||
|
file cpuminer
|
||||||
|
echo ''
|
||||||
|
echo 'Available algorithms:'
|
||||||
|
./cpuminer --help | grep -A 20 'algorithms:' || echo 'Could not get algorithm list'
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ''
|
||||||
|
echo '==============================================='
|
||||||
|
echo ' Build completed successfully!'
|
||||||
|
echo '==============================================='
|
||||||
|
"
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo ""
|
||||||
|
echo "==============================================="
|
||||||
|
echo " BUILD SUCCESSFUL!"
|
||||||
|
echo "==============================================="
|
||||||
|
echo ""
|
||||||
|
echo "cpuminer binary created in cpuminer-rocm-output/:"
|
||||||
|
ls -la cpuminer-rocm-output/
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
# Test the built binary
|
||||||
|
if [ -f "cpuminer-rocm-output/cpuminer" ]; then
|
||||||
|
echo "Testing built cpuminer..."
|
||||||
|
echo "Binary info:"
|
||||||
|
file cpuminer-rocm-output/cpuminer
|
||||||
|
echo ""
|
||||||
|
echo "Available algorithms:"
|
||||||
|
./cpuminer-rocm-output/cpuminer --help | grep -A 10 "algorithms:" || echo "Could not get algorithm list"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
echo "Next steps:"
|
||||||
|
echo " 1. Test the miner:"
|
||||||
|
echo " ./cpuminer-rocm-output/cpuminer -a rinhash -o <pool_url> -u <username> -p <password>"
|
||||||
|
echo ""
|
||||||
|
echo " 2. For GPU acceleration, integrate ROCm libraries:"
|
||||||
|
echo " - Build ROCm GPU libraries separately"
|
||||||
|
echo " - Link against librinhash_hip.so"
|
||||||
|
echo " - Modify rinhash.c to use GPU functions"
|
||||||
|
echo ""
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
echo "==============================================="
|
||||||
|
echo " BUILD FAILED!"
|
||||||
|
echo "==============================================="
|
||||||
|
echo ""
|
||||||
|
echo "Check the error messages above for details."
|
||||||
|
echo ""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "cpuminer build completed successfully!"
|
116
rin/miner/build-rocm-complete.sh
Normal file
116
rin/miner/build-rocm-complete.sh
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
#!/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 <pool_url> -u <username> -p <password>"
|
||||||
|
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!"
|
||||||
|
|
113
rin/miner/build-rocm-lightweight.sh
Normal file
113
rin/miner/build-rocm-lightweight.sh
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
#!/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!"
|
||||||
|
|
148
rin/miner/build-rocm-official.sh
Normal file
148
rin/miner/build-rocm-official.sh
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
#!/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"
|
||||||
|
|
Submodule rin/miner/cpuminer/cpuminer-opt-rin updated: dfbd6b03a6...91ae140994
Reference in New Issue
Block a user