allow importing theano.sandbox.cuda.{var,type} when nvcc is not their

this will allow building the library cuda doc on our webserver
上级 e04ac9a7
......@@ -100,6 +100,13 @@ if cuda_available:
cuda_available = False
cuda_initialization_error_message = e.message
# We must do those import to be able to create the full doc when nvcc
from theano.sandbox.cuda.var import (CudaNdarrayVariable,
CudaNdarrayConstant,
CudaNdarraySharedVariable,
float32_shared_constructor)
from theano.sandbox.cuda.type import CudaNdarrayType
if cuda_available:
#check if their is an old cuda_ndarray that was loading instead of the one we compiled!
import cuda_ndarray.cuda_ndarray
......@@ -108,11 +115,6 @@ if cuda_available:
warning("WARNING: cuda_ndarray was loaded from",cuda_ndarray.cuda_ndarray.__file__,"This is not expected as theano should compile it automatically for you. Do you have a directory called cuda_ndarray in your LD_LIBRARY_PATH environment variable? If so, please remove it as it is outdated!")
from theano.sandbox.cuda.type import CudaNdarrayType
from theano.sandbox.cuda.var import (CudaNdarrayVariable,
CudaNdarrayConstant,
CudaNdarraySharedVariable,
float32_shared_constructor)
shared_constructor = float32_shared_constructor
import basic_ops
......
......@@ -8,10 +8,13 @@ from theano import Op, Type, Apply, Variable, Constant
from theano import tensor, config
from theano import scalar as scal
import cuda_ndarray.cuda_ndarray as cuda
import cuda_ndarray
from theano.sandbox.cuda.nvcc_compiler import nvcc_module_compile_str
try:
# We must do those import to be able to create the full doc when nvcc
import cuda_ndarray.cuda_ndarray as cuda
from theano.sandbox.cuda.nvcc_compiler import nvcc_module_compile_str
import cuda_ndarray
except ImportError:
pass
class CudaNdarrayType(Type):
......@@ -358,4 +361,8 @@ copy_reg.constructor(CudaNdarray_unpickler)
def CudaNdarray_pickler(cnda):
return (CudaNdarray_unpickler, (numpy.asarray(cnda),))
copy_reg.pickle(cuda.CudaNdarray, CudaNdarray_pickler, CudaNdarray_unpickler)
try:
# In case cuda is not imported.
copy_reg.pickle(cuda.CudaNdarray, CudaNdarray_pickler, CudaNdarray_unpickler)
except NameError:
pass
......@@ -8,9 +8,12 @@ from theano import tensor
from theano.compile import SharedVariable
from theano.sandbox.cuda.type import CudaNdarrayType
from theano.sandbox.cuda import filter as type_support_filter
from theano.sandbox.cuda.basic_ops import HostFromGpu, GpuFromHost
try:
# We must do those import to be able to create the full doc when nvcc
from theano.sandbox.cuda import filter as type_support_filter
from theano.sandbox.cuda.basic_ops import HostFromGpu, GpuFromHost
except ImportError:
pass
class _operators(tensor.basic._tensor_py_operators):
"""Define a few properties and conversion methods for CudaNdarray Variables.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论