How to use the cache_dir along with optimum-cli export

Dear team,

I’m getting the annoying max number of requests message. I’m part of a organization. Thus, I have no time to investigate that.

I just need to reuse weights that I downloaded last week. Can someone help me to do so?

  • The CLI program takes a cache_dir. Yet, the model insists on downloading Why!
  • Is that a bug?
  • BTW, there is a variable call local_files_only in the function main_export not exposed to the users.
  • Smell like bug

KIndly provide hints. Happy to submit PR!


@fxmarty Kindly consider reading my question & lemme know if I should file a issue in GH Bug :bug: or FR :rocket:

For anyone interested you can reproduce the issue as follows:

optimum-cli export onnx --model t5-base checkpoints/t5-base_onnx/ --framework pt --optimize O3 --batch_size 1 --sequence_length 512 --atol 0.0001 --cache_dir ~/.cache/huggingface/hub

Ask task='auto' (default), the code gets stuck here sending a request to HF servers to infer something from catalog. IMHO, a patch is needed.

cc @michaelbenayoun

If anyone is facing the issue, the workaround is to specify the task.

Perhaps, you downloaded the model & it’s in the cache_dir of HF (e.g., ~/.cache/huggingface/hub in Linux). If so, just use one of the supported tasks here

1 Like

Hi @escorciav , thank you for the report. Could you try on the main branch if you still encounter the issue? Should be fixed with Improve the offline support for the ONNX/TFLite export by fxmarty · Pull Request #1109 · huggingface/optimum · GitHub


Tried that out and report my findings in Github. Thanks for the fix!