Replaced cxfreeze with pyinstaller. Works better.
This commit is contained in:
@@ -1,13 +1,18 @@
|
|||||||
set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py")
|
find_program(PYINSTALLER pyinstaller)
|
||||||
set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
|
|
||||||
|
if(PYINSTALLER)
|
||||||
|
|
||||||
|
set(SPEC_IN "${CMAKE_CURRENT_SOURCE_DIR}/pyinstaller_build.spec")
|
||||||
|
set(SPEC "${CMAKE_CURRENT_BINARY_DIR}/pyinstaller_build.spec")
|
||||||
set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build/timestamp")
|
set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build/timestamp")
|
||||||
file(GLOB DEPS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/pysrc/*.py")
|
file(GLOB DEPS RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/pysrc/*.py")
|
||||||
LIST(APPEND DEPS "${CMAKE_CURRENT_SOURCE_DIR}/setup.py")
|
LIST(APPEND DEPS "${CMAKE_CURRENT_SOURCE_DIR}/pyinstaller_build.spec")
|
||||||
|
|
||||||
configure_file(${SETUP_PY_IN} ${SETUP_PY})
|
configure_file(${SPEC_IN} ${SPEC})
|
||||||
add_custom_command(OUTPUT ${OUTPUT}
|
add_custom_command(OUTPUT ${OUTPUT}
|
||||||
COMMAND ${PYTHON} ${SETUP_PY} build
|
COMMAND ${PYINSTALLER} ${SPEC_IN} ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
|
COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT}
|
||||||
DEPENDS ${DEPS})
|
DEPENDS ${DEPS} pyatidlas)
|
||||||
add_custom_target(autotune ALL DEPENDS ${OUTPUT})
|
add_custom_target(autotune ALL DEPENDS ${OUTPUT})
|
||||||
install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install)")
|
|
||||||
|
endif()
|
||||||
|
34
python/autotune/pyinstaller_build.spec
Normal file
34
python/autotune/pyinstaller_build.spec
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/usr/bin/env
|
||||||
|
import os, sys
|
||||||
|
|
||||||
|
prefix = sys.argv[2]
|
||||||
|
|
||||||
|
sys.path.append('/home/philippe/Development/ATIDLAS/build/python/pyatidlas/build/lib.linux-x86_64-2.7/')
|
||||||
|
sys.path.append('/home/philippe/Development/pyviennacl-dev/build/lib.linux-x86_64-2.7/')
|
||||||
|
sys.path.append(os.path.join(prefix, 'pysrc'))
|
||||||
|
|
||||||
|
a = Analysis([os.path.join(prefix, 'pysrc','autotune.py')],
|
||||||
|
hiddenimports=['scipy.sparse.csgraph._validation',
|
||||||
|
'scipy.special._ufuncs_cxx',
|
||||||
|
'scipy.sparse.linalg.dsolve.umfpack',
|
||||||
|
'scipy.integrate.vode',
|
||||||
|
'scipy.integrate.lsoda',
|
||||||
|
'sklearn.utils.sparsetools._graph_validation',
|
||||||
|
'sklearn.utils.sparsetools._graph_tools',
|
||||||
|
'sklearn.utils.lgamma'],
|
||||||
|
hookspath=None,
|
||||||
|
excludes=['scipy.io.matlab','matplotlib','PyQt4'],
|
||||||
|
runtime_hooks=None)
|
||||||
|
dict_tree = Tree(os.path.join(prefix, 'external', 'pyopencl-2014.1-py2.7.egg-info'), prefix = 'pyopencl-2014.1-py2.7.egg-info')
|
||||||
|
a.datas += dict_tree
|
||||||
|
pyz = PYZ(a.pure)
|
||||||
|
exe = EXE(pyz,
|
||||||
|
a.scripts,
|
||||||
|
a.binaries,
|
||||||
|
a.zipfiles,
|
||||||
|
a.datas,
|
||||||
|
name='autotune',
|
||||||
|
debug=False,
|
||||||
|
strip=None,
|
||||||
|
upx=True,
|
||||||
|
console=True )
|
@@ -1,63 +1,20 @@
|
|||||||
from sklearn import tree
|
from sklearn import tree
|
||||||
from sklearn import ensemble
|
from sklearn import ensemble
|
||||||
|
|
||||||
from numpy import array, bincount, mean, std, max, argmax, min, argmin, median
|
from numpy import array, bincount, mean, std, max, argmax, min, argmin, median
|
||||||
from scipy.stats import gmean
|
|
||||||
|
|
||||||
|
|
||||||
# def random_forest(Xtr, Ytr):
|
def gmean(a, axis=0, dtype=None):
|
||||||
# clf = ensemble.RandomForestRegressor(10, max_depth=7).fit(Xtr,Ytr)
|
if not isinstance(a, np.ndarray): # if not an ndarray object attempt to convert it
|
||||||
#
|
log_a = np.log(np.array(a, dtype=dtype))
|
||||||
# def predict_tree(tree, x):
|
elif dtype: # Must change the default dtype allowing array type
|
||||||
# tree_ = tree.tree_
|
if isinstance(a,np.ma.MaskedArray):
|
||||||
# children_left = tree_.children_left
|
log_a = np.log(np.ma.asarray(a, dtype=dtype))
|
||||||
# children_right = tree_.children_right
|
else:
|
||||||
# threshold = tree_.threshold
|
log_a = np.log(np.asarray(a, dtype=dtype))
|
||||||
# feature = tree_.feature
|
else:
|
||||||
# value = tree_.value
|
log_a = np.log(a)
|
||||||
# idx = 0
|
return np.exp(log_a.mean(axis=axis))
|
||||||
# while children_left[idx]!=-1:
|
|
||||||
# if x[0, feature[idx]] <= threshold[idx]:
|
|
||||||
# idx = children_left[idx]
|
|
||||||
# else:
|
|
||||||
# idx = children_right[idx]
|
|
||||||
# return value[[idx],:,:][:,:,0]
|
|
||||||
#
|
|
||||||
# s = 0
|
|
||||||
# for e in clf.estimators_:
|
|
||||||
# tree_ = e.tree_
|
|
||||||
# children_left = tree_.children_left
|
|
||||||
# children_right = tree_.children_right
|
|
||||||
# threshold = tree_.threshold
|
|
||||||
# feature = tree_.feature
|
|
||||||
# value = tree_.value
|
|
||||||
# s = s + value.size + feature.size + threshold.size + children_right.size + children_left.size
|
|
||||||
# print s*4*1e-3
|
|
||||||
# return clf, clf.predict
|
|
||||||
#
|
|
||||||
# def train_nn(layer_sizes, XTr, YTr, XTe, YTe):
|
|
||||||
# optimizer = HF(open(os.devnull, 'w'), 15)
|
|
||||||
# optimizer.doCGBacktracking = True
|
|
||||||
# net = FeedforwardNeuralNet(layer_sizes, [Act.Tanh() for i in range(len(layer_sizes)-2)], Act.Linear(), 1e-5)
|
|
||||||
#
|
|
||||||
# nbatch=10
|
|
||||||
# bsize = XTr.shape[0]/nbatch
|
|
||||||
# data = ((XTr[(i%nbatch)*bsize:(i%nbatch+1)*bsize,:], YTr[(i%nbatch)*bsize:(i%nbatch+1)*bsize,:]) for i in range(nbatch))
|
|
||||||
# data = HFDataSource(data, bsize, gradBatchSize = nbatch*bsize, curvatureBatchSize = bsize, lineSearchBatchSize =nbatch*bsize, gradBatchIsTrainingSet=True)
|
|
||||||
# iters = optimizer.optimize(HFModel(net), data, 300, otherPrecondDampingTerm=net.L2Cost)
|
|
||||||
# bestte = collections.deque([float("inf")]*5, maxlen=5)
|
|
||||||
# for i,w in enumerate(iters):
|
|
||||||
# Diffte = YTe - net.predictions(XTe).as_numpy_array()
|
|
||||||
# Difftr = YTr - net.predictions(XTr).as_numpy_array()
|
|
||||||
# Ete = np.sum(Diffte**2)
|
|
||||||
# Etr = np.sum(Difftr**2)
|
|
||||||
# bestte.append(min(min(bestte),Ete))
|
|
||||||
# if min(bestte)==max(bestte):
|
|
||||||
# print 'Final test error: ', Ete
|
|
||||||
# return net, net.predictions
|
|
||||||
# print 'Iteration %d | Test error = %.2f | Train error = %.2f'%(i, Ete, Etr)
|
|
||||||
# return net, net.predictions
|
|
||||||
|
|
||||||
def train_model(X, Y, profiles, metric):
|
def train_model(X, Y, profiles, metric):
|
||||||
print("Building the model...")
|
print("Building the model...")
|
||||||
|
|
||||||
|
@@ -1,33 +0,0 @@
|
|||||||
import os
|
|
||||||
import sys
|
|
||||||
from setuptools import Extension, setup
|
|
||||||
from cx_Freeze import setup, Executable
|
|
||||||
|
|
||||||
def main():
|
|
||||||
sys.path.append('/home/philippe/Development/ATIDLAS/build/python/pyatidlas/build/lib.linux-x86_64-2.7/')
|
|
||||||
sys.path.append('/home/philippe/Development/pyviennacl-dev/build/lib.linux-x86_64-2.7/')
|
|
||||||
sys.path.append(os.path.join('${CMAKE_CURRENT_SOURCE_DIR}','pysrc'))
|
|
||||||
extdir = os.path.join('${CMAKE_CURRENT_SOURCE_DIR}','external')
|
|
||||||
|
|
||||||
buildOptions = dict(packages = ['scipy.sparse.csgraph._validation',
|
|
||||||
'scipy.special._ufuncs_cxx',
|
|
||||||
'scipy.sparse.linalg.dsolve.umfpack',
|
|
||||||
'scipy.integrate.vode',
|
|
||||||
'scipy.integrate.lsoda',
|
|
||||||
'sklearn.utils.sparsetools._graph_validation',
|
|
||||||
'sklearn.utils.lgamma'],
|
|
||||||
excludes = ['matplotlib'],
|
|
||||||
bin_path_includes = ['/usr/lib/x86_64-linux-gnu/'],
|
|
||||||
include_files = [(os.path.abspath(os.path.join(extdir, x)), x) for x in os.listdir(extdir)])
|
|
||||||
base = 'Console'
|
|
||||||
executables = [
|
|
||||||
Executable(os.path.join('${CMAKE_CURRENT_SOURCE_DIR}','pysrc','autotune.py'), base=base)
|
|
||||||
]
|
|
||||||
setup(name='atidlas-tune',
|
|
||||||
version = '1.0',
|
|
||||||
description = 'Auto-tuner for ATIDLAS',
|
|
||||||
options = dict(build_exe = buildOptions),
|
|
||||||
executables = executables)
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
Reference in New Issue
Block a user