From T3_KR_KNU
(Created page with "== HTCondor 에서 GPU 사용하기 == === Ex 1) Matrix === matrix.py import numpy as np from timeit import default_timer as timer from numba import vectorize @vector...") |
(→Ex 1) Matrix) |
||
| Line 21: | Line 21: | ||
duration = timer() - start | duration = timer() - start | ||
print(duration) | print(duration) | ||
| + | |||
| + | matrix.sh | ||
| + | |||
| + | #!/bin/bash | ||
| + | python3.6 -m virtualenv myvenv | ||
| + | source myvenv/bin/activate | ||
| + | pip3 install numba | ||
| + | python3.6 matrix.py | ||
| + | |||
| + | matrix.sub | ||
| + | |||
| + | executable = matrix.sh | ||
| + | arguments = $(ClusterId)$(ProcId) | ||
| + | output = matrix.$(ClusterId).$(ProcId).out | ||
| + | error = matrix.$(ClusterId).$(ProcId).err | ||
| + | log = matrix.$(ClusterId).log | ||
| + | should_transfer_files = YES | ||
| + | transfer_input_files = matrix.py | ||
| + | when_to_transfer_output = ON_EXIT | ||
| + | request_GPUs = 1 | ||
| + | request_CPUs = 1 | ||
| + | queue | ||
Revision as of 02:03, 12 May 2021
HTCondor 에서 GPU 사용하기
Ex 1) Matrix
matrix.py
import numpy as np
from timeit import default_timer as timer
from numba import vectorize
@vectorize(['float32(float32, float32)'], target='cuda')
def pow(a, b):
return a ** b
vec_size = 100000000
a = b = np.array(np.random.sample(vec_size), dtype=np.float32)
c = np.zeros(vec_size, dtype=np.float32)
start = timer()
c = pow(a,b)
duration = timer() - start
print(duration)
matrix.sh
#!/bin/bash python3.6 -m virtualenv myvenv source myvenv/bin/activate pip3 install numba python3.6 matrix.py
matrix.sub
executable = matrix.sh arguments = $(ClusterId)$(ProcId) output = matrix.$(ClusterId).$(ProcId).out error = matrix.$(ClusterId).$(ProcId).err log = matrix.$(ClusterId).log should_transfer_files = YES transfer_input_files = matrix.py when_to_transfer_output = ON_EXIT request_GPUs = 1 request_CPUs = 1 queue