PyCUDA context error when using Flask

有些话、适合烂在心里 提交于 2019-12-12 13:16:45

问题


I am using the PyCUDA to implement the smooth_local_affine as shown here. It works well when I simply run the program on linux. But when I tried to import it under Flask context:

from smooth_local_affine import smooth_local_affine
from flask import Flask
app = Flask(_name_)
...

The following error occurs:

-------------------------------------------------------------------  
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.

Then I tried to add context.pop(),then another error occurs;

Error in atexit._run_exitfuncs: Traceback (most recent call last):
File "/home/yifang/anaconda3/envs/python3/lib/python3.6/site-packages/pycuda-2017.1-py3.6-linux-x86_64.egg/pycuda/autoinit.py", line 14, in _finish_up context.pop() pycuda._driver.LogicError: context::pop failed: invalid device context - cannot pop non-current context

Anyone knows how to run PyCuda in Flask environment? Or maybe any alternative ways that I can use this smooth_local_affine feature without using PyCuda?

来源:https://stackoverflow.com/questions/49595175/pycuda-context-error-when-using-flask

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!