google / google/flax

Problem while using checkpoints.restore_checkpoint with gradio

Open
#3,860 1 comment 0 reactions 0 assignees View on GitHub
Priority: P2 - no schedule
Dominant language
Jupyter Notebook
Stars
7.3k
Forks
833
Avg merge
5h 11m
Merged PRs (30d)
5

Description

Provide as much information as possible. At least, this should include a description of your issue and steps to reproduce the problem. If possible also provide a summary of what steps or workarounds you have already tried.

### System information
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04):
- Flax, jax, jaxlib versions (obtain with `pip show flax jax jaxlib`:
- Python version:
- GPU/TPU model and memory:
- CUDA version (if applicable):

### Problem you have encountered:

Throws exception when using **flax.training.checkpoints.restore_checkpoint** within a module wrapped with using gradio. After some sanity checks and from the logs, I feel that this happens because of the use of parallelization within .restore_checkpoint that is not supported by gradio.

### Logs, error messages, etc:

Screenshot 2024-04-16 at 2 38 40 PM

### Steps to reproduce:

```
T5_PRETRAINED_PATH="path_to_the_weight"
PARAM_DTYPE=jnp.float32
PARAMS_LANG = checkpoints.restore_checkpoint(T5_PRETRAINED_PATH, target=None,parallel=False)
PARAMS_LANG=jax.tree_map(lambda x:x.astype(PARAM_DTYPE),PARAMS_LANG)

with gr.Blocks() as demo:

with gr.Column():
input_file_obj = gr.File(label="File upload")
Num_of_samples=gr.Text(label="Number of samples",value=100)
submit_button = gr.Button("Generate")
input_load=[input_file_obj,Num_of_samples]
with gr.Column():
file_out_obj = gr.File(label="Output File")
submit_button.click(pass_through_func,
inputs=input_load,
outputs=file_out_obj)
demo.launch()

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.