Theano在以模块形式运行Python时无法使用GPU(Python-m)
我构建了一个Python包,这样我就可以进行相关导入,如:Theano在以模块形式运行Python时无法使用GPU(Python-m),python,theano,Python,Theano,我构建了一个Python包,这样我就可以进行相关导入,如: from ..utils import gen_utils 从 如果我的文件结构类似于: package_name/ --utils/ ----gen_utils.py --gpu_code/ ----script_using_theano.py 但是,当我使用\u theano运行python-m package\u name.gpu\code.script\u时,会出现以下错误: ERROR (theano.sandbox.cu
from ..utils import gen_utils
从
如果我的文件结构类似于:
package_name/
--utils/
----gen_utils.py
--gpu_code/
----script_using_theano.py
但是,当我使用\u theano运行python-m package\u name.gpu\code.script\u时,会出现以下错误:
ERROR (theano.sandbox.cuda): Failed to compile cuda_ndarray.cu: libcublas.so.7.5: cannot open shared object file: No such file or directory
WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not available (error: cuda unavilable)
当我刚刚运行时,不会出现此错误
python包\u名称/gpu\u代码/script\u使用\u theano.py
在这种情况下,我可以很好地使用GPU。我想知道是否有一些Theano配置设置是通过将python作为模块运行而开始更改的?您是如何从顶部文件的目录之外导入文件的?如果您没有使用
import sys
sys.path.insert(0, './path/to/some/place/with/files/for/importing1')
sys.path.insert(0, './path/to/some/place/with/files/for/importing2')
import thing1
import thing2
我建议您这样做。所有东西都是相对导入的?我不知道你的意思。不管怎么说,问题不在于不能导入任何东西,而在于当Python作为模块运行时不能访问GPU。啊,好吧,我明白你的意思了。Theano需要导入相对于我的主目录的路径才能查看其配置文件。因为我是作为一个模块运行的,主目录不再位于Python的路径中,所以我需要显式地添加它。成功了
import sys
sys.path.insert(0, './path/to/some/place/with/files/for/importing1')
sys.path.insert(0, './path/to/some/place/with/files/for/importing2')
import thing1
import thing2