Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mjun0812/hf-model-cleanup-experiment
🧪 Hugging Face のモデルをCPU/RAMから解放する方法を検証するリポジトリ | A verification repository for unloading Hugging Face models from CPU/RAM memory
https://github.com/mjun0812/hf-model-cleanup-experiment
Last synced: 1 day ago
JSON representation
🧪 Hugging Face のモデルをCPU/RAMから解放する方法を検証するリポジトリ | A verification repository for unloading Hugging Face models from CPU/RAM memory
- Host: GitHub
- URL: https://github.com/mjun0812/hf-model-cleanup-experiment
- Owner: mjun0812
- Created: 2025-01-11T08:42:53.000Z (7 days ago)
- Default Branch: main
- Last Pushed: 2025-01-11T09:39:35.000Z (7 days ago)
- Last Synced: 2025-01-11T10:33:32.129Z (7 days ago)
- Language: Python
- Size: 2.55 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# HuggingFace Model Memory Cleanup Experiment
HuggingFaceのモデルをメモリから解放する方法の調査。
```bash
docker build -t memory-profiler .
docker run -it --rm -v $(pwd):/app memory-profiler python /app/1.py
```## 1. `del model; gc.collect();`で削除
![1](figs/2048m/memory_usage_1.png)
## 2. モデルのパラメータを手動で削除 + `del model; gc.collect();`
![2](figs/2048m/memory_usage_2.png)
## 3. `del model; gc.collect();` + `ctypes.CDLL("libc.so.6")`で削除
![3](figs/2048m/memory_usage_3.png)
## 4. モデルのパラメータを手動で削除 + `del model; gc.collect();` + `ctypes.CDLL("libc.so.6")`で削除
![4](figs/2048m/memory_usage_4.png)
## All
![all](figs/2048m/memory_usage_all.png)