import tensorflow as tf def _load_library(name): """Loads a .so file containing the specified operators. Args: name: The name of the .so file to load. Raises: NotFoundError if were not able to load .so file. """ filename = resource_loader.get_path_to_datafile(name) library = load_library.load_op_library(filename) return library C_LIB = _load_library('c_lib' + get_ext_suffix()) _basics = _BytePSBasics(__file__, 'c_lib') # import basic methods init = _basics.init shutdown = _basics.shutdown suspend = _basics.suspend resume = _basics.resume size = _basics.size local_size = _basics.local_size rank = _basics.rank local_rank = _basics.local_rank dll_path = os.path.join(os.path.dirname(__file__), 'c_lib' + get_ext_suffix())
import tensorflow as tf def _load_library(name): """Loads a .so file containing the specified operators. Args: name: The name of the .so file to load. Raises: NotFoundError if were not able to load .so file. """ filename = resource_loader.get_path_to_datafile(name) library = load_library.load_op_library(filename) return library C_LIB = _load_library('c_lib' + get_ext_suffix()) _basics = _BytePSBasics(__file__, 'c_lib') # import basic methods init = _basics.init shutdown = _basics.shutdown suspend = _basics.suspend resume = _basics.resume size = _basics.size local_size = _basics.local_size rank = _basics.rank local_rank = _basics.local_rank dll_path = os.path.join(os.path.dirname(__file__), 'c_lib' + get_ext_suffix()) TF_LIB_CTYPES = ctypes.CDLL(dll_path, ctypes.RTLD_GLOBAL)
from mxnet.base import c_str, check_call, string_types from byteps.common import get_ext_suffix from byteps.common import BytePSBasics as _BytePSBasics _basics = _BytePSBasics(__file__, 'c_lib') # import basic methods init = _basics.init shutdown = _basics.shutdown size = _basics.size local_size = _basics.local_size rank = _basics.rank local_rank = _basics.local_rank dll_path = os.path.join(os.path.dirname(__file__), 'c_lib' + get_ext_suffix()) MXNET_LIB_CTYPES = ctypes.CDLL(dll_path, ctypes.RTLD_GLOBAL) def byteps_push_pull(tensor, version=0, priority=0, name=None, is_average=True): """ A function that performs pushing and pulling tensors The operation is keyed by the name. If name is not provided, an incremented auto-generated name is used. The tensor type and shape must be the same on all BytePS processes for a given name. The reduction will not start until all processes are ready to send and receive the tensor. This acts as a thin wrapper around an autograd function. If your input tensor requires tensors, then callings this function will allow tensors to be computed and backpropagated.
from byteps.common import get_ext_suffix from byteps.common import BytePSBasics as _BytePSBasics _basics = _BytePSBasics(__file__, 'c_lib') # import basic methods init = _basics.init shutdown = _basics.shutdown suspend = _basics.suspend resume = _basics.resume size = _basics.size local_size = _basics.local_size rank = _basics.rank local_rank = _basics.local_rank dll_path = os.path.join(os.path.dirname(__file__), 'c_lib' + get_ext_suffix()) MXNET_LIB_CTYPES = ctypes.CDLL(dll_path, ctypes.RTLD_GLOBAL) def byteps_push_pull(tensor, version=0, priority=0, name=None, is_average=True): """ A function that performs pushing and pulling tensors The operation is keyed by the name. If name is not provided, an incremented auto-generated name is used. The tensor type and shape must be the same on all BytePS processes for a given name. The reduction will not start until all processes are ready to send and receive the tensor.
def run(): dll_path = os.path.join(os.path.dirname(__file__), 'c_lib' + get_ext_suffix()) SERVER_LIB_CTYPES = ctypes.CDLL(dll_path, ctypes.RTLD_GLOBAL) SERVER_LIB_CTYPES.byteps_server()