2015-10-04 97 views
2

我建了一個Python包使用GPU,這樣我可以做相對進口,如:Theano無法運行時的Python作爲模塊(蟒蛇-m)

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作爲模塊來改變?

回答

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 

我建議你這樣做。

+0

一切都比較導入?我不確定你是什麼意思。無論如何,問題不在於能夠導入任何東西,只是Python在作爲模塊運行時訪問GPU。 – bschreck

+0

好吧,我明白你的意思了。 Theano需要導入一個相對於我的主目錄的路徑才能看到它的配置文件。由於我作爲模塊運行,主目錄不再處於Python的路徑中,所以我需要明確地添加它。這工作 – bschreck