Browse Source

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

master
wandhydrant 8 months ago
parent
commit
15c3884984
4 changed files with 78 additions and 75 deletions
  1. 23
    9
      Dockerfile
  2. 54
    50
      README.md
  3. 0
    15
      docker-compose.yaml
  4. 1
    1
      entrypoint.sh

+ 23
- 9
Dockerfile View File

@@ -1,21 +1,32 @@
1
-FROM debian:stable-slim
1
+FROM nvidia/cuda:10.2-base-ubuntu18.04
2 2
 
3 3
 ARG version="v7.5"
4 4
 
5
-RUN useradd --system folding && \
5
+RUN apt-get update && apt-get install -y --no-install-recommends \
6
+# Install PPA dependency
7
+    software-properties-common \
8
+# Install Time Zone Database
9
+        tzdata && \
10
+# Install folding@home client
11
+    useradd --system folding && \
6 12
     mkdir -p /opt/fahclient && \
7
-    # download and untar
13
+# download and untar
8 14
     apt-get update -y && \
9 15
     apt-get install -y wget bzip2 && \
10 16
     wget https://download.foldingathome.org/releases/public/release/fahclient/debian-stable-64bit/${version}/latest.tar.bz2 -O /tmp/fahclient.tar.bz2 && \
11 17
     tar -xjf /tmp/fahclient.tar.bz2 -C /opt/fahclient --strip-components=1 && \
12
-    # fix permissions
18
+# fix permissions
13 19
     chown -R folding:folding /opt/fahclient && \
14
-    # cleanup
20
+# cleanup
15 21
     rm -rf /tmp/fahclient.tar.bz2 && \
16
-    apt-get purge -y wget bzip2 && \
22
+# Install Nvidia OpenCL
23
+    add-apt-repository -y ppa:graphics-drivers && \
24
+    apt-get update && apt-get install -y --install-recommends \
25
+    nvidia-opencl-dev && \
26
+# Cleaning up
27
+    apt-get remove -y software-properties-common && \
28
+    apt-get autoremove -y && \
17 29
     apt-get clean autoclean && \
18
-    apt-get autoremove --yes && \
19 30
     rm -rf /var/lib/apt/lists/*
20 31
 
21 32
 COPY --chown=folding:folding entrypoint.sh /opt/fahclient
@@ -24,8 +35,9 @@ RUN chmod +x /opt/fahclient/entrypoint.sh
24 35
 
25 36
 ENV USER "Anonymous"
26 37
 ENV TEAM "0"
27
-ENV ENABLE_GPU "false"
38
+ENV ENABLE_GPU "true"
28 39
 ENV ENABLE_SMP "true"
40
+ENV POWER "full"
29 41
 
30 42
 USER folding
31 43
 WORKDIR /opt/fahclient
@@ -33,4 +45,6 @@ WORKDIR /opt/fahclient
33 45
 EXPOSE 7396
34 46
 EXPOSE 36330
35 47
 
36
-ENTRYPOINT ["/opt/fahclient/entrypoint.sh"]
48
+ENTRYPOINT ["/opt/fahclient/entrypoint.sh"]
49
+
50
+

+ 54
- 50
README.md View File

@@ -1,48 +1,70 @@
1
-# Folding@Home Docker
1
+# Folding@Home Dockerfile for Nvidia GPUs
2 2
 
3
-Folding@home is a project focused on disease research. The problems we’re solving require so many computer calcul­ations – and we need your help to find the cures!
3
+Folding@home is a project focused on disease research.
4
+Right now, to the best of my knowledge, they are the
5
+only GPU-based distributed computing project who
6
+are running calculations against Coronavirus.
7
+
8
+Here is a combination of [Nikolay Yurin's Folding@home Dockerfile](https://github.com/yurinnick/folding-at-home-docker)
9
+and the [BOINC Nvidia Dockerfile](https://github.com/BOINC/boinc-client-docker),
10
+so that you have an additional layer of sandboxing around
11
+GPU computations of Folding@home. In case you are allowed
12
+to use other people's computers, or your employer's,
13
+using Docker containers might even be a requirement.
4 14
 
5 15
 ## Usage
6 16
 
7
-### docker
17
+### Build the image locally
18
+
19
+I did not set up anything pre-built on the Docker hub.
20
+
21
+Please inspect the Dockerfile and build the image yourself:
22
+
23
+```
24
+cd <git-checkout>
25
+docker build -t my-fah-nvidia-image .
26
+```
27
+
28
+### and run it:
29
+
30
+GPU access by containers went through several stages:
31
+first direct export of /dev/dri and other devices; then
32
+solutions with Docker "runtimes" (nvidia-docker v1
33
+and v2); the current variant is the Nvidia Container
34
+Toolkit. The latter is the only one I tested this with.
35
+
36
+As for the BOINC Nvidia container, please:
37
+
38
+1. Install Docker (19.03 or later);
39
+
40
+2. Install the Nvidia drivers (so that "nvidia-smi" gives you output on the host);
41
+
42
+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).
43
+
44
+Finally you can run this container:
8 45
 
9 46
 ```
10
-docker run \
47
+docker run -d \
11 48
   --name folding-at-home \
12
-  -p 7396:7396 \
13
-  -p 36330:36330 \
49
+  --gpus all \
50
+  -h node \
14 51
   -e USER=Anonymous \
15 52
   -e TEAM=0 \
16
-  -e ENABLE_GPU=false \
53
+  -e ENABLE_GPU=true \
17 54
   -e ENABLE_SMP=true \
18 55
   --restart unless-stopped \
19
-  yurinnick/folding-at-home
56
+  my-fah-nvidia-image \
57
+  --allow 0/0 --web-allow 0/0
20 58
 ```
21 59
 
22
-### docker-compose
60
+``-h node`` sets an anonymous hostname instead of copying yours.
23 61
 
24
-```
25
----
26
-version: "3"
27
-services:
28
-  folding-at-home:
29
-    image: yurinnick/folding-at-home
30
-    container_name: folding-at-home
31
-    environment:
32
-      - USER=Anonymous
33
-      - TEAM=0
34
-      - ENABLE_GPU=false
35
-      - ENABLE_SMP=true
36
-    ports:
37
-      - 7396:7396
38
-      - 36330:36330
39
-    restart: unless-stopped
40
-```
41
-
42
-### Kubernetes
62
+The last line means that Folding@home's web access will let everybody in,
63
+but as the port is not exported, you can use it only from the Docker host,
64
+pointing your browser at the container:
43 65
 
44 66
 ```
45
-TDB
67
+echo http://$(docker inspect  --format "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" folding-at-home):7396
46 68
 ```
47 69
 
48 70
 ## Parameters
@@ -50,30 +72,12 @@ TDB
50 72
 - USER - Folding@home username (default: Anonymous)
51 73
 - TEAM - Foldinghome team number (default: 0)
52 74
 - PASSKEY - [optional] Folding@home [passkey](https://apps.foldingathome.org/getpasskey)
53
-- ENABLE_GPU - Enable GPU compute (default: false)
75
+- ENABLE_GPU - Enable GPU compute (default: true)
54 76
 - ENABLE_SMP - Enable auto-configuration of SMP slots (default: true)
77
+- 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.
55 78
 
56 79
 Additional configuration parameters can be passed as command line arguments. To get the full list of parameters run:
57 80
 
58 81
 ```
59
-docker run yurinnick/folding-at-home:latest --help
60
-```
61
-
62
-## Web Interface
63
-
64
-Web interface is locked to `localhost` by default, to enable remote access run:
65
-
82
+docker run my-fah-nvidia-image --help
66 83
 ```
67
-docker run \
68
-  --name folding-at-home \
69
-  -p 7396:7396 \
70
-  -p 36330:36330 \
71
-  -e USER=Anonymous \
72
-  -e TEAM=0 \
73
-  -e ENABLE_GPU=false \
74
-  -e ENABLE_SMP=true \
75
-  --restart unless-stopped \
76
-  yurinnick/folding-at-home \
77
-  --allow 0/0 \
78
-  --web-allow 0/0
79
-```

+ 0
- 15
docker-compose.yaml View File

@@ -1,15 +0,0 @@
1
----
2
-version: "3"
3
-services:
4
-  folding-at-home:
5
-    image: yurinnick/folding-at-home
6
-    container_name: folding-at-home
7
-    environment:
8
-      - USER=Anonymous
9
-      - TEAM=0
10
-      - ENABLE_GPU=false
11
-      - ENABLE_SMP=true
12
-    ports:
13
-      - 7396:7396
14
-      - 36330:36330
15
-    restart: unless-stopped

+ 1
- 1
entrypoint.sh View File

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

Loading…
Cancel
Save