我构建了一个Python包,以便我可以执行相对导入,如:
from ..utils import gen_utils
这
package_name/gpu_code/script_using_theano.py
如果我的文件结构如下:
package_name/
--utils/
----gen_utils.py
--gpu_code/
----script_using_theano.py
但是,当我运行python -m package_name.gpu_code.script_using_theano
时,我收到以下错误:
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 package_name/gpu_code/script_using_theano.py
我可以在这种情况下使用GPU。我想知道是否有一些Theano配置设置通过运行python作为模块而开始改变?
答案 0 :(得分:1)
你是如何从顶级文件目录之外导入文件的?如果您不使用
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
我建议您这样做。