lemms commited on
Commit
5d375ac
Β·
verified Β·
1 Parent(s): e70ffa3

Add manual dependency installation script to fix sentencepiece import issues

Browse files
Files changed (1) hide show
  1. install_dependencies.py +109 -0
install_dependencies.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Manual dependency installation script for Hugging Face Spaces.
4
+
5
+ This script installs missing dependencies that might not be properly
6
+ installed through requirements.txt. Run this in the Space terminal.
7
+
8
+ Author: Louis Chua Bean Chong
9
+ License: GPL-3.0
10
+ """
11
+
12
+ import subprocess
13
+ import sys
14
+ import os
15
+
16
+ def run_command(command, description):
17
+ """
18
+ Run a shell command and handle errors.
19
+
20
+ Args:
21
+ command: Command to run
22
+ description: Description of what the command does
23
+ """
24
+ print(f"\nπŸ”§ {description}")
25
+ print(f"Running: {command}")
26
+
27
+ try:
28
+ result = subprocess.run(command, shell=True, capture_output=True, text=True)
29
+ if result.returncode == 0:
30
+ print(f"βœ… Success: {description}")
31
+ if result.stdout.strip():
32
+ print(f"Output: {result.stdout.strip()}")
33
+ else:
34
+ print(f"❌ Failed: {description}")
35
+ print(f"Error: {result.stderr.strip()}")
36
+ return False
37
+ except Exception as e:
38
+ print(f"❌ Exception: {e}")
39
+ return False
40
+
41
+ return True
42
+
43
+ def main():
44
+ """Install all required dependencies manually."""
45
+ print("πŸš€ Manual Dependency Installation for OpenLLM Training")
46
+ print("=" * 60)
47
+
48
+ # Check Python version
49
+ print(f"🐍 Python version: {sys.version}")
50
+ print(f"πŸ“ Working directory: {os.getcwd()}")
51
+
52
+ # Core dependencies that might be missing
53
+ dependencies = [
54
+ ("sentencepiece>=0.1.99", "SentencePiece tokenization library (CRITICAL for OpenLLM)"),
55
+ ("transformers>=4.30.0", "Hugging Face Transformers library"),
56
+ ("datasets>=2.12.0", "Hugging Face Datasets library"),
57
+ ("tokenizers>=0.13.0", "Fast tokenization library"),
58
+ ("huggingface_hub>=0.34.0", "Hugging Face Hub integration"),
59
+ ("accelerate>=0.20.0", "Distributed training acceleration"),
60
+ ("torch>=2.0.0", "PyTorch deep learning framework"),
61
+ ("gradio==4.44.1", "Gradio UI framework (fixed version)"),
62
+ ("numpy>=1.24.0", "Numerical computing library"),
63
+ ("pandas>=2.0.0", "Data manipulation library"),
64
+ ("tqdm>=4.65.0", "Progress bars"),
65
+ ("requests>=2.31.0", "HTTP library"),
66
+ ]
67
+
68
+ print(f"\nπŸ“¦ Installing {len(dependencies)} dependencies...")
69
+
70
+ success_count = 0
71
+ for package, description in dependencies:
72
+ command = f"pip install {package}"
73
+ if run_command(command, description):
74
+ success_count += 1
75
+
76
+ print(f"\n" + "=" * 60)
77
+ print(f"🎯 Installation Summary:")
78
+ print(f"βœ… Successful: {success_count}/{len(dependencies)}")
79
+ print(f"❌ Failed: {len(dependencies) - success_count}/{len(dependencies)}")
80
+
81
+ if success_count == len(dependencies):
82
+ print("\nπŸŽ‰ All dependencies installed successfully!")
83
+ print("πŸ’‘ You can now try the training again.")
84
+ else:
85
+ print("\n⚠️ Some dependencies failed to install.")
86
+ print("πŸ’‘ Check the error messages above and try again.")
87
+
88
+ # Test critical imports
89
+ print(f"\nπŸ§ͺ Testing critical imports...")
90
+ test_imports = [
91
+ ("sentencepiece", "SentencePiece (CRITICAL)"),
92
+ ("transformers", "Transformers"),
93
+ ("datasets", "Datasets"),
94
+ ("torch", "PyTorch"),
95
+ ("gradio", "Gradio"),
96
+ ]
97
+
98
+ for module, name in test_imports:
99
+ try:
100
+ __import__(module)
101
+ print(f"βœ… {name} - Import successful")
102
+ except ImportError as e:
103
+ print(f"❌ {name} - Import failed: {e}")
104
+
105
+ print(f"\nπŸ”§ Manual installation complete!")
106
+ print("πŸ’‘ If imports still fail, try restarting the Space.")
107
+
108
+ if __name__ == "__main__":
109
+ main()