Created
September 1, 2021 18:58
-
-
Save mGalarnyk/30c8672620c8655a37940be935899a57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
import numpy as np | |
from timebudget import timebudget | |
import ray | |
iterations_count = round(1e7) | |
@ray.remote | |
def complex_operation(input_index): | |
print("Complex operation. Input index: {:2d}".format(input_index)) | |
[math.exp(i) * math.sinh(i) for i in [1] * iterations_count] | |
@ray.remote | |
def complex_operation_numpy(input_index): | |
print("Complex operation (numpy). Input index: {:2d}".format(input_index)) | |
data = np.ones(iterations_count) | |
np.exp(data) * np.sinh(data) | |
@timebudget | |
def run_complex_operations(operation, input): | |
ray.get([operation.remote(i) for i in input]) | |
ray.init() | |
input = range(10) | |
print('Without NumPy') | |
run_complex_operations(complex_operation, input) | |
print('NumPy') | |
run_complex_operations(complex_operation_numpy, input) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it is not work for me, i am trying to run the code as is :(
but get error:
TypeError: can't pickle function objects
why it can be?
p.s. i am install ray and timebudget packages