提交 4ac9cbd2 authored 作者: James Bergstra's avatar James Bergstra

merge

......@@ -7,6 +7,8 @@ from theano.gof.cc import OpWiseCLinker
from theano import gof
import theano.config as config
import_time = time.time()
class ProfileMode(Mode):
def __init__(self, linker=default_linker, optimizer=default_optimizer):
local_time = [0.0]
......@@ -179,7 +181,7 @@ class ProfileMode(Mode):
print '---------------------------'
print ''
print 'local_time %fs (Time spent running thunks)'% local_time
print 'local_time %.3fs (Time spent running thunks)'% local_time
if print_apply:
print 'Apply-wise summary: <% of local_time spent at this position> <cumulative seconds> <apply time> <time per call> <nb_call> <Apply position> <Apply Op name>'
......@@ -247,8 +249,15 @@ class ProfileMode(Mode):
%(max(0, len(sotimes)-n_ops_to_print),
sum(f for f, t, a, ci, nb_call in sotimes[n_ops_to_print:])*100,
sum(t for f, t, a, ci, nb_call in sotimes[n_ops_to_print:]))
print '(*) Op is running a c implementation'
print 'compile time: %.3fs'%compile_time
print
total_time = time.time() - import_time
other_time = total_time - local_time - compile_time
print 'Time since import %.3fs'%(total_time)
print 'Local time %.3fs %.1f%%(Time spent running thunks)'% (local_time,local_time/total_time*100)
print 'Compile time: %.3fs %.1f%%'%(compile_time, compile_time/total_time*100)
print 'Other time since import %.3fs %.1f%%'%(other_time,other_time/total_time*100)
if any([x[2].__name__.startswith("Gpu") for x in sotimes]):
cpu=[]
......
CUDA_NDARRAY?=../../../../cuda_ndarray
NUMPY_INCLUDE?=/usr/include/python2.6
type_support.so : type_support.cu $(CUDA_NDARRAY)/cuda_ndarray.so
nvcc -g -shared -I$(CUDA_NDARRAY) -I$(CUDA_ROOT)/include -I$(NUMPY_INCLUDE) -o type_support.so -Xcompiler -fPIC type_support.cu -L$(CUDA_ROOT)/lib -L$(CUDA_NDARRAY) -lcuda_ndarray $(CFLAGS)
clean :
rm type_support.so *~ *.pyc */*~ */*.pyc
from theano.sandbox.cuda.type import CudaNdarrayType
import os, sys
from theano.gof.compiledir import get_compiledir
from theano.compile import optdb
import logging, copy
_logger_name = 'theano_cuda_ndarray'
_logger = logging.getLogger(_logger_name)
_logger.setLevel(logging.INFO)
_logger.addHandler(logging.StreamHandler())
def warning(*msg):
_logger.warning(_logger_name+'WARNING: '+' '.join(str(m) for m in msg))
def info(*msg):
_logger.info(_logger_name+'INFO: '+' '.join(str(m) for m in msg))
def debug(*msg):
_logger.debug(_logger_name+'DEBUG: '+' '.join(str(m) for m in msg))
#compile type_support.cu
#this need that nvcc(part of cuda) is installed
old_file = os.path.join(os.path.split(__file__)[0],'type_support.so')
if os.path.exists(old_file):
os.remove(old_file)
try:
sys.path.append(get_compiledir())
from type_support.type_support import *
except ImportError:
import nvcc_compiler
print __file__
cuda_path=os.path.split(old_file)[0]
code = open(os.path.join(cuda_path, "type_support.cu")).read()
loc = os.path.join(get_compiledir(),'type_support')
if not os.path.exists(loc):
os.makedirs(loc)
CUDA_NDARRAY=os.getenv('CUDA_NDARRAY')
include_dirs=[]
lib_dirs=[]
if CUDA_NDARRAY:
include_dirs.append(CUDA_NDARRAY)
lib_dirs.append(CUDA_NDARRAY)
else:
import theano.sandbox
path = os.path.split(os.path.split(os.path.split(theano.sandbox.__file__)[0])[0])[0]
path2 = os.path.join(path,'cuda_ndarray')
if os.path.isdir(path2):
include_dirs.append(path2)
lib_dirs.append(path2)
else:
path = os.path.split(path)[0]
path2 = os.path.join(path,'cuda_ndarray')
include_dirs.append(path2)
lib_dirs.append(path2)
nvcc_compiler.nvcc_module_compile_str('type_support', code, location = loc, include_dirs=include_dirs, lib_dirs=lib_dirs, libs=['cuda_ndarray'])
from type_support.type_support import *
from theano.sandbox.cuda.type import CudaNdarrayType
from theano.sandbox.cuda.var import (CudaNdarrayVariable,
CudaNdarrayConstant,
CudaNdarraySharedVariable,
......@@ -12,22 +78,7 @@ from basic_ops import (GpuFromHost, HostFromGpu, GpuElemwise,
import opt
import cuda_ndarray
import os
import theano.config as config
from theano.compile import optdb
import logging, copy
_logger_name = 'theano_cuda_ndarray'
_logger = logging.getLogger(_logger_name)
_logger.setLevel(logging.WARN)
_logger.addHandler(logging.StreamHandler())
def warning(*msg):
_logger.warning(_logger_name+'WARNING: '+' '.join(str(m) for m in msg))
def info(*msg):
_logger.info(_logger_name+'INFO: '+' '.join(str(m) for m in msg))
def debug(*msg):
_logger.debug(_logger_name+'DEBUG: '+' '.join(str(m) for m in msg))
def use(device=config.THEANO_GPU):
if use.device_number is None:
......
......@@ -5,7 +5,7 @@ from theano import Op, Type, Apply, Variable, Constant
from theano import tensor, scalar, config
from theano.sandbox.cuda.type import CudaNdarrayType
from theano.sandbox.cuda.type_support import filter as type_support_filter
from theano.sandbox.cuda import filter as type_support_filter
from theano.sandbox.cuda.elemwise import NaiveAlgo
......
......@@ -14,7 +14,7 @@ import logging, StringIO, time, sys
import numpy
import theano
from theano.compile.sandbox import shared, pfunc
from theano.compile import shared, pfunc
from theano import tensor
from theano.tensor.nnet import softplus
from theano.sandbox.softsign import softsign
......
import sys, time
from theano.compile.sandbox.sharedvalue import shared
from theano.compile.sandbox.pfunc import pfunc
from theano.compile.sharedvalue import shared
from theano.compile.pfunc import pfunc
from theano import tensor
import numpy
......
import sys, time
from theano.compile.sandbox.sharedvalue import shared
from theano.compile.sandbox.pfunc import pfunc
from theano.compile.sharedvalue import shared
from theano.compile.pfunc import pfunc
from theano import tensor
import theano
import numpy
......
import sys, time
from theano.compile.sandbox.sharedvalue import shared
from theano.compile.sandbox.pfunc import pfunc
from theano.compile.sharedvalue import shared
from theano.compile.pfunc import pfunc
from theano import tensor
import numpy
......
......@@ -9,7 +9,7 @@ import theano.config as config
import cuda_ndarray
from theano.sandbox.cuda.type_support import filter as type_support_filter
from theano.sandbox.cuda import filter as type_support_filter
from theano.sandbox.cuda.nvcc_compiler import nvcc_module_compile_str
......
......@@ -5,7 +5,7 @@ from theano import tensor
from theano.compile import shared, SharedVariable, shared_constructor
from theano.sandbox.cuda.type import CudaNdarrayType
from theano.sandbox.cuda.type_support import filter as type_support_filter
from theano.sandbox.cuda import filter as type_support_filter
from theano.sandbox.cuda.basic_ops import HostFromGpu, GpuFromHost
......
......@@ -30,7 +30,7 @@ __docformat__ = 'restructedtext en'
import traceback
import numpy
import theano
import theano.compile.sandbox
import theano.compile
from theano.tensor import opt
from theano import gof
from theano.compile import optdb
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论