使用Flas时出现PyCUDA上下文错误

2024-04-18 22:21:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用PyCUDA实现平滑的本地仿射,如here。当我在linux上运行这个程序时,它运行得很好。但当我试图在烧瓶上下文中导入它时:

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

出现以下错误:

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

然后我试图添加context.pop(),然后又发生了一个错误

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

有人知道如何在烧瓶环境下运行PyCuda吗?或者有没有其他方法可以让我在不使用PyCuda的情况下使用这种平滑的本地仿射特性?在


Tags: infromimportpycudaflask烧瓶linuxlocal