Commit ee893b1b by Ting PAN

add setup.py

1 parent 88ba833a
......@@ -19,11 +19,10 @@ option(WITH_CUDA_FP16 "Set to ON to use FP16" ON)
# set your 3rdparty
set(3RDPARTY_DIR ${PROJECT_SOURCE_DIR}/3rdparty)
# set if you want to build pydragon
#set(PYTHON_DIR /usr/include/python2.7)
set(ANACONDA_DIR /xxx/anaconda)
set(NUMPY_DIR /xxx/numpy)
# set your py27
set(PYTHON_DIR /usr/include/python2.7) # prefer
#set(ANACONDA_DIR /xxx/anaconda) # optional
set(NUMPY_DIR /xxx/numpy) # require
# set CUDA compiling architecture
set(CUDA_ARCH -gencode arch=compute_20,code=sm_20
......
message TensorProto {
repeated int32 dims = 1;
enum DataType {
FLOAT = 1;
INT32 = 2;
BYTE = 3;
STRING = 4;
FLOAT16 = 12;
}
optional DataType data_type = 2 [default = FLOAT];
repeated float float_data = 3 [packed = true];
repeated int32 int32_data = 4 [packed = true];
optional bytes byte_data = 5;
repeated bytes string_data = 6;
optional string name = 7;
}
message TensorProtos {
repeated TensorProto protos = 1;
}
message Argument {
optional string name=1;
optional float f=2;
optional int32 i=3;
optional int64 i64=9;
optional string s=4;
optional bool b=8;
repeated float floats=5;
repeated int32 ints=6;
repeated string strings=7;
}
enum DeviceType { CPU = 0; CUDA = 1; OPENCL = 2; }
message DeviceOption {
optional DeviceType device_type = 1 [default = CPU];
optional int32 gpu_id = 2 [default = 0];
optional uint32 random_seed = 3 [default = 3];
optional string engine = 4;
}
message OperatorDef {
repeated string input = 1;
repeated string output = 2;
optional string name = 3;
optional string type = 4;
repeated Argument arg= 5;
optional DeviceOption device_option = 6;
optional bool debug_mode = 7 [default = false];
}
message GradientTarget {
optional string cost = 1;
optional string wrt = 2;
optional string external = 3;
}
message UpdateTarget {
optional string name = 1;
optional string type = 2;
repeated string tensor = 3;
repeated Argument arg = 4;
}
// simply copy from caffe1
message TensorFiller {
optional string tensor = 1;
optional string type = 2 [default = 'constant'];
optional float value = 3 [default = 0];
optional float low = 4 [default = 0];
optional float high = 5 [default = 1];
optional float mean = 6 [default = 0];
optional float std = 7 [default = 1];
optional float scale = 8 [default = 3];
enum VarianceNorm { FAN_IN = 0; FAN_OUT = 1; FAN_AVG=2; }
optional VarianceNorm variance_norm = 9 [default = FAN_IN];
}
message GraphDef {
optional string name = 1;
repeated OperatorDef op = 2;
optional string graph_type = 3;
optional DeviceOption device_option = 5;
repeated Argument arg = 6;
repeated string target = 7;
repeated GradientTarget g_target = 8;
repeated UpdateTarget u_target = 9;
optional bool debug_mode = 10 [default = false];
}
......@@ -107,4 +107,4 @@ class DataBatch(object):
'num_transformers': self._num_transformers,
'num_prefetching': self._prefetch}
pprint.pprint(params)
print '---------------------------------------------------------'
\ No newline at end of file
print '---------------------------------------------------------'
from distutils.core import setup, Extension
import os.path, sys
import shutil
packages = []
def find_packages(root_dir):
filenames = os.listdir(root_dir)
for filename in filenames:
filepath = os.path.join(root_dir, filename)
if os.path.isdir(filepath):
find_packages(filepath)
else:
if filename == '__init__.py':
packages.append(root_dir.replace('python', 'dragon')
.replace('\\', '.')
.replace('/', '.'))
def find_modules():
dragon_c_lib_win32 = 'lib/dragon.dll'
dragon_c_lib_other = 'lib/libdragon.so'
if os.path.exists(dragon_c_lib_win32):
shutil.copy(dragon_c_lib_win32, 'python/libdragon.pyd')
elif os.path.exists(dragon_c_lib_other):
shutil.copy(dragon_c_lib_other, 'python/libdragon.so')
else:
print('ERROR: Unable to find modules. built Dragon using CMake.')
sys.exit()
def find_resources():
c_lib = ['libdragon.*']
protos = ['protos/*.proto', 'vm/caffe/proto/*.proto']
others = []
return c_lib + protos + others
find_packages('python')
find_modules()
setup(name = 'dragon',
version='0.2',
description = 'Dragon: A Computation Graph Virtual Machine Based Deep Learning Framework',
url='https://github.com/neopenx/Dragon',
author='Ting Pan',
license='BSD 2-Clause',
packages=packages,
package_dir={'dragon': 'python'},
package_data={'dragon': find_resources()})
\ No newline at end of file
......@@ -31,8 +31,9 @@
4. Configure Dragon/CMakeLists.txt
- Select optional libraries [CUDA / CUDNN / BLAS / SSE / MPI / MPI_CUDA_AWARE / CUDA_FP16]
- Set 3rdparty path (recommend to keep defualt)
- Set python path
- Set python & numpy root path
- Set cuda compiling architectures if necessary
- GCC version(4.8+, 5.0-) should add ``-std=c++11`` to ``CUDA_NVCC_FLAGS``, if ``nullptr`` is not found.
5. Environment Variables
### Linux(Only for OpenMPI):
......@@ -100,9 +101,7 @@
8. Deploy
```Shell
cp Dragon/libs/libdragon.so Dragon/python
cp Dragon/python /usr/lib/python2.7/dist-packages/dragon (For Python)
cp Dragon/python ANACONDA_DIR/libs/python2.7/dist-packages/dragon (For Anaconda)
python Dragon/setup.py install
```
----
......@@ -189,4 +188,3 @@ Please cite Dragon in your publications if it helps your research:
Title = {Dragon: A Computation Graph Virtual Machine Based Deep Learning Framework},
Year = {2017}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!