-1

I'm trying to run multiple threads on GPUs using the Pycuda example MultipleThreads. When I run my python file, I get the following error message:

(/root/anaconda3/) root@109c7b117fd7:~/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

I have tried to change the way I import threading from import threading to from threading import Thread, but the error still persists. Could anyone be able to see what is the problem that I'm encountering?

Zhangsheng
  • 85
  • 2
  • 11
  • Line numbers in the error messages seem to be 3 lines earlier than what is in the linked example. While it may be innocent and indicate that you just removed some of the empty/comment lines from the beginning, it still brings up the question: "What other differences could be there?" – tevemadar Aug 08 '17 at 00:22
  • Thanks for the pointer! I solved my problem. The number of lines weren't the issue. The problem was with my import commands for pycuda which I only spotted it when I compared my code and the one in the example side by side. – Zhangsheng Aug 08 '17 at 01:31

1 Answers1

0

Problem has been solved. Just a minor error in the import command.

Instead of:

from pycuda.compiler import SourceModule

I mistakenly wrote:

import pycuda.compiler as SourceModule

It was a bad mistake.

Zhangsheng
  • 85
  • 2
  • 11