Closed
Description
Problem Description
When running in WSL environment, ComfyUI-3D-Pack fails to load with the following error:
RuntimeError: Cuda error: 304[cudaGraphicsGLRegisterBuffer(&s.cudaPosBuffer, s.glPosBuffer, cudaGraphicsRegisterFlagsWriteDiscard);]
Root Cause
The issue stems from an inconsistency in how the rasterizer is selected:
- The
multiview_color_projection_texture()
function offers aforce_cuda_rast
parameter that allows choosing between OpenGL and CUDA rasterizers - However, the
Pix2FacesRenderer
class inproject_mesh.py
always initializes withRasterizeGLContext
during module loading - This initial OpenGL-based renderer creation fails in WSL2 due to OpenGL-CUDA interoperability limitations (like Unable to load under WSL 2 in Win10 due to: RuntimeError: Cuda error: 304[cudaGraphicsGLRegisterBuffer(&s.cudaPosBuffer, s.glPosBuffer, cudaGraphicsRegisterFlagsWriteDiscard);] #425)
Proposed Fix
The solution is to make the CUDA rasterizer option consistent throughout the codebase:
class Pix2FacesRenderer:
def __init__(self, device="cuda"):
try:
self._glctx = dr.RasterizeGLContext(output_db=False, device=device)
except Exception:
self._glctx = dr.RasterizeCudaContext()
self.device = device
_warmup(self._glctx, device)
I've verified that this approach works by manually modifying the code. However, I would appreciate any feedback on this fix before submitting a PR.
I would also be happy to submit a PR with this fix if it looks good.
Metadata
Metadata
Assignees
Labels
No labels