2017-08-07 36 views
0

私はGPUで複数のスレッドを実行しようとしていますが、Pycudaの例MultipleThreadsを使用しています。私はPythonのファイルを実行すると、私は次のようなエラーメッセージが出ます:Pycuda複数スレッドの使用

(/root/anaconda3/) [email protected]:~/pycuda# python multiplethreads.py 
Exception in thread Thread-5: 
Traceback (most recent call last): 
    File "/root/anaconda3/lib/python3.6/threading.py", line 916, in _bootstrap_inner 
    self.run() 
    File "multiplethreads.py", line 22, in run 
    test_kernel(self.array_gpu) 
    File "multiplethreads.py", line 36, in test_kernel 
    """) 
TypeError: 'module' object is not callable 

------------------------------------------------------------------- 
PyCUDA ERROR: The context stack was not empty upon module cleanup. 
------------------------------------------------------------------- 
A context was still active when the context stack was being 
cleaned up. At this point in our execution, CUDA may already 
have been deinitialized, so there is no way we can finish 
cleanly. The program will be aborted now. 
Use Context.pop() to avoid this problem. 
------------------------------------------------------------------- 
Exception in thread Thread-6: 
Traceback (most recent call last): 
    File "/root/anaconda3/lib/python3.6/threading.py", line 916, in _bootstrap_inner 
    self.run() 
    File "multiplethreads.py", line 22, in run 
    test_kernel(self.array_gpu) 
    File "multiplethreads.py", line 36, in test_kernel 
    """) 
TypeError: 'module' object is not callable 
Aborted 

を私はfrom threading import Threadimport threadingからthreadingをインポートする方法を変更しようとしましたが、エラーが解消されません。誰が私が遭遇している問題が何かを見ることができるだろうか?

+0

エラーメッセージの行番号は、リンクされた例の行番号よりも3行早いと思われます。それは無実かもしれませんが、最初から空白行/コメント行の一部を削除しただけであることを示していますが、それでもなお他の違いはありますか? – tevemadar

+0

ポインタありがとう!私は私の問題を解決しました。ラインの数は問題ではなかった。問題はPycuda用のインポートコマンドを使用したときに私がコードを比較したときに見つけただけであり、例のコードを並べて比較した場合です。 – Zhangsheng

答えて

0

問題は解決されました。 importコマンドの小さなエラーです。

の代わりに:

from pycuda.compiler import SourceModule 

私が間違って書いた:

import pycuda.compiler as SourceModule 

それは悪い間違いでした。

関連する問題