-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Use "hub" directory for cache instead of "diffusers" #2005
Conversation
The documentation is not available anymore as the PR was closed or merged. |
Hi @pcuenca , thanks for making the change :) About your questions, I see 2 things here:
Good question. There shouldn't be conflicts in the
Easiest solution for that would be to delete the previous folder but that would cause issues for users that have both an old and a new version of |
I verified that the constants are available in huggingface_hub version 0.10.0, which is the minimum we require. Co-authored-by: Lucain Pouget <lucainp@gmail.com>
For information, the whole logic to migrate to the new cache in Transformers is here. |
@pcuenca, it would be nice to automatically migrate the cache just like we do in |
Yes, I'll use @sgugger's logic. Thanks a lot for the pointer! |
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread. Please note that issues that do not follow the contributing guidelines are likely to be ignored. |
Wait, this was never merged? Well that explains some things. |
yeah i think we do want this merged |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplifications with respect to the migration process in transformers:
- Moving the whole cache folder (https://github.com/huggingface/transformers/blob/9ddf4f4f03608095224cd3354b62c6f7d0d4b009/src/transformers/utils/hub.py#L83-L98) is probably not going to happen as the new cache path will already exist, because diffusers uses transformers models that have possibly been migrated. That shortcut has been removed here.
- The migration process consists of simply moving the model folders, as shown below. We don't need an update of the structure as far as I can tell.
One question I have, if we want to be extremely cautious, is whether to ignore the migration until the new version has been released (i.e., don't do anything when installing from |
...or multiple venvs with different versions. can you mitigate this by leaving symlinks at the old location to point to the new one? |
Co-authored-by: Lucain <lucainp@gmail.com>
Especially important if we want to ensure that the user may want to invoke the process again later, if they are keeping multiple envs with different versions.
Good idea. Note, however, that the migration process will only run once automatically. If you keep multiple versions, then you'll need to invoke |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR looks good to me, thanks for the changes 👍
Maybe another pair of eyes would be good before finally merging.
"The cache for model files in Diffusers v0.14.0 has moved to a new location. Moving your " | ||
"existing cached models. This is a one-time operation, you can interrupt it or run it " | ||
"later by calling `diffusers.utils.hub_utils.move_cache()`." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a need to also spit out the actual location in this message for ultra transparency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, perhaps we can include that too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool - thanks !
Only the |
@carson-katri Yes it's normal. The Hope this clarifies everything :) |
@Wauplin Got it, thanks. My issue was I was reading the cache to see what models the user has available. But I think I should read the old cache and new cache now until those folders are recreated. |
@carson-katri yes exactly. Also worth mentioning we have a scan-cache cli to list which models you have in your cache. huggingface-cli scan-cache
# or
# huggingface-cli scan-cache --dir=path/to/cache Disclaimer: I'm not really sure it will work on the old cache has the tool is not expecting symlinks in the blobs folder. |
…accelerate 0.16 (#2865) Things to check for in this version: - `diffusers` cache location is now more consistent with other huggingface-hub using code (i.e. `transformers`) as of huggingface/diffusers#2005. I think ultimately this should make @damian0815 (and other folks with multiple diffusers-using projects) happier, but it's worth taking a look to make sure the way @lstein set things up to respect `HF_HOME` is still functioning as intended. - I've gone ahead and updated `transformers` to the current version (4.26), but I have a vague memory that we were holding it back at some point? Need to look that up and see if that's the case and why.
* Use "hub" directory for cache instead of "diffusers" * Import cache locations from huggingface_hub I verified that the constants are available in huggingface_hub version 0.10.0, which is the minimum we require. Co-authored-by: Lucain Pouget <lucainp@gmail.com> * make style * Move cached directories to new location. * make style * Apply suggestions by @Wauplin Co-authored-by: Lucain <lucainp@gmail.com> * Fix is_file * Ignore symlinks. Especially important if we want to ensure that the user may want to invoke the process again later, if they are keeping multiple envs with different versions. * Style --------- Co-authored-by: Lucain Pouget <lucainp@gmail.com>
* Use "hub" directory for cache instead of "diffusers" * Import cache locations from huggingface_hub I verified that the constants are available in huggingface_hub version 0.10.0, which is the minimum we require. Co-authored-by: Lucain Pouget <lucainp@gmail.com> * make style * Move cached directories to new location. * make style * Apply suggestions by @Wauplin Co-authored-by: Lucain <lucainp@gmail.com> * Fix is_file * Ignore symlinks. Especially important if we want to ensure that the user may want to invoke the process again later, if they are keeping multiple envs with different versions. * Style --------- Co-authored-by: Lucain Pouget <lucainp@gmail.com>
* Use "hub" directory for cache instead of "diffusers" * Import cache locations from huggingface_hub I verified that the constants are available in huggingface_hub version 0.10.0, which is the minimum we require. Co-authored-by: Lucain Pouget <lucainp@gmail.com> * make style * Move cached directories to new location. * make style * Apply suggestions by @Wauplin Co-authored-by: Lucain <lucainp@gmail.com> * Fix is_file * Ignore symlinks. Especially important if we want to ensure that the user may want to invoke the process again later, if they are keeping multiple envs with different versions. * Style --------- Co-authored-by: Lucain Pouget <lucainp@gmail.com>
Fixes #1663.
So far I've only changed the cache location. I think maybe we should migrate the existing cached files (so far living in
diffusers
) upon first launch. If so, how could we go about it? I remember there was a migration process inhuggingface_hub
when the cache layout was updated, so perhaps @Wauplin can recommend a sensible approach here? My initial idea would be to:diffusers
.hub
. What happens if there's a directory conflict?