1
0
Fork 0

Convert Dockerfile for Nvidia Container Toolkit. Expose "POWER" option.

This commit is contained in:
wandhydrant 2020-03-10 22:36:32 +01:00
parent 8074f0f173
commit 15c3884984
4 changed files with 79 additions and 76 deletions

View file

@ -1,8 +1,14 @@
FROM debian:stable-slim
FROM nvidia/cuda:10.2-base-ubuntu18.04
ARG version="v7.5"
RUN useradd --system folding && \
RUN apt-get update && apt-get install -y --no-install-recommends \
# Install PPA dependency
software-properties-common \
# Install Time Zone Database
tzdata && \
# Install folding@home client
useradd --system folding && \
mkdir -p /opt/fahclient && \
# download and untar
apt-get update -y && \
@ -13,9 +19,14 @@ RUN useradd --system folding && \
chown -R folding:folding /opt/fahclient && \
# cleanup
rm -rf /tmp/fahclient.tar.bz2 && \
apt-get purge -y wget bzip2 && \
# Install Nvidia OpenCL
add-apt-repository -y ppa:graphics-drivers && \
apt-get update && apt-get install -y --install-recommends \
nvidia-opencl-dev && \
# Cleaning up
apt-get remove -y software-properties-common && \
apt-get autoremove -y && \
apt-get clean autoclean && \
apt-get autoremove --yes && \
rm -rf /var/lib/apt/lists/*
COPY --chown=folding:folding entrypoint.sh /opt/fahclient
@ -24,8 +35,9 @@ RUN chmod +x /opt/fahclient/entrypoint.sh
ENV USER "Anonymous"
ENV TEAM "0"
ENV ENABLE_GPU "false"
ENV ENABLE_GPU "true"
ENV ENABLE_SMP "true"
ENV POWER "full"
USER folding
WORKDIR /opt/fahclient
@ -34,3 +46,5 @@ EXPOSE 7396
EXPOSE 36330
ENTRYPOINT ["/opt/fahclient/entrypoint.sh"]

106
README.md
View file

@ -1,48 +1,70 @@
# Folding@Home Docker
# Folding@Home Dockerfile for Nvidia GPUs
Folding@home is a project focused on disease research. The problems were solving require so many computer calcul­ations and we need your help to find the cures!
Folding@home is a project focused on disease research.
Right now, to the best of my knowledge, they are the
only GPU-based distributed computing project who
are running calculations against Coronavirus.
Here is a combination of [Nikolay Yurin's Folding@home Dockerfile](https://github.com/yurinnick/folding-at-home-docker)
and the [BOINC Nvidia Dockerfile](https://github.com/BOINC/boinc-client-docker),
so that you have an additional layer of sandboxing around
GPU computations of Folding@home. In case you are allowed
to use other people's computers, or your employer's,
using Docker containers might even be a requirement.
## Usage
### docker
### Build the image locally
I did not set up anything pre-built on the Docker hub.
Please inspect the Dockerfile and build the image yourself:
```
docker run \
cd <git-checkout>
docker build -t my-fah-nvidia-image .
```
### and run it:
GPU access by containers went through several stages:
first direct export of /dev/dri and other devices; then
solutions with Docker "runtimes" (nvidia-docker v1
and v2); the current variant is the Nvidia Container
Toolkit. The latter is the only one I tested this with.
As for the BOINC Nvidia container, please:
1. Install Docker (19.03 or later);
2. Install the Nvidia drivers (so that "nvidia-smi" gives you output on the host);
3. Install the [Nvidia Container Toolkit](https://github.com/NVIDIA/nvidia-docker) (see "Usage" on the linked page to test nvidia-smi in a container).
Finally you can run this container:
```
docker run -d \
--name folding-at-home \
-p 7396:7396 \
-p 36330:36330 \
--gpus all \
-h node \
-e USER=Anonymous \
-e TEAM=0 \
-e ENABLE_GPU=false \
-e ENABLE_GPU=true \
-e ENABLE_SMP=true \
--restart unless-stopped \
yurinnick/folding-at-home
my-fah-nvidia-image \
--allow 0/0 --web-allow 0/0
```
### docker-compose
``-h node`` sets an anonymous hostname instead of copying yours.
The last line means that Folding@home's web access will let everybody in,
but as the port is not exported, you can use it only from the Docker host,
pointing your browser at the container:
```
---
version: "3"
services:
folding-at-home:
image: yurinnick/folding-at-home
container_name: folding-at-home
environment:
- USER=Anonymous
- TEAM=0
- ENABLE_GPU=false
- ENABLE_SMP=true
ports:
- 7396:7396
- 36330:36330
restart: unless-stopped
```
### Kubernetes
```
TDB
echo http://$(docker inspect --format "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" folding-at-home):7396
```
## Parameters
@ -50,30 +72,12 @@ TDB
- USER - Folding@home username (default: Anonymous)
- TEAM - Foldinghome team number (default: 0)
- PASSKEY - [optional] Folding@home [passkey](https://apps.foldingathome.org/getpasskey)
- ENABLE_GPU - Enable GPU compute (default: false)
- ENABLE_GPU - Enable GPU compute (default: true)
- ENABLE_SMP - Enable auto-configuration of SMP slots (default: true)
- POWER - by default "full"; but you might want to switch to "medium" and see how hot your hardware gets (especially laptops). "light" did not use the GPU at all for me. You can always switch this in the web interface.
Additional configuration parameters can be passed as command line arguments. To get the full list of parameters run:
```
docker run yurinnick/folding-at-home:latest --help
```
## Web Interface
Web interface is locked to `localhost` by default, to enable remote access run:
```
docker run \
--name folding-at-home \
-p 7396:7396 \
-p 36330:36330 \
-e USER=Anonymous \
-e TEAM=0 \
-e ENABLE_GPU=false \
-e ENABLE_SMP=true \
--restart unless-stopped \
yurinnick/folding-at-home \
--allow 0/0 \
--web-allow 0/0
docker run my-fah-nvidia-image --help
```

View file

@ -1,15 +0,0 @@
---
version: "3"
services:
folding-at-home:
image: yurinnick/folding-at-home
container_name: folding-at-home
environment:
- USER=Anonymous
- TEAM=0
- ENABLE_GPU=false
- ENABLE_SMP=true
ports:
- 7396:7396
- 36330:36330
restart: unless-stopped

View file

@ -7,6 +7,6 @@ set -e
--passkey="${PASSKEY}" \
--gpu="${ENABLE_GPU}" \
--smp="${ENABLE_SMP}" \
--power=full \
--power="${POWER}" \
--gui-enabled=false \
"${@}"