Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[Bump version] Make python package install more easily #181

Merged
merged 2 commits into from
Sep 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions doc/env_var.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ Environment Variables
MXNet have several settings that can be changed via environment variable.
Usually you do not need to change these settings, but they are listed here for reference.

* MXNET_GPU_WORKER_NTHREADS (default=1 when number of cpu<8, otherwise 2)
* MXNET_GPU_WORKER_NTHREADS (default=1)
- Maximum number of threads that do the computation job on each GPU.
* MXNET_GPU_COPY_NTHREADS (default=1)
- Maximum number of threads that do memory copy job on each GPU.
* MXNET_CPU_WORKER_NTHREADS (default=1)
- Maximum number of threads that do the CPU computation job.
* MXNET_EXEC_ENABLE_INPLACE (default=true)
* MXNET_CPU_PRIORITY_NTHREADS (default=4)
- Number of threads given to prioritized CPU jobs.
* MXNET_EXEC_ENABLE_INPLACE (default=true)
- Whether to enable inplace optimization in symbolic execution.
* MXNET_EXEC_MATCH_RANGE (default=10)
- The rough matching scale in symbolic execution memory allocator.
Expand All @@ -20,3 +22,8 @@ Usually you do not need to change these settings, but they are listed here for r
- NaiveEngine: very simple engine that use master thread to do computation.
- ThreadedEngine: a threaded engine that uses global thread pool to schedule jobs.
- ThreadedEnginePerDevice: a threaded engine that allocates thread per GPU.
* MXNET_KVSTORE_REDUCTION_NTHREADS (default=4)
- Number of threads used for summing of big arrays.
* MXNET_KVSTORE_BIGARRAY_BOUND (default=1e6)
- The minimum size of "big array".
- When the array size is bigger than this threshold, MXNET_KVSTORE_REDUCTION_NTHREADS threads will be used for reduction.
28 changes: 14 additions & 14 deletions include/mxnet/ndarray.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,10 @@ struct NDArrayFunctionReg
* \param fsetvalue function body to set
* \return ref to the registered entry, used to set properties
*/
inline NDArrayFunctionReg &set_function(void fsetvalue(const real_t &rhs,
NDArray *out)) {
inline NDArrayFunctionReg &set_function(void (*fsetvalue)(const real_t &rhs,
NDArray *out)) {
body = [fsetvalue] (NDArray **used_vars, real_t *s, NDArray **mutate_vars) {
fsetvalue(s[0], mutate_vars[0]);
(*fsetvalue)(s[0], mutate_vars[0]);
};
num_mutate_vars = 1; num_scalars = 1;
this->add_argument("src", "real_t", "Source input to the function.");
Expand All @@ -482,12 +482,12 @@ struct NDArrayFunctionReg
* \param fbinary function body to set
* \return ref to the registered entry, used to set properties
*/
inline NDArrayFunctionReg &set_function(void fbinary(const NDArray &lhs,
const NDArray &rhs,
NDArray *out)) {
inline NDArrayFunctionReg &set_function(void (*fbinary)(const NDArray &lhs,
const NDArray &rhs,
NDArray *out)) {
body = [fbinary] (NDArray **used_vars,
real_t *s, NDArray **mutate_vars) {
fbinary(*used_vars[0], *used_vars[1], mutate_vars[0]);
(*fbinary)(*used_vars[0], *used_vars[1], mutate_vars[0]);
};
num_use_vars = 2; num_mutate_vars = 1;
type_mask = kNDArrayArgBeforeScalar | kAcceptEmptyMutateTarget;
Expand All @@ -501,12 +501,12 @@ struct NDArrayFunctionReg
* \param fscalar function body to set
* \return ref to the registered entry, used to set properties
*/
inline NDArrayFunctionReg &set_function(void fscalar(const NDArray &lhs,
const real_t &rhs,
NDArray *out)) {
inline NDArrayFunctionReg &set_function(void (*fscalar)(const NDArray &lhs,
const real_t &rhs,
NDArray *out)) {
body = [fscalar] (NDArray **used_vars,
real_t *s, NDArray **mutate_vars) {
fscalar(*used_vars[0], s[0], mutate_vars[0]);
(*fscalar)(*used_vars[0], s[0], mutate_vars[0]);
};
num_use_vars = 1; num_mutate_vars = 1; num_scalars = 1;
type_mask = kNDArrayArgBeforeScalar | kAcceptEmptyMutateTarget;
Expand All @@ -520,11 +520,11 @@ struct NDArrayFunctionReg
* \param funary function body to set
* \return ref to the registered entry, used to set properties
*/
inline NDArrayFunctionReg &set_function(void funary(const NDArray &src,
NDArray *out)) {
inline NDArrayFunctionReg &set_function(void (*funary)(const NDArray &src,
NDArray *out)) {
body = [funary] (NDArray **used_vars,
real_t *s, NDArray **mutate_vars) {
funary(*used_vars[0], mutate_vars[0]);
(*funary)(*used_vars[0], mutate_vars[0]);
};
num_use_vars = 1; num_mutate_vars = 1;
type_mask = kNDArrayArgBeforeScalar | kAcceptEmptyMutateTarget;
Expand Down
3 changes: 3 additions & 0 deletions python/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
dist
*.egg-info
build
9 changes: 9 additions & 0 deletions python/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
MXNet Python Package
====================
MXNet is a deep learning framework designed for both *efficiency* and *flexibility*.
It allows you to mix the flavours of deep learning programs together to maximize the efficiency and your productivity.


Installation
------------
To install, check [Build Instruction](http://mxnet.readthedocs.org/en/latest/build.html)
2 changes: 1 addition & 1 deletion python/mxnet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
from . import callback
from . import misc

__version__ = "0.1.0"
__version__ = base.__version__
36 changes: 4 additions & 32 deletions python/mxnet/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
""" ctypes library of mxnet and helper functions """
from __future__ import absolute_import

import os
import sys
import ctypes
import platform
import numpy as np
import atexit
from . import libinfo

__all__ = ['MXNetError']
#----------------------------
Expand All @@ -30,43 +29,16 @@ class MXNetError(Exception):
"""Error that will be throwed by all mxnet functions"""
pass


def find_lib_path():
"""Find MXNet dynamic library files.

Returns
-------
lib_path : list(string)
List of all found path to the libraries
"""
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
api_path = os.path.join(curr_path, '../../lib/')
dll_path = [curr_path, api_path]
if os.name == 'nt':
if platform.architecture()[0] == '64bit':
dll_path.append(os.path.join(api_path, '../windows/x64/Release/'))
else:
dll_path.append(os.path.join(api_path, '../windows/Release/'))
if os.name == 'nt':
dll_path = [os.path.join(p, 'mxnet.dll') for p in dll_path]
else:
dll_path = [os.path.join(p, 'libmxnet.so') for p in dll_path]
lib_path = [p for p in dll_path if os.path.exists(p) and os.path.isfile(p)]
if len(lib_path) == 0:
raise MXNetError('Cannot find find the files.\n' +
'List of candidates:\n' + str('\n'.join(dll_path)))
return lib_path


def _load_lib():
"""Load libary by searching possible path."""
lib_path = find_lib_path()
lib_path = libinfo.find_lib_path()
lib = ctypes.cdll.LoadLibrary(lib_path[0])
# DMatrix functions
lib.MXGetLastError.restype = ctypes.c_char_p
return lib


# version number
__version__ = libinfo.__version__
# library instance of mxnet
_LIB = _load_lib()

Expand Down
35 changes: 35 additions & 0 deletions python/mxnet/libinfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# coding: utf-8
"""Information about mxnet."""
from __future__ import absolute_import
import os
import platform

def find_lib_path():
"""Find MXNet dynamic library files.

Returns
-------
lib_path : list(string)
List of all found path to the libraries
"""
curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
api_path = os.path.join(curr_path, '../../lib/')
dll_path = [curr_path, api_path]
if os.name == 'nt':
if platform.architecture()[0] == '64bit':
dll_path.append(os.path.join(api_path, '../../windows/x64/Release/'))
else:
dll_path.append(os.path.join(api_path, '../../windows/Release/'))
if os.name == 'nt':
dll_path = [os.path.join(p, 'mxnet.dll') for p in dll_path]
else:
dll_path = [os.path.join(p, 'libmxnet.so') for p in dll_path]
lib_path = [p for p in dll_path if os.path.exists(p) and os.path.isfile(p)]
if len(lib_path) == 0:
raise RuntimeError('Cannot find find the files.\n' +
'List of candidates:\n' + str('\n'.join(dll_path)))
return lib_path


# current version
__version__ = "0.5.0"
21 changes: 14 additions & 7 deletions python/setup.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
"""Setup script for mxnet."""
# pylint: disable=invalid-name, exec-used
"""Setup mxnet package."""
from __future__ import absolute_import
import sys
import os
from setuptools import setup
sys.path.insert(0, '.')
import mxnet

LIB_PATH = mxnet.base.find_lib_path()
# We can not import `mxnet.info.py` in setup.py directly since mxnet/__init__.py
# Will be invoked which introduces dependences
CURRENT_DIR = os.path.dirname(__file__)
libinfo_py = os.path.join(CURRENT_DIR, 'mxnet/libinfo.py')
libinfo = {'__file__': libinfo_py}
exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinfo)

LIB_PATH = libinfo['find_lib_path']()
__version__ = libinfo['__version__']

setup(name='mxnet',
version=mxnet.__version__,
description=mxnet.__doc__,
version=__version__,
description=open(os.path.join(CURRENT_DIR, 'README.md')).read(),
install_requires=[
'numpy',
],
Expand Down