From 48cac79a4dd875904eeca8b081172571d9cf2f07 Mon Sep 17 00:00:00 2001 From: canardleteer Date: Wed, 6 Jul 2022 21:43:20 -0700 Subject: [PATCH] Add a Dockerfile with CUDA support. - Multistage build, runtime still larger than it could be. --- README.md | 25 +++++++++++++++++++++++++ docker/Dockerfile.cuda | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 docker/Dockerfile.cuda diff --git a/README.md b/README.md index 1d0009f..606156a 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,31 @@ Privkey: 5JcX7HgrPxEbYKcWhtBT83L3BHcdJ8K8p8X1sNHmcJLsSyMNycZ ## How Split-key Works See the explanation in another similar [project](https://github.com/JeanLucPons/VanitySearch#how-it-works). +# CUDA Docker Image + +## Build Image +```shell +$ docker build -f docker/Dockerfile.cuda -t vanitygen-plusplus:latest . +``` + +The CUDA version from the base image must work with the driver available +through the `container-toolkit`, so YMMV with the `Dockerfile.cuda` default +versions of the images. so you can specify different versions with Docker's +`--build-arg` on: + +- `BASE_CUDA_DEV_CONTAINER` +- `BASE_CUDA_RUN_CONTAINER` + +## Running with [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/overview.html) +```shell +$ docker run -it --network none --gpus all vanitygen-plusplus:latest 1Love +Difficulty: 4476342 +Compiling kernel, can take minutes...done! +Pattern: 1Love +Address: 1LovebbyvEuCnJoKZBXDA6kqts6Q2KG1WJ +Privkey: 5K3J3aA8XkvfdjhJcZ8BJhTUKAjYATCey9AdgahRvoxGB9gLUoD +``` + # Credit Many thanks to following projects: 1. https://github.com/samr7/vanitygen diff --git a/docker/Dockerfile.cuda b/docker/Dockerfile.cuda new file mode 100644 index 0000000..278c8e7 --- /dev/null +++ b/docker/Dockerfile.cuda @@ -0,0 +1,41 @@ +# The CUDA version matters to some degree, and must at least work with the +# driver used in the container host. +ARG BASE_CUDA_DEV_CONTAINER=nvidia/cuda:11.6.2-devel-ubuntu20.04 +ARG BASE_CUDA_RUN_CONTAINER=nvidia/cuda:11.6.2-runtime-ubuntu20.04 + +FROM $BASE_CUDA_DEV_CONTAINER as build + +# Bring in source +WORKDIR /vanitygen-plusplus +COPY . /vanitygen-plusplus + +# Build Requirements +# +# NOTE(canardleteer): I didn't have any luck getting `make test` to work, so +# have omitted `check`. +ENV DEBIAN_FRONTEND=noninteractive +RUN apt update && \ + apt install -y make gcc libssl-dev libpcre3-dev libcurl4-openssl-dev nvidia-opencl-dev && \ + rm -rf /var/lib/apt/lists/* + +# NOTE(canardleteer): `make install` target wanted. +RUN make all + +# The runtime image is approximately half the size of the `build` image. +FROM $BASE_CUDA_RUN_CONTAINER + +# NOTE(canardleteer): `libcurl4` is needed by oclvanityminer. I'd like to use +# something smaller than `nvidia-opencl-dev` if anyone has +# any suggestions. +RUN apt update && apt install -y libcurl4 nvidia-opencl-dev && rm -rf /var/lib/apt/lists/* + +COPY --from=build /vanitygen-plusplus/oclvanitygen++ /usr/bin +COPY --from=build /vanitygen-plusplus/oclvanityminer /usr/bin +COPY --from=build /vanitygen-plusplus/vanitygen++ /usr/bin +COPY --from=build /vanitygen-plusplus/keyconv /usr/bin +COPY --from=build /vanitygen-plusplus/calc_addrs.cl . +COPY --from=build /vanitygen-plusplus/base58prefix.txt . + +# The other binaries are available by setting `--entrypoint` upon a `docker run`. +ENTRYPOINT ["/usr/bin/oclvanitygen++"] +