๐ฌ Local LLM Deployment ToolsJune 15, 2026โ
Tests passing
LLM Package Optimizer
A CLI tool that analyzes and optimizes the Python packages and dependencies needed for local LLM deployment. It ensures that only the required libraries are installed and checks for hardware compatibility, reducing bloat and improving performance.
What It Does
- Analyze dependencies in a
requirements.txtfile or Python environment. - Automatically remove unused or redundant packages.
- Check hardware compatibility for GPU acceleration and recommend appropriate libraries.
- Generate an optimized
requirements.txtfile.
Installation
1. Clone the repository:
git clone https://github.com/your-repo/llm_package_optimizer.git
cd llm_package_optimizer2. Install the required dependencies:
pip install -r requirements.txtUsage
To use the LLM Package Optimizer, run the following command:
python llm_package_optimizer.py --input requirements.txt --output optimized_requirements.txt--input: Path to the inputrequirements.txtfile.--output: Path to save the optimizedrequirements.txtfile.
Example
Input requirements.txt:
torch
tensorflow
scipy
numpy
# Commented lineCommand:
python llm_package_optimizer.py --input requirements.txt --output optimized_requirements.txtOutput optimized_requirements.txt:
scipy
numpy
torch
tensorflow-gpuSource Code
import os
import argparse
import subprocess
import yaml
from rich.console import Console
from rich.table import Table
def parse_requirements(file_path):
"""Parse a requirements.txt file into a list of dependencies."""
if not os.path.exists(file_path):
raise FileNotFoundError(f"The file {file_path} does not exist.")
with open(file_path, 'r') as f:
lines = f.readlines()
dependencies = [line.strip() for line in lines if line.strip() and not line.startswith('#')]
return dependencies
def check_hardware_compatibility():
"""Check for GPU compatibility and return relevant libraries."""
try:
result = subprocess.run(['nvidia-smi'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if result.returncode == 0:
return ['torch', 'tensorflow-gpu']
else:
return ['torch-cpu', 'tensorflow']
except FileNotFoundError:
return ['torch-cpu', 'tensorflow']
def optimize_dependencies(dependencies):
"""Optimize dependencies by removing unused or redundant packages."""
optimized = []
for dep in dependencies:
if 'torch' in dep or 'tensorflow' in dep:
continue # Skip LLM-related packages for now
optimized.append(dep)
# Add hardware-compatible LLM packages
optimized.extend(check_hardware_compatibility())
return optimized
def write_requirements(dependencies, output_path):
"""Write the optimized dependencies to a new requirements file."""
with open(output_path, 'w') as f:
for dep in dependencies:
f.write(f"{dep}\n")
def main():
parser = argparse.ArgumentParser(description="LLM Package Optimizer")
parser.add_argument('--input', required=True, help="Path to the input requirements.txt file")
parser.add_argument('--output', required=True, help="Path to save the optimized requirements.txt file")
args = parser.parse_args()
console = Console()
try:
console.print("[bold green]Parsing requirements file...[/bold green]")
dependencies = parse_requirements(args.input)
console.print("[bold green]Optimizing dependencies...[/bold green]")
optimized_dependencies = optimize_dependencies(dependencies)
console.print("[bold green]Writing optimized requirements...[/bold green]")
write_requirements(optimized_dependencies, args.output)
console.print("[bold green]Optimization complete![/bold green]")
table = Table(title="Optimized Dependencies")
table.add_column("Dependency")
for dep in optimized_dependencies:
table.add_row(dep)
console.print(table)
except Exception as e:
console.print(f"[bold red]Error:[/bold red] {e}")
if __name__ == "__main__":
main()Community
Downloads
ยทยทยท
Rate this tool
No ratings yet โ be the first!
Details
- Tool Name
- llm_package_optimizer
- Category
- Local LLM Deployment Tools
- Generated
- June 15, 2026
- Tests
- Passing โ
Quick Install
Clone just this tool:
git clone --depth 1 --filter=blob:none --sparse \ https://github.com/ptulin/autoaiforge.git cd autoaiforge git sparse-checkout set generated_tools/2026-06-15/llm_package_optimizer cd generated_tools/2026-06-15/llm_package_optimizer pip install -r requirements.txt 2>/dev/null || true python llm_package_optimizer.py