text
Do you have a hidden massive storage leak thanks to HF hub models and datasets revisions adding up and not getting automatically deleted?
Do you have a hidden massive storage leak thanks to HF hub models and datasets revisions adding up and not getting automatically deleted?
new_line
new_line
text
Here is how to delete all old revisions and only keeping 
Here is how to delete all old revisions and only keeping 
inline_code
`main`
main
text
 in a few quick steps and no tedious manual editing.
 in a few quick steps and no tedious manual editing.
new_line
new_line
text
In terminal A:
In terminal A:
new_line
code_fence
```
$ pip install huggingface_hub["cli"] -U
$ huggingface-cli delete-cache --disable-tui
File to edit: /tmp/tmpundr7lky.txt
0 revisions selected counting for 0.0. Continue ? (y/N)
```
$ pip install huggingface_hub["cli"] -U
$ huggingface-cli delete-cache --disable-tui
File to edit: /tmp/tmpundr7lky.txt
0 revisions selected counting for 0.0. Continue ? (y/N)
new_line
text
Do not answer the prompt and proceed with my instructions.
Do not answer the prompt and proceed with my instructions.
new_line
new_line
text
(note your tmp file will have a different path, so adjust it below)
(note your tmp file will have a different path, so adjust it below)
new_line
new_line
text
In terminal B:
In terminal B:
new_line
code_fence
```
$ cp /tmp/tmpedbz00ox.txt cache.txt
$ perl -pi -e 's|^#(.*detached.*)|$1|' cache.txt
$ cat cache.txt >>  /tmp/tmpundr7lky.txt
```
$ cp /tmp/tmpedbz00ox.txt cache.txt
$ perl -pi -e 's|^#(.*detached.*)|$1|' cache.txt
$ cat cache.txt >>  /tmp/tmpundr7lky.txt
new_line
text
The perl one-liner uncommented out all lines that had 
The perl one-liner uncommented out all lines that had 
inline_code
`(detached)`
(detached)
text
 in it - so can be wiped out. And then we pasted it back into the tmp file 
 in it - so can be wiped out. And then we pasted it back into the tmp file 
inline_code
`huggingface-cli`
huggingface-cli
text
 expects to be edited.
 expects to be edited.
new_line
new_line
text
Now go back to terminal A and hit: N, Y, Y, so it looks like:
Now go back to terminal A and hit: N, Y, Y, so it looks like:
new_line
new_line
code_fence
```
0 revisions selected counting for 0.0. Continue ? (y/N) n
89 revisions selected counting for 211.7G. Continue ? (y/N) y
89 revisions selected counting for 211.7G. Confirm deletion ? (Y/n) y
```
0 revisions selected counting for 0.0. Continue ? (y/N) n
89 revisions selected counting for 211.7G. Continue ? (y/N) y
89 revisions selected counting for 211.7G. Confirm deletion ? (Y/n) y
new_line
text
Done.
Done.
new_line
new_line
text
If you messed up with the prompt answering you still have 
If you messed up with the prompt answering you still have 
inline_code
`cache.txt`
cache.txt
text
 file which you can feed again to the new tmp file it'll create when you run 
 file which you can feed again to the new tmp file it'll create when you run 
inline_code
`huggingface-cli delete-cache --disable-tui`
huggingface-cli delete-cache --disable-tui
text
 again.
 again.
new_line
new_line
text
For more details and additional techniques please see 
For more details and additional techniques please see 
link
https://github.com/stas00/ml-engineering/tree/master/storage#huggingface-hub-caches
https://github.com/stas00/ml-engineering/tree/master/storage#huggingface-hub-caches
Do you have a hidden massive storage leak thanks to HF hub models and datasets revisions adding up and not getting automatically deleted?

Here is how to delete all old revisions and only keeping `main` in a few quick steps and no tedious manual editing.

In terminal A:
```
$ pip install huggingface_hub["cli"] -U
$ huggingface-cli delete-cache --disable-tui
File to edit: /tmp/tmpundr7lky.txt
0 revisions selected counting for 0.0. Continue ? (y/N)
```
Do not answer the prompt and proceed with my instructions.

(note your tmp file will have a different path, so adjust it below)

In terminal B:
```
$ cp /tmp/tmpedbz00ox.txt cache.txt
$ perl -pi -e 's|^#(.*detached.*)|$1|' cache.txt
$ cat cache.txt >>  /tmp/tmpundr7lky.txt
```
The perl one-liner uncommented out all lines that had `(detached)` in it - so can be wiped out. And then we pasted it back into the tmp file `huggingface-cli` expects to be edited.

Now go back to terminal A and hit: N, Y, Y, so it looks like:

```
0 revisions selected counting for 0.0. Continue ? (y/N) n
89 revisions selected counting for 211.7G. Continue ? (y/N) y
89 revisions selected counting for 211.7G. Confirm deletion ? (Y/n) y
```
Done.

If you messed up with the prompt answering you still have `cache.txt` file which you can feed again to the new tmp file it'll create when you run `huggingface-cli delete-cache --disable-tui` again.

For more details and additional techniques please see https://github.com/stas00/ml-engineering/tree/master/storage#huggingface-hub-caches
❤️
vicgalle cahlen osanseviero not-lain samusenps clem victor Wauplin afrideva sethuiyer sbrandeis
👍
neph1