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 | |
from multiprocessing import Pool | |
iterations_count = round(1e7) | |
def complex_operation(input_index): | |
print("Complex operation. Input index: {:2d}".format(input_index)) |
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 | |
iterations_count = round(1e7) | |
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] |
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)) |
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 torch | |
from torch.utils.data import DataLoader | |
from torchvision.datasets import CIFAR10 | |
import torchvision.transforms as transforms | |
import ray | |
from ray.util.sgd.torch import TorchTrainer | |
from ray.util.sgd.torch import TrainingOperator | |
# https://github.com/kuangliu/pytorch-cifar/blob/master/models/resnet.py | |
from ray.util.sgd.torch.resnet import ResNet18 |
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
from mars.session import new_session | |
ray_session = new_session(backend=’ray’).as_default() # Set Ray as the default backend. | |
import mars.dataframe as md | |
import mars.tensor as mt | |
t = mt.random.randint(100, size=(2**10, 2**8)) | |
df = md.DataFrame(t) | |
print(df.head(10).execute()) |
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 ray | |
# Modin defaults to backing Ray’s object store with disk. | |
# Start Ray before importing modin to use shared memory instead. | |
ray.init() | |
import modin.pandas as pd | |
import numpy as np | |
frame_data = np.random.randint(0, 100, size=(2**10, 2**8)) | |
df = pd.DataFrame(frame_data) |
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 ray | |
from ray.util.dask import ray_dask_get | |
import dask | |
import dask.dataframe as dd | |
import pandas as pd | |
import numpy as np | |
dask.config.set(scheduler=ray_dask_get) # Sets Ray as the default backend. |
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 ray | |
import raydp | |
ray.init() | |
@ray.remote | |
class PySparkDriver: | |
def __init__(self): | |
self.spark = raydp.init_spark( | |
app_name='RayDP example', |
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 ray | |
from ray.util.sgd import TorchTrainer | |
from ray.util.sgd.torch import TrainingOperator | |
from ray.util.sgd.torch.examples.train_example import LinearDataset | |
import torch | |
from torch.utils.data import DataLoader | |
class CustomTrainingOperator(TrainingOperator): | |
def setup(self, config): |
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 time | |
from sklearn.datasets import make_classification | |
from sklearn.model_selection import train_test_split | |
from sklearn.linear_model import LogisticRegression | |
# Set training and validation sets | |
X, y = make_classification(n_samples=1000000, n_features=1000, n_classes = 2) | |
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=10000) | |
# Solvers |