mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 20:22:39 +08:00
Start working toward Python3 compatibility. (#117)
This commit is contained in:
committed by
Philipp Moritz
parent
3d083c8b58
commit
ddba1df802
@@ -34,7 +34,7 @@ for _ in range(10):
|
||||
|
||||
# Fetch the results of the tasks and print their average.
|
||||
estimate = np.mean(ray.get(result_ids))
|
||||
print "Pi is approximately {}.".format(estimate)
|
||||
print("Pi is approximately {}.".format(estimate))
|
||||
```
|
||||
|
||||
Within the for loop, each call to `estimate_pi.remote(100)` sends a message to
|
||||
|
||||
@@ -190,5 +190,5 @@ for iteration in range(NUM_ITERS):
|
||||
# Print the current weights. They should converge to roughly to the values 0.1
|
||||
# and 0.3 used in generate_fake_x_y_data.
|
||||
if iteration % 20 == 0:
|
||||
print "Iteration {}: weights are {}".format(iteration, weights)
|
||||
print("Iteration {}: weights are {}".format(iteration, weights))
|
||||
```
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
# The code for AlexNet is copied and adapted from the TensorFlow repository
|
||||
# https://github.com/tensorflow/tensorflow/blob/master/tensorflow/models/image/alexnet/alexnet_benchmark.py.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import ray
|
||||
import numpy as np
|
||||
import tarfile, io
|
||||
@@ -390,7 +394,7 @@ def shuffle(batches):
|
||||
# Randomly permute the order of the batches.
|
||||
permuted_batches = np.random.permutation(batches)
|
||||
new_batches = []
|
||||
for i in range(len(batches) / 2):
|
||||
for i in range(len(batches) // 2):
|
||||
# Swap data between consecutive batches.
|
||||
shuffled_batch1, shuffled_batch2 = shuffle_pair(permuted_batches[2 * i], permuted_batches[2 * i + 1])
|
||||
new_batches += [shuffled_batch1, shuffled_batch2]
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
import ray
|
||||
import os
|
||||
@@ -28,7 +32,7 @@ if __name__ == "__main__":
|
||||
imagenet_bucket = s3_resource.Bucket(args.s3_bucket)
|
||||
objects = imagenet_bucket.objects.filter(Prefix=args.key_prefix)
|
||||
image_tar_files = [str(obj.key) for obj in objects.all()]
|
||||
print "Images will be downloaded from {} files.".format(len(image_tar_files))
|
||||
print("Images will be downloaded from {} files.".format(len(image_tar_files)))
|
||||
|
||||
# Downloading the label file, and create a dictionary mapping the filenames of
|
||||
# the images to their labels.
|
||||
@@ -38,7 +42,7 @@ if __name__ == "__main__":
|
||||
filename_label_pairs = [line.split(" ") for line in filename_label_str]
|
||||
filename_label_dict = dict([(os.path.basename(name), label) for name, label in filename_label_pairs])
|
||||
filename_label_dict_id = ray.put(filename_label_dict)
|
||||
print "Labels extracted."
|
||||
print("Labels extracted.")
|
||||
|
||||
# Download the imagenet dataset.
|
||||
imagenet_data = alexnet.load_tarfiles_from_s3(args.s3_bucket, image_tar_files, [256, 256])
|
||||
@@ -60,7 +64,7 @@ if __name__ == "__main__":
|
||||
# Initialize the network and optimizer weights. This is only run once on the
|
||||
# driver. We initialize the weights manually on the workers.
|
||||
sess.run(init_all_variables)
|
||||
print "Initialized network weights."
|
||||
print("Initialized network weights.")
|
||||
|
||||
iteration = 0
|
||||
while True:
|
||||
@@ -82,7 +86,7 @@ if __name__ == "__main__":
|
||||
gradient_ids.append(alexnet.compute_grad.remote(x_id, y_id, mean_id, weights_id))
|
||||
|
||||
# Print the accuracy on a random training batch.
|
||||
print "Iteration {}: accuracy = {:.3}%".format(iteration, 100 * ray.get(accuracy))
|
||||
print("Iteration {}: accuracy = {:.3}%".format(iteration, 100 * ray.get(accuracy)))
|
||||
|
||||
# Fetch the gradients. This blocks until the gradients have been computed.
|
||||
gradient_sets = ray.get(gradient_ids)
|
||||
|
||||
@@ -148,7 +148,7 @@ while len(remaining_ids) > 0:
|
||||
ready_ids, remaining_ids = ray.wait(remaining_ids, num_returns=1)
|
||||
# Get the accuracy corresponding to the ready object ID.
|
||||
accuracy = ray.get(ready_ids[0])
|
||||
print "Accuracy {}".format(accuracy)
|
||||
print("Accuracy {}".format(accuracy))
|
||||
```
|
||||
|
||||
Note that the above example does not associate the accuracy with the parameters
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
# Most of the tensorflow code is adapted from Tensorflow's tutorial on using CNNs to train MNIST
|
||||
# https://www.tensorflow.org/versions/r0.9/tutorials/mnist/pros/index.html#build-a-multilayer-convolutional-network
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
import ray
|
||||
import argparse
|
||||
@@ -24,7 +29,7 @@ if __name__ == "__main__":
|
||||
steps = args.steps
|
||||
|
||||
# Load the mnist data and turn the data into remote objects.
|
||||
print "Downloading the MNIST dataset. This may take a minute."
|
||||
print("Downloading the MNIST dataset. This may take a minute.")
|
||||
mnist = input_data.read_data_sets("MNIST_data", one_hot=True)
|
||||
train_images = ray.put(mnist.train.images)
|
||||
train_labels = ray.put(mnist.train.labels)
|
||||
@@ -65,20 +70,20 @@ if __name__ == "__main__":
|
||||
result_id = ready_ids[0]
|
||||
params = params_mapping[result_id]
|
||||
accuracy = ray.get(result_id)
|
||||
print """We achieve accuracy {:.3}% with
|
||||
print("""We achieve accuracy {:.3}% with
|
||||
learning_rate: {:.2}
|
||||
batch_size: {}
|
||||
dropout: {:.2}
|
||||
stddev: {:.2}
|
||||
""".format(100 * accuracy, params["learning_rate"], params["batch_size"], params["dropout"], params["stddev"])
|
||||
""".format(100 * accuracy, params["learning_rate"], params["batch_size"], params["dropout"], params["stddev"]))
|
||||
if accuracy > best_accuracy:
|
||||
best_params = params
|
||||
best_accuracy = accuracy
|
||||
|
||||
# Record the best performing set of hyperparameters.
|
||||
print """Best accuracy over {} trials was {:.3} with
|
||||
print("""Best accuracy over {} trials was {:.3} with
|
||||
learning_rate: {:.2}
|
||||
batch_size: {}
|
||||
dropout: {:.2}
|
||||
stddev: {:.2}
|
||||
""".format(trials, 100 * best_accuracy, best_params["learning_rate"], best_params["batch_size"], best_params["dropout"], best_params["stddev"])
|
||||
""".format(trials, 100 * best_accuracy, best_params["learning_rate"], best_params["batch_size"], best_params["dropout"], best_params["stddev"]))
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import ray
|
||||
import numpy as np
|
||||
import tensorflow as tf
|
||||
@@ -6,7 +10,7 @@ def get_batch(data, batch_index, batch_size):
|
||||
# This method currently drops data when num_data is not divisible by
|
||||
# batch_size.
|
||||
num_data = data.shape[0]
|
||||
num_batches = num_data / batch_size
|
||||
num_batches = num_data // batch_size
|
||||
batch_index %= num_batches
|
||||
return data[(batch_index * batch_size):((batch_index + 1) * batch_size)]
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ built in methods for loading the data.
|
||||
from tensorflow.examples.tutorials.mnist import input_data
|
||||
mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
|
||||
batch_size = 100
|
||||
num_batches = mnist.train.num_examples / batch_size
|
||||
num_batches = mnist.train.num_examples // batch_size
|
||||
batches = [mnist.train.next_batch(batch_size) for _ in range(num_batches)]
|
||||
```
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import ray
|
||||
|
||||
import numpy as np
|
||||
@@ -115,16 +119,16 @@ if __name__ == "__main__":
|
||||
# algorithm.
|
||||
|
||||
# Load the mnist data and turn the data into remote objects.
|
||||
print "Downloading the MNIST dataset. This may take a minute."
|
||||
print("Downloading the MNIST dataset. This may take a minute.")
|
||||
mnist = input_data.read_data_sets("MNIST_data", one_hot=True)
|
||||
batch_size = 100
|
||||
num_batches = mnist.train.num_examples / batch_size
|
||||
num_batches = mnist.train.num_examples // batch_size
|
||||
batches = [mnist.train.next_batch(batch_size) for _ in range(num_batches)]
|
||||
print "Putting MNIST in the object store."
|
||||
print("Putting MNIST in the object store.")
|
||||
batch_ids = [(ray.put(xs), ray.put(ys)) for (xs, ys) in batches]
|
||||
|
||||
# Initialize the weights for the network to the vector of all zeros.
|
||||
theta_init = 1e-2 * np.random.normal(size=dim)
|
||||
# Use L-BFGS to minimize the loss function.
|
||||
print "Running L-BFGS."
|
||||
print("Running L-BFGS.")
|
||||
result = scipy.optimize.fmin_l_bfgs_b(full_loss, theta_init, maxiter=10, fprime=full_grad, disp=True)
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
# This code is copied and adapted from Andrej Karpathy's code for learning to
|
||||
# play Pong https://gist.github.com/karpathy/a4166c7fe253700972fcbc77e4ea32c5.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
import cPickle as pickle
|
||||
import ray
|
||||
@@ -135,7 +139,7 @@ if __name__ == "__main__":
|
||||
reward_sum = ray.get(reward_sums[i])
|
||||
for k in model: grad_buffer[k] += grad[k] # accumulate grad over batch
|
||||
running_reward = reward_sum if running_reward is None else running_reward * 0.99 + reward_sum * 0.01
|
||||
print "Batch {}. episode reward total was {}. running mean: {}".format(batch_num, reward_sum, running_reward)
|
||||
print("Batch {}. episode reward total was {}. running mean: {}".format(batch_num, reward_sum, running_reward))
|
||||
for k, v in model.iteritems():
|
||||
g = grad_buffer[k] # gradient
|
||||
rmsprop_cache[k] = decay_rate * rmsprop_cache[k] + (1 - decay_rate) * g ** 2
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
# Ray version string
|
||||
__version__ = "0.01"
|
||||
|
||||
@@ -9,8 +13,7 @@ if hasattr(ctypes, "windll"):
|
||||
# This is done by associating all child processes with a "job" object that imposes this behavior.
|
||||
(lambda kernel32: (lambda job: (lambda n: kernel32.SetInformationJobObject(job, 9, "\0" * 17 + chr(0x8 | 0x4 | 0x20) + "\0" * (n - 18), n))(0x90 if ctypes.sizeof(ctypes.c_void_p) > ctypes.sizeof(ctypes.c_int) else 0x70) and kernel32.AssignProcessToJobObject(job, ctypes.c_void_p(kernel32.GetCurrentProcess())))(ctypes.c_void_p(kernel32.CreateJobObjectW(None, None))) if kernel32 is not None else None)(ctypes.windll.kernel32)
|
||||
|
||||
import config
|
||||
import serialization
|
||||
from worker import register_class, error_info, init, connect, disconnect, get, put, wait, remote
|
||||
from worker import Reusable, reusables
|
||||
from worker import SCRIPT_MODE, WORKER_MODE, PYTHON_MODE, SILENT_MODE
|
||||
import ray.serialization
|
||||
from ray.worker import register_class, error_info, init, connect, disconnect, get, put, wait, remote
|
||||
from ray.worker import Reusable, reusables
|
||||
from ray.worker import SCRIPT_MODE, WORKER_MODE, PYTHON_MODE, SILENT_MODE
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
import ray.array.remote as ra
|
||||
import ray
|
||||
@@ -141,10 +145,10 @@ def blockwise_dot(*matrices):
|
||||
n = len(matrices)
|
||||
if n % 2 != 0:
|
||||
raise Exception("blockwise_dot expects an even number of arguments, but len(matrices) is {}.".format(n))
|
||||
shape = (matrices[0].shape[0], matrices[n / 2].shape[1])
|
||||
shape = (matrices[0].shape[0], matrices[n // 2].shape[1])
|
||||
result = np.zeros(shape)
|
||||
for i in range(n / 2):
|
||||
result += np.dot(matrices[i], matrices[n / 2 + i])
|
||||
for i in range(n // 2):
|
||||
result += np.dot(matrices[i], matrices[n // 2 + i])
|
||||
return result
|
||||
|
||||
@ray.remote
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
import ray.array.remote as ra
|
||||
import ray
|
||||
|
||||
from core import *
|
||||
from .core import *
|
||||
|
||||
__all__ = ["tsqr", "modified_lu", "tsqr_hr", "qr"]
|
||||
|
||||
@@ -68,7 +72,7 @@ def tsqr(a):
|
||||
else:
|
||||
lower = [a.shape[1], 0]
|
||||
upper = [2 * a.shape[1], BLOCK_SIZE]
|
||||
ith_index /= 2
|
||||
ith_index //= 2
|
||||
q_block_current = ra.dot.remote(q_block_current, ra.subarray.remote(q_tree[ith_index, j], lower, upper))
|
||||
q_result.objectids[i] = q_block_current
|
||||
r = current_rs[0]
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
import ray.array.remote as ra
|
||||
import ray
|
||||
|
||||
from core import *
|
||||
from .core import *
|
||||
|
||||
@ray.remote
|
||||
def normal(shape):
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
import ray
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
import ray
|
||||
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
import ray
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import datetime
|
||||
import os.path
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
def get_log_file_path(name):
|
||||
return os.path.join(
|
||||
os.path.join("/tmp" if sys.platform.startswith("darwin") else tempfile.gettempdir(), "raylogs"),
|
||||
("{:%Y-%m-%d-%H-%M-%S}-{}").format(datetime.datetime.now(), name.replace(":", "-")))
|
||||
@@ -1,5 +1,9 @@
|
||||
# Note that a little bit of code here is taken and slightly modified from the pickler because it was not possible to change its behavior otherwise.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
from ctypes import c_void_p
|
||||
from cloudpickle import pickle, cloudpickle, CloudPickler, load, loads
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
import pickling
|
||||
import numbuf
|
||||
|
||||
import ray.pickling as pickling
|
||||
|
||||
def check_serializable(cls):
|
||||
"""Throws an exception if Ray cannot serialize this class efficiently.
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import psutil
|
||||
@@ -10,7 +12,6 @@ import sys
|
||||
import time
|
||||
|
||||
# Ray modules
|
||||
import config
|
||||
import photon
|
||||
import plasma
|
||||
import global_scheduler
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import ray
|
||||
|
||||
import numpy as np
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import hashlib
|
||||
@@ -16,10 +18,9 @@ import threading
|
||||
import string
|
||||
|
||||
# Ray modules
|
||||
import config
|
||||
import pickling
|
||||
import serialization
|
||||
import services
|
||||
import ray.pickling as pickling
|
||||
import ray.serialization as serialization
|
||||
import ray.services as services
|
||||
import numbuf
|
||||
import photon
|
||||
import plasma
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import sys
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
|
||||
@@ -12,17 +12,17 @@ message(STATUS "Trying custom approach for finding Python.")
|
||||
# Start off by figuring out which Python executable to use.
|
||||
find_program(CUSTOM_PYTHON_EXECUTABLE python)
|
||||
message(STATUS "Found Python program: ${CUSTOM_PYTHON_EXECUTABLE}")
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "import sys; print 'python' + sys.version[0:3]"
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "import sys; print('python' + sys.version[0:3])"
|
||||
OUTPUT_VARIABLE PYTHON_LIBRARY_NAME OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "PYTHON_LIBRARY_NAME: " ${PYTHON_LIBRARY_NAME})
|
||||
# Now find the Python include directories.
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_python_inc()"
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print(get_python_inc())"
|
||||
OUTPUT_VARIABLE PYTHON_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "PYTHON_INCLUDE_DIRS: " ${PYTHON_INCLUDE_DIRS})
|
||||
# Now find the Python libraries. We'll start by looking near the Python
|
||||
# executable. If that fails, then we'll look near the Python include
|
||||
# directories.
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "import sys; print sys.exec_prefix"
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "import sys; print(sys.exec_prefix)"
|
||||
OUTPUT_VARIABLE PYTHON_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "PYTHON_PREFIX: " ${PYTHON_PREFIX})
|
||||
FIND_LIBRARY(PYTHON_LIBRARIES
|
||||
|
||||
@@ -1 +1,5 @@
|
||||
from libnumbuf import *
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
from numbuf.libnumbuf import *
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import unittest
|
||||
import numbuf
|
||||
import numpy as np
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import subprocess
|
||||
from setuptools import setup, find_packages
|
||||
import setuptools.command.install as _install
|
||||
|
||||
+9
-5
@@ -1,3 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import socket
|
||||
@@ -63,7 +67,7 @@ class RayCluster(object):
|
||||
raise Exception("Commands run over ssh must not contain the single quote character. This command does: {}".format(command))
|
||||
full_command = "ssh -o StrictHostKeyChecking=no -i {} {}@{} '{}'".format(self.key_file, self.username, node_ip_address, command)
|
||||
subprocess.call([full_command], shell=True)
|
||||
print "Finished running command '{}' on {}@{}.".format(command, self.username, node_ip_address)
|
||||
print("Finished running command '{}' on {}@{}.".format(command, self.username, node_ip_address))
|
||||
|
||||
def _run_parallel_functions(self, functions, inputs):
|
||||
"""Run functions in parallel.
|
||||
@@ -117,7 +121,7 @@ class RayCluster(object):
|
||||
self._run_command_over_ssh(node_ip_address, command)
|
||||
inputs = zip(node_ip_addresses, commands)
|
||||
self._run_parallel_functions(len(self.node_ip_addresses) * [function], inputs)
|
||||
print "Finished running commands {} on all nodes.".format(inputs)
|
||||
print("Finished running commands {} on all nodes.".format(inputs))
|
||||
|
||||
def install_ray(self):
|
||||
"""Install Ray on every node in the cluster.
|
||||
@@ -172,7 +176,7 @@ class RayCluster(object):
|
||||
self.run_command_over_ssh_on_all_nodes_in_parallel(start_workers_commands)
|
||||
|
||||
setup_env_path = os.path.join(self.installation_directory, "ray/setup-env.sh")
|
||||
print """
|
||||
print("""
|
||||
The cluster has been started. You can attach to the cluster by sshing to the head node with the following command.
|
||||
|
||||
ssh -i {} {}@{}
|
||||
@@ -185,7 +189,7 @@ class RayCluster(object):
|
||||
|
||||
import ray
|
||||
ray.init(node_ip_address="{}", scheduler_address="{}:10001")
|
||||
""".format(self.key_file, self.username, self.node_ip_addresses[0], setup_env_path, self.node_private_ip_addresses[0], self.node_private_ip_addresses[0])
|
||||
""".format(self.key_file, self.username, self.node_ip_addresses[0], setup_env_path, self.node_private_ip_addresses[0], self.node_private_ip_addresses[0]))
|
||||
|
||||
def stop_ray(self):
|
||||
"""Kill all of the processes in the Ray cluster.
|
||||
@@ -317,7 +321,7 @@ if __name__ == "__main__":
|
||||
# will be expanded locally instead of remotely.
|
||||
echo_home_command = "ssh -o StrictHostKeyChecking=no -i {} {}@{} 'echo $HOME'".format(key_file, username, node_ip_addresses[0])
|
||||
installation_directory = subprocess.check_output(echo_home_command, shell=True).strip()
|
||||
print "Using '{}' as the home directory on the cluster.".format(installation_directory)
|
||||
print("Using '{}' as the home directory on the cluster.".format(installation_directory))
|
||||
# Create the Raycluster object.
|
||||
cluster = RayCluster(node_ip_addresses, node_private_ip_addresses, username, key_file, installation_directory)
|
||||
# Drop into an IPython shell.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
|
||||
@@ -6,17 +6,17 @@ message(STATUS "Trying custom approach for finding Python.")
|
||||
# Start off by figuring out which Python executable to use.
|
||||
find_program(CUSTOM_PYTHON_EXECUTABLE python)
|
||||
message(STATUS "Found Python program: ${CUSTOM_PYTHON_EXECUTABLE}")
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "import sys; print 'python' + sys.version[0:3]"
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "import sys; print('python' + sys.version[0:3])"
|
||||
OUTPUT_VARIABLE PYTHON_LIBRARY_NAME OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "PYTHON_LIBRARY_NAME: " ${PYTHON_LIBRARY_NAME})
|
||||
# Now find the Python include directories.
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_python_inc()"
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print(get_python_inc())"
|
||||
OUTPUT_VARIABLE PYTHON_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "PYTHON_INCLUDE_DIRS: " ${PYTHON_INCLUDE_DIRS})
|
||||
# Now find the Python libraries. We'll start by looking near the Python
|
||||
# executable. If that fails, then we'll look near the Python include
|
||||
# directories.
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "import sys; print sys.exec_prefix"
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "import sys; print(sys.exec_prefix)"
|
||||
OUTPUT_VARIABLE PYTHON_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "PYTHON_PREFIX: " ${PYTHON_PREFIX})
|
||||
FIND_LIBRARY(PYTHON_LIBRARIES
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
from libphoton import *
|
||||
from photon_services import *
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
|
||||
@@ -6,17 +6,17 @@ message(STATUS "Trying custom approach for finding Python.")
|
||||
# Start off by figuring out which Python executable to use.
|
||||
find_program(CUSTOM_PYTHON_EXECUTABLE python)
|
||||
message(STATUS "Found Python program: ${CUSTOM_PYTHON_EXECUTABLE}")
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "import sys; print 'python' + sys.version[0:3]"
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "import sys; print('python' + sys.version[0:3])"
|
||||
OUTPUT_VARIABLE PYTHON_LIBRARY_NAME OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "PYTHON_LIBRARY_NAME: " ${PYTHON_LIBRARY_NAME})
|
||||
# Now find the Python include directories.
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print get_python_inc()"
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print(get_python_inc())"
|
||||
OUTPUT_VARIABLE PYTHON_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "PYTHON_INCLUDE_DIRS: " ${PYTHON_INCLUDE_DIRS})
|
||||
# Now find the Python libraries. We'll start by looking near the Python
|
||||
# executable. If that fails, then we'll look near the Python include
|
||||
# directories.
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "import sys; print sys.exec_prefix"
|
||||
execute_process(COMMAND ${CUSTOM_PYTHON_EXECUTABLE} -c "import sys; print(sys.exec_prefix)"
|
||||
OUTPUT_VARIABLE PYTHON_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
message(STATUS "PYTHON_PREFIX: " ${PYTHON_PREFIX})
|
||||
FIND_LIBRARY(PYTHON_LIBRARIES
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import random
|
||||
import subprocess
|
||||
import time
|
||||
import libplasma
|
||||
|
||||
from . import libplasma
|
||||
|
||||
PLASMA_ID_SIZE = 20
|
||||
PLASMA_WAIT_TIMEOUT = 2 ** 30
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
import setuptools.command.install as _install
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
@@ -534,7 +536,7 @@ class TestPlasmaManager(unittest.TestCase):
|
||||
# loop slow down the manager so much that some of the asynchronous Redis
|
||||
# commands timeout triggering fatal failure callbacks.
|
||||
n = 40
|
||||
for i in range(n * (n + 1) / 2):
|
||||
for i in range(n * (n + 1) // 2):
|
||||
if i % 2 == 0:
|
||||
object_id, _, _ = create_object(self.client1, 200, 200)
|
||||
else:
|
||||
|
||||
+7
-3
@@ -1,3 +1,7 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import unittest
|
||||
import ray
|
||||
import numpy as np
|
||||
@@ -130,7 +134,7 @@ class DistributedArrayTest(unittest.TestCase):
|
||||
|
||||
# test da.linalg.modified_lu
|
||||
def test_modified_lu(d1, d2):
|
||||
print "testing dist_modified_lu with d1 = " + str(d1) + ", d2 = " + str(d2)
|
||||
print("testing dist_modified_lu with d1 = " + str(d1) + ", d2 = " + str(d2))
|
||||
assert d1 >= d2
|
||||
k = min(d1, d2)
|
||||
m = ra.random.normal.remote([d1, d2])
|
||||
@@ -153,7 +157,7 @@ class DistributedArrayTest(unittest.TestCase):
|
||||
|
||||
# test dist_tsqr_hr
|
||||
def test_dist_tsqr_hr(d1, d2):
|
||||
print "testing dist_tsqr_hr with d1 = " + str(d1) + ", d2 = " + str(d2)
|
||||
print("testing dist_tsqr_hr with d1 = " + str(d1) + ", d2 = " + str(d2))
|
||||
a = da.random.normal.remote([d1, d2])
|
||||
y, t, y_top, r = da.linalg.tsqr_hr.remote(a)
|
||||
a_val = ray.get(da.assemble.remote(a))
|
||||
@@ -171,7 +175,7 @@ class DistributedArrayTest(unittest.TestCase):
|
||||
test_dist_tsqr_hr(d1, d2)
|
||||
|
||||
def test_dist_qr(d1, d2):
|
||||
print "testing qr with d1 = {}, and d2 = {}.".format(d1, d2)
|
||||
print("testing qr with d1 = {}, and d2 = {}.".format(d1, d2))
|
||||
a = da.random.normal.remote([d1, d2])
|
||||
K = min(d1, d2)
|
||||
q, r = da.linalg.qr.remote(a)
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import unittest
|
||||
import ray
|
||||
import time
|
||||
|
||||
import test_functions
|
||||
import ray.test.test_functions as test_functions
|
||||
|
||||
def wait_for_errors(error_type, num_errors, timeout=10):
|
||||
start_time = time.time()
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
# This code reproduces a memory leak we had in the past
|
||||
|
||||
import os
|
||||
import numpy as np
|
||||
import ray
|
||||
|
||||
ray.init(start_ray_local=True, num_workers=1)
|
||||
|
||||
d = {"w": np.zeros(1000000)}
|
||||
|
||||
obj_capsule, contained_objectids = ray.libraylib.serialize_object(ray.worker.global_worker.handle, d)
|
||||
|
||||
while True:
|
||||
ray.libraylib.deserialize_object(ray.worker.global_worker.handle, obj_capsule)
|
||||
+25
-21
@@ -1,9 +1,13 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import unittest
|
||||
import ray
|
||||
import time
|
||||
import numpy as np
|
||||
|
||||
import test_functions
|
||||
import ray.test.test_functions as test_functions
|
||||
|
||||
class MicroBenchmarkTest(unittest.TestCase):
|
||||
|
||||
@@ -20,11 +24,11 @@ class MicroBenchmarkTest(unittest.TestCase):
|
||||
elapsed_times.append(end_time - start_time)
|
||||
elapsed_times = np.sort(elapsed_times)
|
||||
average_elapsed_time = sum(elapsed_times) / 1000
|
||||
print "Time required to submit an empty function call:"
|
||||
print " Average: {}".format(average_elapsed_time)
|
||||
print " 90th percentile: {}".format(elapsed_times[900])
|
||||
print " 99th percentile: {}".format(elapsed_times[990])
|
||||
print " worst: {}".format(elapsed_times[999])
|
||||
print("Time required to submit an empty function call:")
|
||||
print(" Average: {}".format(average_elapsed_time))
|
||||
print(" 90th percentile: {}".format(elapsed_times[900]))
|
||||
print(" 99th percentile: {}".format(elapsed_times[990]))
|
||||
print(" worst: {}".format(elapsed_times[999]))
|
||||
# average_elapsed_time should be about 0.00038
|
||||
|
||||
# measure the time required to submit a remote task to the scheduler (where the remote task returns one value)
|
||||
@@ -36,11 +40,11 @@ class MicroBenchmarkTest(unittest.TestCase):
|
||||
elapsed_times.append(end_time - start_time)
|
||||
elapsed_times = np.sort(elapsed_times)
|
||||
average_elapsed_time = sum(elapsed_times) / 1000
|
||||
print "Time required to submit a trivial function call:"
|
||||
print " Average: {}".format(average_elapsed_time)
|
||||
print " 90th percentile: {}".format(elapsed_times[900])
|
||||
print " 99th percentile: {}".format(elapsed_times[990])
|
||||
print " worst: {}".format(elapsed_times[999])
|
||||
print("Time required to submit a trivial function call:")
|
||||
print(" Average: {}".format(average_elapsed_time))
|
||||
print(" 90th percentile: {}".format(elapsed_times[900]))
|
||||
print(" 99th percentile: {}".format(elapsed_times[990]))
|
||||
print(" worst: {}".format(elapsed_times[999]))
|
||||
# average_elapsed_time should be about 0.001
|
||||
|
||||
# measure the time required to submit a remote task to the scheduler and get the result
|
||||
@@ -53,11 +57,11 @@ class MicroBenchmarkTest(unittest.TestCase):
|
||||
elapsed_times.append(end_time - start_time)
|
||||
elapsed_times = np.sort(elapsed_times)
|
||||
average_elapsed_time = sum(elapsed_times) / 1000
|
||||
print "Time required to submit a trivial function call and get the result:"
|
||||
print " Average: {}".format(average_elapsed_time)
|
||||
print " 90th percentile: {}".format(elapsed_times[900])
|
||||
print " 99th percentile: {}".format(elapsed_times[990])
|
||||
print " worst: {}".format(elapsed_times[999])
|
||||
print("Time required to submit a trivial function call and get the result:")
|
||||
print(" Average: {}".format(average_elapsed_time))
|
||||
print(" 90th percentile: {}".format(elapsed_times[900]))
|
||||
print(" 99th percentile: {}".format(elapsed_times[990]))
|
||||
print(" worst: {}".format(elapsed_times[999]))
|
||||
# average_elapsed_time should be about 0.0013
|
||||
|
||||
# measure the time required to do do a put
|
||||
@@ -69,11 +73,11 @@ class MicroBenchmarkTest(unittest.TestCase):
|
||||
elapsed_times.append(end_time - start_time)
|
||||
elapsed_times = np.sort(elapsed_times)
|
||||
average_elapsed_time = sum(elapsed_times) / 1000
|
||||
print "Time required to put an int:"
|
||||
print " Average: {}".format(average_elapsed_time)
|
||||
print " 90th percentile: {}".format(elapsed_times[900])
|
||||
print " 99th percentile: {}".format(elapsed_times[990])
|
||||
print " worst: {}".format(elapsed_times[999])
|
||||
print("Time required to put an int:")
|
||||
print(" Average: {}".format(average_elapsed_time))
|
||||
print(" 90th percentile: {}".format(elapsed_times[900]))
|
||||
print(" 99th percentile: {}".format(elapsed_times[990]))
|
||||
print(" worst: {}".format(elapsed_times[999]))
|
||||
# average_elapsed_time should be about 0.00087
|
||||
|
||||
ray.worker.cleanup()
|
||||
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import unittest
|
||||
@@ -8,7 +10,7 @@ import string
|
||||
import sys
|
||||
from collections import namedtuple
|
||||
|
||||
import test_functions
|
||||
import ray.test.test_functions as test_functions
|
||||
import ray.array.remote as ra
|
||||
import ray.array.distributed as da
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
|
||||
import unittest
|
||||
|
||||
Reference in New Issue
Block a user