A python binding for gloo
Project description
pygloo
Pygloo provides Python bindings for gloo. It is implemented using pybind11.
It is currenlty used in Ray for collective communication between CPUs.
Requirements
Python >= 3.6
Installation
Install From Wheels
We provide prepackaged Python wheels (manylinux2014_x86_64
,manylinux_2_24_x86_64
). To install from wheels:
pip install pygloo
Building from source
One can build pygloo from source if none of released wheels fit with the development environment.
Pygloo uses Bazel to automatically manange dependencies and compilation. To compile from source, install Bazel>=2.0.0 following the Bazel installation guide. After installing Bazel, build and install pygloo following this command:
python setup.py install
Testing
Pygloo uses Ray to create multiple, distributed processes for collective communication tests. See tests
directory.
Example
An example for allreduce.
import os
import ray
import pygloo
import numpy as np
@ray.remote(num_cpus=1)
def test_allreduce(rank, world_size, fileStore_path):
'''
rank # Rank of this process within list of participating processes
world_size # Number of participating processes
fileStore_path # The path to create filestore
'''
context = pygloo.rendezvous.Context(rank, world_size)
# Prepare device and store for rendezvous
attr = pygloo.transport.tcp.attr("localhost")
dev = pygloo.transport.tcp.CreateDevice(attr)
fileStore = pygloo.rendezvous.FileStore(fileStore_path)
store = pygloo.rendezvous.PrefixStore(str(world_size), fileStore)
context.connectFullMesh(store, dev)
sendbuf = np.array([[1,2,3],[1,2,3]], dtype=np.float32)
recvbuf = np.zeros_like(sendbuf, dtype=np.float32)
sendptr = sendbuf.ctypes.data
recvptr = recvbuf.ctypes.data
pygloo.allreduce(context, sendptr, recvptr,
sendbuf.size, pygloo.glooDataType_t.glooFloat32,
pygloo.ReduceOp.SUM, pygloo.allreduceAlgorithm.RING)
if __name__ == "__main__":
ray.init(num_cpus=6)
world_size = 2
fileStore_path = f"{ray.worker._global_node.get_session_dir_path()}" + "/collective/gloo/rendezvous"
os.makedirs(fileStore_path)
ray.get([test_allreduce.remote(rank, world_size, fileStore_path) for rank in range(world_size)])
License
Gloo is licensed under the Apache License, Version 2.0.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file pygloo-0.2.0-cp38-cp38-manylinux2014_x86_64.whl
.
File metadata
- Download URL: pygloo-0.2.0-cp38-cp38-manylinux2014_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.8
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.6.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e434054adef9df7c3d708f9184186ca092d26345a4f3a7d4cb68ccc8c1ddd366 |
|
MD5 | 78bd535186ec132945c39cd13c4ff9c2 |
|
BLAKE2b-256 | 4aeb8cacf61388435ea05a1f39f4efe7c9b669d64031297013cc6faa4730a5f2 |
File details
Details for the file pygloo-0.2.0-cp37-cp37m-manylinux2014_x86_64.whl
.
File metadata
- Download URL: pygloo-0.2.0-cp37-cp37m-manylinux2014_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.6.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64a21b2cc97058278f15b4c3afb69994f50b8ec2538354f22aee8ef287aae81d |
|
MD5 | 2bbd09f41b6c222e0de82ff38d153fda |
|
BLAKE2b-256 | 7b0b701fe8307c00b979b8a951b0eb0355c1509bdccea6b4c2637932cfa3ae44 |
File details
Details for the file pygloo-0.2.0-cp36-cp36m-manylinux2014_x86_64.whl
.
File metadata
- Download URL: pygloo-0.2.0-cp36-cp36m-manylinux2014_x86_64.whl
- Upload date:
- Size: 1.0 MB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.6.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 658dd53e35f28a4240b56c387bad56a2ad3b2e146eada3d6288b8bb866e32255 |
|
MD5 | 7a4dd5aad180bdfcc66aa4b07b32cc92 |
|
BLAKE2b-256 | 46ab2a2648933f148e05ae2cfc83c65f63cc6793ee922eb57a1d43898456f3fc |