Преглед на файлове

added examples for python R and GPU

master
ma0 преди 5 години
ревизия
9ea30b19f9
променени са 38 файла, в които са добавени 418 реда и са изтрити 0 реда
  1. 11
    0
      docker/R/read/condor.submit
  2. 0
    0
      docker/R/read/docker_stderror
  3. 4
    0
      docker/R/read/read.R
  4. 0
    0
      docker/R/read/read_R_err.err
  5. 19
    0
      docker/R/read/read_R_log.log
  6. 2
    0
      docker/R/read/read_R_out.out
  7. 7
    0
      docker/R/requirements/Dockerfile
  8. 10
    0
      docker/R/requirements/compile_docker_image.sh
  9. 11
    0
      docker/R/requirements/condor.submit
  10. 21
    0
      docker/R/requirements/docker_stderror
  11. 1
    0
      docker/R/requirements/install.R
  12. 3
    0
      docker/R/requirements/requirements.R
  13. 0
    0
      docker/R/requirements/requirements_R_err.err
  14. 19
    0
      docker/R/requirements/requirements_R_log.log
  15. 42
    0
      docker/R/requirements/requirements_R_out.out
  16. 11
    0
      docker/R/write/condor.submit
  17. 27
    0
      docker/R/write/docker_stderror
  18. 4
    0
      docker/R/write/write.R
  19. 0
    0
      docker/R/write/write_R_err.err
  20. 19
    0
      docker/R/write/write_R_log.log
  21. 0
    0
      docker/R/write/write_R_out.out
  22. 11
    0
      docker/python/read/condor.submit
  23. 23
    0
      docker/python/read/docker_stderror
  24. 12
    0
      docker/python/read/read.py
  25. 3
    0
      docker/python/read/read.py.save
  26. 0
    0
      docker/python/read/read_python_err.err
  27. 19
    0
      docker/python/read/read_python_log.log
  28. 2
    0
      docker/python/read/read_python_out.out
  29. 7
    0
      docker/python/requirements/Dockerfile
  30. 10
    0
      docker/python/requirements/compile_docker_image.sh
  31. 11
    0
      docker/python/requirements/condor.submit
  32. 8
    0
      docker/python/requirements/requirements.py
  33. 1
    0
      docker/python/requirements/requirements.txt
  34. 11
    0
      docker/python/write/condor.submit
  35. 11
    0
      docker/python/write/write.py
  36. 55
    0
      gpu/add.cu
  37. 15
    0
      gpu/condor.submit
  38. 8
    0
      gpu/run.sh

+ 11
- 0
docker/R/read/condor.submit Целия файл

@@ -0,0 +1,11 @@
1
+should_transfer_files = Yes
2
+when_to_transfer_output = ON_EXIT_OR_EVICT
3
+transfer_input_files = read.R
4
+Universe = docker
5
+docker_image = r-base
6
+Executable = /usr/bin/Rscript
7
+Arguments = read.R /datos/ma0/test.txt
8
+Log = read_R_log.log
9
+Output = read_R_out.out
10
+Error = read_R_err.err
11
+Queue

+ 0
- 0
docker/R/read/docker_stderror Целия файл


+ 4
- 0
docker/R/read/read.R Целия файл

@@ -0,0 +1,4 @@
1
+args <- commandArgs(TRUE)
2
+data <- read.delim(args[1])
3
+print(data)
4
+

+ 0
- 0
docker/R/read/read_R_err.err Целия файл


+ 19
- 0
docker/R/read/read_R_log.log Целия файл

@@ -0,0 +1,19 @@
1
+000 (050.000.000) 05/10 11:13:59 Job submitted from host: <192.168.27.25:9618?addrs=192.168.27.25-9618&noUDP&sock=1446571_f6bf_4>
2
+...
3
+001 (050.000.000) 05/10 11:14:01 Job executing on host: <192.168.27.17:9618?addrs=192.168.27.17-9618&noUDP&sock=27247_c111_3>
4
+...
5
+005 (050.000.000) 05/10 11:14:02 Job terminated.
6
+	(1) Normal termination (return value 0)
7
+		Usr 0 00:00:00, Sys 0 00:00:00  -  Run Remote Usage
8
+		Usr 0 00:00:00, Sys 0 00:00:00  -  Run Local Usage
9
+		Usr 0 00:00:00, Sys 0 00:00:00  -  Total Remote Usage
10
+		Usr 0 00:00:00, Sys 0 00:00:00  -  Total Local Usage
11
+	49  -  Run Bytes Sent By Job
12
+	67  -  Run Bytes Received By Job
13
+	49  -  Total Bytes Sent By Job
14
+	67  -  Total Bytes Received By Job
15
+	Partitionable Resources :    Usage  Request Allocated 
16
+	   Cpus                 :        0        1         1 
17
+	   Disk (KB)            :       16        1     45972 
18
+	   Memory (MB)          :                 0      1024 
19
+...

+ 2
- 0
docker/R/read/read_R_out.out Целия файл

@@ -0,0 +1,2 @@
1
+[1] hello.world
2
+<0 rows> (or 0-length row.names)

+ 7
- 0
docker/R/requirements/Dockerfile Целия файл

@@ -0,0 +1,7 @@
1
+FROM r-base
2
+
3
+WORKDIR /code
4
+ADD install.R /code
5
+RUN Rscript install.R
6
+
7
+CMD ["Rscript"]

+ 10
- 0
docker/R/requirements/compile_docker_image.sh Целия файл

@@ -0,0 +1,10 @@
1
+#!/bin/bash
2
+
3
+if [ -z "$1" ]; then
4
+    echo "A name for the image is needed"
5
+    exit 1
6
+fi
7
+
8
+docker build -t 192.168.27.25:5000/$(whoami)/$1 .
9
+docker push 192.168.27.25:5000/$(whoami)/$1
10
+

+ 11
- 0
docker/R/requirements/condor.submit Целия файл

@@ -0,0 +1,11 @@
1
+should_transfer_files = Yes
2
+when_to_transfer_output = ON_EXIT_OR_EVICT
3
+transfer_input_files = requirements.R
4
+Universe = docker
5
+docker_image = 192.168.27.25:5000/ma0/plumber_test
6
+Executable = /usr/bin/Rscript
7
+Arguments = requirements.R
8
+Log = requirements_R_log.log
9
+Output = requirements_R_out.out
10
+Error = requirements_R_err.err
11
+Queue

+ 21
- 0
docker/R/requirements/docker_stderror Целия файл

@@ -0,0 +1,21 @@
1
+Unable to find image '192.168.27.25:5000/ma0/plumber_test:latest' locally
2
+latest: Pulling from ma0/plumber_test
3
+0656ed1d7f85: Already exists
4
+c753f78c1082: Already exists
5
+9b7d77a2fb38: Already exists
6
+f759fbe73258: Already exists
7
+5dbb370e90a3: Already exists
8
+77bb82bbd854: Already exists
9
+03cc54129ca4: Pulling fs layer
10
+821d7fd1ddb1: Pulling fs layer
11
+abf1a70cd42e: Pulling fs layer
12
+03cc54129ca4: Download complete
13
+821d7fd1ddb1: Verifying Checksum
14
+821d7fd1ddb1: Download complete
15
+03cc54129ca4: Pull complete
16
+821d7fd1ddb1: Pull complete
17
+abf1a70cd42e: Verifying Checksum
18
+abf1a70cd42e: Download complete
19
+abf1a70cd42e: Pull complete
20
+Digest: sha256:be7a2bdd848f4610f1ea5de4bb0c53d1c88d08a4b023cb791e640c9ad3dd9105
21
+Status: Downloaded newer image for 192.168.27.25:5000/ma0/plumber_test:latest

+ 1
- 0
docker/R/requirements/install.R Целия файл

@@ -0,0 +1 @@
1
+if(!require(plumber))install.packages("plumber")

+ 3
- 0
docker/R/requirements/requirements.R Целия файл

@@ -0,0 +1,3 @@
1
+library(plumber)
2
+plumb
3
+

+ 0
- 0
docker/R/requirements/requirements_R_err.err Целия файл


+ 19
- 0
docker/R/requirements/requirements_R_log.log Целия файл

@@ -0,0 +1,19 @@
1
+000 (051.000.000) 05/10 12:05:50 Job submitted from host: <192.168.27.25:9618?addrs=192.168.27.25-9618&noUDP&sock=1446571_f6bf_4>
2
+...
3
+001 (051.000.000) 05/10 12:05:52 Job executing on host: <192.168.27.17:9618?addrs=192.168.27.17-9618&noUDP&sock=27247_c111_3>
4
+...
5
+005 (051.000.000) 05/10 12:05:56 Job terminated.
6
+	(1) Normal termination (return value 0)
7
+		Usr 0 00:00:00, Sys 0 00:00:00  -  Run Remote Usage
8
+		Usr 0 00:00:00, Sys 0 00:00:00  -  Run Local Usage
9
+		Usr 0 00:00:00, Sys 0 00:00:00  -  Total Remote Usage
10
+		Usr 0 00:00:00, Sys 0 00:00:00  -  Total Local Usage
11
+	2015  -  Run Bytes Sent By Job
12
+	24  -  Run Bytes Received By Job
13
+	2015  -  Total Bytes Sent By Job
14
+	24  -  Total Bytes Received By Job
15
+	Partitionable Resources :    Usage  Request Allocated 
16
+	   Cpus                 :        0        1         1 
17
+	   Disk (KB)            :       18        1     45972 
18
+	   Memory (MB)          :                 0      1024 
19
+...

+ 42
- 0
docker/R/requirements/requirements_R_out.out Целия файл

@@ -0,0 +1,42 @@
1
+function (file, dir = ".") 
2
+{
3
+    dirMode <- NULL
4
+    if (!missing(file) && !missing(dir)) {
5
+        stop("You must set either the file or the directory parameter, not both")
6
+    }
7
+    else if (missing(file)) {
8
+        if (identical(dir, "")) {
9
+            stop("You must specify either a file or directory parameter")
10
+        }
11
+        dirMode <- TRUE
12
+        dir <- sub("/$", "", dir)
13
+        file <- list.files(dir, "^plumber\\.r$", ignore.case = TRUE, 
14
+            full.names = TRUE)
15
+        if (length(file) == 0) {
16
+            stop("No plumber.R file found in the specified directory: ", 
17
+                dir)
18
+        }
19
+    }
20
+    else {
21
+        dirMode <- FALSE
22
+    }
23
+    entrypoint <- list.files(dir, "^entrypoint\\.r$", ignore.case = TRUE)
24
+    if (dirMode && length(entrypoint) > 0) {
25
+        old <- setwd(dir)
26
+        on.exit(setwd(old))
27
+        x <- source(entrypoint)
28
+        pr <- x$value
29
+        if (!("plumber" %in% class(pr))) {
30
+            stop("entrypoint.R must return a runnable Plumber router.")
31
+        }
32
+        pr
33
+    }
34
+    else if (file.exists(file)) {
35
+        plumber$new(file)
36
+    }
37
+    else {
38
+        stop("File does not exist: ", file)
39
+    }
40
+}
41
+<bytecode: 0x55df34386588>
42
+<environment: namespace:plumber>

+ 11
- 0
docker/R/write/condor.submit Целия файл

@@ -0,0 +1,11 @@
1
+should_transfer_files = Yes
2
+when_to_transfer_output = ON_EXIT_OR_EVICT
3
+transfer_input_files = write.R
4
+Universe = docker
5
+docker_image = r-base
6
+Executable = /usr/bin/Rscript
7
+Arguments = write.R /datos/ma0/write_file.txt
8
+Log = write_R_log.log
9
+Output = write_R_out.out
10
+Error = write_R_err.err
11
+Queue

+ 27
- 0
docker/R/write/docker_stderror Целия файл

@@ -0,0 +1,27 @@
1
+Unable to find image 'r-base:latest' locally
2
+latest: Pulling from library/r-base
3
+0656ed1d7f85: Pulling fs layer
4
+c753f78c1082: Pulling fs layer
5
+9b7d77a2fb38: Pulling fs layer
6
+f759fbe73258: Pulling fs layer
7
+5dbb370e90a3: Pulling fs layer
8
+77bb82bbd854: Pulling fs layer
9
+f759fbe73258: Waiting
10
+77bb82bbd854: Waiting
11
+c753f78c1082: Download complete
12
+9b7d77a2fb38: Verifying Checksum
13
+9b7d77a2fb38: Download complete
14
+f759fbe73258: Verifying Checksum
15
+f759fbe73258: Download complete
16
+0656ed1d7f85: Download complete
17
+5dbb370e90a3: Download complete
18
+0656ed1d7f85: Pull complete
19
+c753f78c1082: Pull complete
20
+9b7d77a2fb38: Pull complete
21
+f759fbe73258: Pull complete
22
+5dbb370e90a3: Pull complete
23
+77bb82bbd854: Verifying Checksum
24
+77bb82bbd854: Download complete
25
+77bb82bbd854: Pull complete
26
+Digest: sha256:d0e69d45a36a60dfc7fd972f68fcbc154071018c79b7f44c28fe0e6032f94233
27
+Status: Downloaded newer image for r-base:latest

+ 4
- 0
docker/R/write/write.R Целия файл

@@ -0,0 +1,4 @@
1
+args <- commandArgs(TRUE)
2
+write("Hola mundo", args[1])
3
+
4
+

+ 0
- 0
docker/R/write/write_R_err.err Целия файл


+ 19
- 0
docker/R/write/write_R_log.log Целия файл

@@ -0,0 +1,19 @@
1
+000 (049.000.000) 05/10 11:02:21 Job submitted from host: <192.168.27.25:9618?addrs=192.168.27.25-9618&noUDP&sock=1446571_f6bf_4>
2
+...
3
+001 (049.000.000) 05/10 11:02:23 Job executing on host: <192.168.27.17:9618?addrs=192.168.27.17-9618&noUDP&sock=27247_c111_3>
4
+...
5
+005 (049.000.000) 05/10 11:02:39 Job terminated.
6
+	(1) Normal termination (return value 0)
7
+		Usr 0 00:00:00, Sys 0 00:00:00  -  Run Remote Usage
8
+		Usr 0 00:00:00, Sys 0 00:00:00  -  Run Local Usage
9
+		Usr 0 00:00:00, Sys 0 00:00:00  -  Total Remote Usage
10
+		Usr 0 00:00:00, Sys 0 00:00:00  -  Total Local Usage
11
+	899  -  Run Bytes Sent By Job
12
+	57  -  Run Bytes Received By Job
13
+	899  -  Total Bytes Sent By Job
14
+	57  -  Total Bytes Received By Job
15
+	Partitionable Resources :    Usage  Request Allocated 
16
+	   Cpus                 :        0        1         1 
17
+	   Disk (KB)            :       17        1     45972 
18
+	   Memory (MB)          :                 0      1024 
19
+...

+ 0
- 0
docker/R/write/write_R_out.out Целия файл


+ 11
- 0
docker/python/read/condor.submit Целия файл

@@ -0,0 +1,11 @@
1
+should_transfer_files = Yes
2
+when_to_transfer_output = ON_EXIT_OR_EVICT
3
+transfer_input_files = read.py
4
+Universe = docker
5
+docker_image = python:3.7-alpine
6
+Executable = /usr/local/bin/python
7
+Arguments = read.py /datos/ma0/dummy_file.txt
8
+Log = read_python_log.log
9
+Output = read_python_out.out
10
+Error = read_python_err.err
11
+Queue

+ 23
- 0
docker/python/read/docker_stderror Целия файл

@@ -0,0 +1,23 @@
1
+Unable to find image 'python:3.7-alpine' locally
2
+3.7-alpine: Pulling from library/python
3
+bdf0201b3a05: Pulling fs layer
4
+59c926705abf: Pulling fs layer
5
+31ca6b067b5a: Pulling fs layer
6
+b18bc4e1c47b: Pulling fs layer
7
+7e244112a44c: Pulling fs layer
8
+b18bc4e1c47b: Waiting
9
+7e244112a44c: Waiting
10
+59c926705abf: Download complete
11
+bdf0201b3a05: Download complete
12
+bdf0201b3a05: Pull complete
13
+59c926705abf: Pull complete
14
+31ca6b067b5a: Verifying Checksum
15
+31ca6b067b5a: Download complete
16
+b18bc4e1c47b: Download complete
17
+7e244112a44c: Verifying Checksum
18
+7e244112a44c: Download complete
19
+31ca6b067b5a: Pull complete
20
+b18bc4e1c47b: Pull complete
21
+7e244112a44c: Pull complete
22
+Digest: sha256:a12943ec653051bab0c3a542cd99ef4b8f9c9253bfcdbfe291cfe5fea2c6008c
23
+Status: Downloaded newer image for python:3.7-alpine

+ 12
- 0
docker/python/read/read.py Целия файл

@@ -0,0 +1,12 @@
1
+import sys
2
+
3
+def read_dummy_file(file_name):
4
+    with open(file_name) as f:
5
+        data = f.read()
6
+        print(data)
7
+
8
+
9
+if __name__ == "__main__":
10
+    assert len(sys.argv) > 1
11
+    read_dummy_file(sys.argv[1])
12
+

+ 3
- 0
docker/python/read/read.py.save Целия файл

@@ -0,0 +1,3 @@
1
+def read_file():
2
+    with open("/datos/test/dummy_file.txt") as f:
3
+        dataf.read()

+ 0
- 0
docker/python/read/read_python_err.err Целия файл


+ 19
- 0
docker/python/read/read_python_log.log Целия файл

@@ -0,0 +1,19 @@
1
+000 (055.000.000) 05/10 16:53:29 Job submitted from host: <192.168.27.25:9618?addrs=192.168.27.25-9618&noUDP&sock=1446571_f6bf_4>
2
+...
3
+001 (055.000.000) 05/10 16:53:30 Job executing on host: <192.168.27.17:9618?addrs=192.168.27.17-9618&noUDP&sock=27247_c111_3>
4
+...
5
+005 (055.000.000) 05/10 16:53:36 Job terminated.
6
+	(1) Normal termination (return value 0)
7
+		Usr 0 00:00:00, Sys 0 00:00:00  -  Run Remote Usage
8
+		Usr 0 00:00:00, Sys 0 00:00:00  -  Run Local Usage
9
+		Usr 0 00:00:00, Sys 0 00:00:00  -  Total Remote Usage
10
+		Usr 0 00:00:00, Sys 0 00:00:00  -  Total Local Usage
11
+	802  -  Run Bytes Sent By Job
12
+	211  -  Run Bytes Received By Job
13
+	802  -  Total Bytes Sent By Job
14
+	211  -  Total Bytes Received By Job
15
+	Partitionable Resources :    Usage  Request Allocated 
16
+	   Cpus                 :        0        1         1 
17
+	   Disk (KB)            :       17        1     45972 
18
+	   Memory (MB)          :                 0      1024 
19
+...

+ 2
- 0
docker/python/read/read_python_out.out Целия файл

@@ -0,0 +1,2 @@
1
+data for test
2
+

+ 7
- 0
docker/python/requirements/Dockerfile Целия файл

@@ -0,0 +1,7 @@
1
+FROM python:3.7-alpine
2
+
3
+WORKDIR /code
4
+ADD requirements.txt /code
5
+RUN pip install -r requirements.txt
6
+
7
+CMD ["python"]

+ 10
- 0
docker/python/requirements/compile_docker_image.sh Целия файл

@@ -0,0 +1,10 @@
1
+#!/bin/bash
2
+
3
+if [ -z "$1" ]; then
4
+    echo "A name for the image is needed"
5
+    exit 1
6
+fi
7
+
8
+docker build -t 192.168.27.25:5000/$(whoami)/$1 .
9
+docker push 192.168.27.25:5000/$(whoami)/$1
10
+

+ 11
- 0
docker/python/requirements/condor.submit Целия файл

@@ -0,0 +1,11 @@
1
+should_transfer_files = Yes
2
+when_to_transfer_output = ON_EXIT_OR_EVICT
3
+transfer_input_files = requirements.py
4
+Universe = docker
5
+docker_image = 192.168.27.25:5000/ma0/django_test
6
+Executable = /usr/local/bin/python
7
+Arguments = requirements.py
8
+Log = requirements_python_log.log
9
+Output = requirements_python_out.out
10
+Error = requirements_python_err.err
11
+Queue

+ 8
- 0
docker/python/requirements/requirements.py Целия файл

@@ -0,0 +1,8 @@
1
+import django
2
+
3
+def check_django():
4
+    print(django.VERSION)
5
+
6
+if __name__ == "__main__":
7
+    check_django()
8
+

+ 1
- 0
docker/python/requirements/requirements.txt Целия файл

@@ -0,0 +1 @@
1
+django==2.2.0

+ 11
- 0
docker/python/write/condor.submit Целия файл

@@ -0,0 +1,11 @@
1
+should_transfer_files = Yes
2
+when_to_transfer_output = ON_EXIT_OR_EVICT
3
+transfer_input_files = write.py
4
+Universe = docker
5
+docker_image = python:3.7-alpine
6
+Executable = /usr/local/bin/python
7
+Arguments = write.py /datos/ma0/write_file.txt
8
+Log = write_python_log.log
9
+Output = write_python_out.out
10
+Error = write_python_err.err
11
+Queue

+ 11
- 0
docker/python/write/write.py Целия файл

@@ -0,0 +1,11 @@
1
+import sys
2
+
3
+def write_file(file_name):
4
+    with open(file_name, "w+") as f:
5
+        f.write("Dummy text")
6
+
7
+
8
+if __name__ == "__main__":
9
+    assert len(sys.argv) > 1
10
+    write_file(sys.argv[1])
11
+

+ 55
- 0
gpu/add.cu Целия файл

@@ -0,0 +1,55 @@
1
+#include <iostream>
2
+#include <math.h>
3
+
4
+// Kernel function to add the elements of two arrays
5
+__global__
6
+void add(int n, float *x, float *y)
7
+{
8
+  int index = threadIdx.x;
9
+  int stride = blockDim.x;
10
+  for (int i = index; i < n; i += stride)
11
+      y[i] = x[i] + y[i];
12
+}
13
+
14
+/*
15
+__global__
16
+void add(int n, float *x, float *y)
17
+{
18
+  for (int i = 0; i < n; i++)
19
+    y[i] = x[i] + y[i];
20
+}
21
+*/
22
+
23
+int main(void)
24
+{
25
+  int N = 1<<20;
26
+  float *x, *y;
27
+
28
+  // Allocate Unified Memory – accessible from CPU or GPU
29
+  cudaMallocManaged(&x, N*sizeof(float));
30
+  cudaMallocManaged(&y, N*sizeof(float));
31
+
32
+  // initialize x and y arrays on the host
33
+  for (int i = 0; i < N; i++) {
34
+    x[i] = 1.0f;
35
+    y[i] = 2.0f;
36
+  }
37
+
38
+  // Run kernel on 1M elements on the GPU
39
+  add<<<1, 256>>>(N, x, y);
40
+
41
+  // Wait for GPU to finish before accessing on host
42
+  cudaDeviceSynchronize();
43
+
44
+  // Check for errors (all values should be 3.0f)
45
+  float maxError = 0.0f;
46
+  for (int i = 0; i < N; i++)
47
+    maxError = fmax(maxError, fabs(y[i]-3.0f));
48
+  std::cout << "Max error: " << maxError << std::endl;
49
+
50
+  // Free memory
51
+  cudaFree(x);
52
+  cudaFree(y);
53
+  
54
+  return 0;
55
+}

+ 15
- 0
gpu/condor.submit Целия файл

@@ -0,0 +1,15 @@
1
+should_transfer_files = Yes
2
+when_to_transfer_output = ON_EXIT_OR_EVICT
3
+
4
+transfer_input_files=add.cu
5
+Executable = run.sh
6
+Universe   = vanilla
7
+Log        = add_log.log
8
+Output     = add_out.out
9
+Error      = add_err.err
10
+
11
+request_cpus = 1
12
+request_memory = 2G
13
+request_gpus = 1
14
+
15
+Queue 

+ 8
- 0
gpu/run.sh Целия файл

@@ -0,0 +1,8 @@
1
+#!/bin/bash
2
+export PATH=/usr/local/cuda-10.1/bin:/usr/local/cuda-10.1/NsightCompute-2019.1:${PATH}
3
+# Compilar codigo para GPU
4
+nvcc add.cu -o add_cuda
5
+# Ejecutar codigo
6
+nvprof ./add_cuda
7
+# Finalizada ejecucion
8
+

Loading…
Отказ
Запис