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.py import sys from
PyQt5 import uic from PyQt5.QtGui import * from PyQt5.QtWidgets import *
from PyQt5.QtCore import * from PIL.ImageQt import ImageQt import
fractal form_class = uic.loadUiType("main.ui")[0] class
Form(QMainWindow, form_class): DRAW_MANDELBROT = 1 def
__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 img if 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.py import pycuda.autoinit
import pycuda.driver as cuda from pycuda.compiler import SourceModule
import numpy as np import matplotlib.cm as cm from matplotlib.colors
import Normalize from 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 _______________________________________________
PyCUDA mailing list
[email protected]
https://lists.tiker.net/listinfo/pycuda