RuntimeError: CUDA has been initialized before importing the `spaces` package

#91
by MultiTrickFox - opened
ZeroGPU Explorers org

Hello, In multiple spaces I am getting the following error:

This is an example from levihsu/OOTDiffusion, but I'm getting the same exact error in multiple other spaces with entirely different projects too.
The original space seems to be running on zero gpu with no problem in all cases, so why...

  File "/home/user/app/./run/gradio_ootd.py", line 39, in <module>
    import spaces
  File "/usr/local/lib/python3.10/site-packages/spaces/__init__.py", line 19, in <module>
    from .zero.decorator import GPU
  File "/usr/local/lib/python3.10/site-packages/spaces/zero/__init__.py", line 15, in <module>
    raise RuntimeError(
RuntimeError: CUDA has been initialized before importing the `spaces` package
ZeroGPU Explorers org

Ok I figured out a solution: Import the "spaces" right at the top of the code

MultiTrickFox changed discussion status to closed

Sign up or log in to comment