Apply for community grant: Academic project (gpu)

#1
by Yw22 - opened
ARC Lab, Tencent PCG org

We release Image Conductor: Precision Control for Interactive Video Synthesis, which allows precise management of camera transitions and object movements in image-to-video.
Paper: https://arxiv.org/pdf/2406.15339
Github: https://github.com/liyaowei-stu/ImageConductor
Project Page: https://liyaowei-stu.github.io/project/ImageConductor/

Hi @Yw22 , we've assigned ZeroGPU to this Space. Please check the compatibility and usage sections of this page so your Space can run on ZeroGPU.

ARC Lab, Tencent PCG org

Dear HF team:
I am writing to request an upgrade of my Huggingface Space from ZeroGPU to A10. The reason for this request is as follows:

  1. When using gr.Examples with the gr.state parameter, the examples do not display correctly.
  2. I attempted to switch to Gradio version 3.50.0 and set a label for gr.state, which allowed the examples to display. However, using the examples resulted in an error.

These issues do not occur when running the application locally. Additionally, I consulted with a friend who encountered the same problem and resolved it by upgrading from ZeroGPU to A10.
Given these circumstances, I kindly request that my Huggingface Space be upgraded to A10 to ensure smooth functionality.

ARC Lab, Tencent PCG org

File "/usr/local/lib/python3.10/site-packages/spaces/zero/client.py", line 56, in schedule raise RuntimeError("ZeroGPU is only compatible with Gradio 4+") RuntimeError: ZeroGPU is only compatible with Gradio 4+
I'm having this problem, but when I switch to a higher version of gradio I can't specify the gr.State's label, e.g. gr.State(value=None,label="Input")
The same bugs are encountered in BrushNet .(https://huggingface.co/spaces/TencentARC/BrushNet) This problem was solved by replacing the zeroGPU with an A10.

@hysts

@Yw22 As we are using ZeroGPU as the default hardware for grants, it would be nice if you could adapt your code to it. Also, it's not recommended to use old versions of gradio.
Regarding the BrushNet Space, it's true that using the old gradio fixed the issue, but we assigned A10G temporarily until the author update the code to use ZeroGPU. Looks like it's about 3 months ago, though.
It would be nice if we could revisit and resolve the issue.

ARC Lab, Tencent PCG org

@hysts We have discovered that in gradio==4.37.2, although the State class inherits from Component, it is unable to integrate the label attribute through super().init() due to the absence of the **args parameter.

image.png

image.png

ARC Lab, Tencent PCG org
edited Jul 10

In version 3.50.0, however, the instantiation method of the State class includes the **args parameter, allowing it to inherit other attributes from the Component class. Should this bug be fixed?

image.png

ARC Lab, Tencent PCG org
edited Jul 10

I switched gradio to the latest version 4.37.2. Everything is normal locally, but it appears as soon as it runs in space. Could you provide some solutions? @hysts

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/spaces/utils.py", line 42, in put
super().put(obj)
File "/usr/local/lib/python3.10/multiprocessing/queues.py", line 371, in put
obj = _ForkingPickler.dumps(obj)
File "/usr/local/lib/python3.10/multiprocessing/reduction.py", line 51, in dumps
cls(buf, protocol).dump(obj)
AttributeError: Can't pickle local object 'State.init..'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/gradio/queueing.py", line 541, in process_events
response = await route_utils.call_process_api(
File "/usr/local/lib/python3.10/site-packages/gradio/route_utils.py", line 276, in call_process_api
output = await app.get_blocks().process_api(
File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 1928, in process_api
result = await self.call_function(
File "/usr/local/lib/python3.10/site-packages/gradio/blocks.py", line 1514, in call_function
prediction = await anyio.to_thread.run_sync(
File "/usr/local/lib/python3.10/site-packages/anyio/to_thread.py", line 56, in run_sync
return await get_async_backend().run_sync_in_worker_thread(
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 2177, in run_sync_in_worker_thread
return await future
File "/usr/local/lib/python3.10/site-packages/anyio/_backends/_asyncio.py", line 859, in run
result = context.run(func, *args)
File "/usr/local/lib/python3.10/site-packages/gradio/utils.py", line 833, in wrapper
response = f(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/spaces/zero/wrappers.py", line 162, in gradio_handler
worker.arg_queue.put(((args, kwargs), GradioPartialContext.get()))
File "/usr/local/lib/python3.10/site-packages/spaces/utils.py", line 50, in put
raise PicklingError(message)
_pickle.PicklingError: Can't pickle local object 'State.init..'

Thanks for checking! I'll look into it.

ARC Lab, Tencent PCG org
edited Jul 11
  1. When I use version 4.37.2, I get an error due to a lambda expression in gradio.components.state.py -> def State.

AttributeError: Can't pickle local object 'State.__init__ . <locals>.<lambda>

  1. And when I switched gradio to 4.7.0, I get an error due to a local function in gradio.helpers.py -> load_example

_pickle.PicklingError: Can't pickle local object 'Examples.create.<locals>.load_example'

I think it's a problem of incompatibility between zeroGPU and some components of gradio, because I don't have this problem locally no matter what version of gradio I use.
Could you help me to fix it, thanks. @hysts @akhaliq

@Yw22 Sorry for the late reply, but I just opened a PR that fixes this issue.

ARC Lab, Tencent PCG org

@hysts I am genuinely grateful for the time and effort you have invested in helping me. Your expertise and prompt response were invaluable and greatly appreciated.
Thank you for your support and dedication, and I look forward to any future opportunities to collaborate.

Btw, I speculate the issue was caused by the following reasons:

  1. Incorrect usage of gr.State (redefining it multiple times within a function).
  2. Incorrect usage of gr.Examples (loading some Gradio components within a function decorated with @spaces.GPU).

Thanks for your super nice feedback! We are always happy to help and look forward to future collabs. 🤗

Btw, I speculate the issue was caused by the following reasons:

  1. Incorrect usage of gr.State (redefining it multiple times within a function).
  2. Incorrect usage of gr.Examples (loading some Gradio components within a function decorated with @spaces.GPU).

You are right about the first point. gr.State wraps whatever it's passed, but you can treat it as its content inside functions. (Not sure, but it seemed that gr.State wrapped another gr.State object in your original code as you passed a gr.State object to gr.State as its value.)
As for the second point, I think two things are involved.

  • ZeroGPU runs GPU process in a separate process, so arguments and return values are pickled and passed, but gr.State cannot be pickled. On a normal GPU instance, this pickle doesn't happen, so your original code worked fine in your local environment (The @spaces.GPU decorator does nothing on a normal GPU). But to run it on ZeroGPU, the return value of the function decorated with @spaces.GPU needed to be changed to raw values instead of dict with gr.State to avoid this pickle error.
  • Regarding gr.Examples, as you mentioned earlier, it doesn't seem to be possible to load gr.State from gr.Examples, and I adapted your code to this and this as a workaround. But I found it hard to come up with this workaround, and I think it would be nice if gradio could support this kind of use case somehow. Not sure if there's an easy way or if it's possible, but I'll discuss this internally.
ARC Lab, Tencent PCG org

I see 🤗. Thank you so much for your detailed explanation and for helping me resolve the issues. If there is anything I can assist with in the future, please don't hesitate to contact me.

Sign up or log in to comment