안태우 writes:
> Hello, all.I'm using pycuda for making simple project with pyQt5. But when I
> programed like this(in Windows 10, Python 3.6.2), app is aborted with
> printing bottom
> logs.---PyCUDA
> ERROR: The context stack was not empty upon module
> cleanup.---A
> context was still active when the context stack was beingcleaned up. At this
> point in our execution, CUDA may alreadyhave been deinitialized, so there is
> no way we can finishcleanly. The program will be aborted now.Use
> Context.pop() to avoid this
> problem.--My
> code is like this.Could you give me some help? main.pyimport sys
> from PyQt5 import uicfrom PyQt5.QtGui import *from PyQt5.QtWidgets
> import *from PyQt5.QtCore import *from PIL.ImageQt import ImageQt
> import fractalform_class = uic.loadUiType("main.ui")[0]class
> Form(QMainWindow, form_class):DRAW_MANDELBROT = 1def
> __init__(self):super().__init__()self.setupUi(self)
> self.setWindowFlags(Qt.MSWindowsFixedSizeDialogHint)
> self.setFixedSize(self.size())
> self.drawfractal(self.DRAW_MANDELBROT)def wheelEvent(self, event:
> QWheelEvent):pos = QWidget.mapFromGlobal(QCursor.pos()) // when
> this event happens, error occurs. print(pos)def
> drawfractal(self, sort):global imgif sort is
> self.DRAW_MANDELBROT:img = fractal.mandelbrot(-2, -2,
> self.size().width() * 2, 400) qimg =
> QPixmap.fromImage(ImageQt(img))qimg = qimg.scaled(self.size(),
> Qt.KeepAspectRatio, Qt.SmoothTransformation)
> self.label.setPixmap(qimg)if __name__ == "__main__":app =
> QApplication(sys.argv)w = Form()w.show()
> sys.exit(app.exec())fractal.pyimport pycuda.autoinitimport
> pycuda.driver as cudafrom pycuda.compiler import SourceModuleimport
> numpy as npimport matplotlib.cm as cmfrom matplotlib.colors import
> Normalizefrom PIL import Image...def mandelbrot(startx, starty,
> size, precision):matrix = np.array([startx, starty, size, precision],
> np.float32)result = np.empty((size, size), np.int32)
> matrix_gpu = cuda.mem_alloc(matrix.nbytes)result_gpu =
> cuda.mem_alloc(result.nbytes)cuda.memcpy_htod(matrix_gpu, matrix)
> func = cu.get_function("mandelbrot")func(matrix_gpu, result_gpu,
> block=(1, 1, 1), grid=(size, size))cuda.memcpy_dtoh(result,
> result_gpu)return array2imgarray(result, 'nipy_spectral') Thanks
Can you supply a stack trace of the crash? Could you confirm that
PyCUDA's atexit function runs?
Andreas
___
PyCUDA mailing list
PyCUDA@tiker.net
https://lists.tiker.net/listinfo/pycuda