|
1 | 1 | """ |
2 | | -XERV CRAYON V4.2.9 - Production Omni-Backend Tokenizer |
| 2 | +XERV CRAYON V4.3.0 - Production Omni-Backend Tokenizer |
3 | 3 | ======================================================= |
4 | 4 | Copy this ENTIRE script into a Google Colab cell and run it. |
5 | 5 |
|
|
13 | 13 | import time |
14 | 14 |
|
15 | 15 | print("=" * 70) |
16 | | -print("XERV CRAYON V4.2.9 INSTALLATION") |
| 16 | +print("XERV CRAYON V4.3.0 INSTALLATION") |
17 | 17 | print("=" * 70) |
18 | 18 |
|
19 | | -# ... (rest of the script is same until Verification) |
| 19 | +# 1. Environment Check |
| 20 | +print("[1/7] Checking environment...") |
| 21 | +try: |
| 22 | + import torch |
| 23 | + print(f" PyTorch: {torch.__version__}") |
| 24 | + if torch.cuda.is_available(): |
| 25 | + print(f" CUDA: {torch.version.cuda} ({torch.cuda.get_device_name(0)})") |
| 26 | + print(" * Smart Build: Will compile ONLY for this GPU architecture") |
| 27 | + else: |
| 28 | + print(" CUDA: Not available (CPU only)") |
| 29 | +except ImportError: |
| 30 | + print(" PyTorch not found (will be installed)") |
| 31 | + |
| 32 | +nvcc_check = subprocess.run(["which", "nvcc"], capture_output=True, text=True) |
| 33 | +if nvcc_check.returncode == 0: |
| 34 | + print(f" NVCC: {nvcc_check.stdout.strip()}") |
| 35 | +else: |
| 36 | + print(" NVCC: Not found") |
| 37 | + |
| 38 | + |
| 39 | +# 2. Build Dependencies |
| 40 | +print("\n[2/7] Installing build dependencies...") |
| 41 | +subprocess.check_call([sys.executable, "-m", "pip", "install", "-q", "ninja", "packaging", "wheel", "setuptools>=68.0"]) |
| 42 | +print(" Done (ninja, packaging, wheel)") |
| 43 | + |
| 44 | + |
| 45 | +# 3. Clean Old State |
| 46 | +print("\n[3/7] Cleaning previous installations...") |
| 47 | +os.system("pip uninstall -y xerv-crayon crayon 2>/dev/null") |
| 48 | +os.system("rm -rf /tmp/crayon* build dist src/*.egg-info 2>/dev/null") |
| 49 | + |
| 50 | + |
| 51 | +# 4. Clone Source |
| 52 | +print("\n[4/7] Cloning source code...") |
| 53 | +timestamp = int(time.time()) |
| 54 | +clone_dir = f"/tmp/crayon_{timestamp}" |
| 55 | +cmd = f"git clone --depth 1 https://github.com/Electroiscoding/CRAYON.git {clone_dir}" |
| 56 | +if os.system(cmd) != 0: |
| 57 | + print(" FATAL: Git clone failed!") |
| 58 | + sys.exit(1) |
| 59 | + |
| 60 | +# Verify source |
| 61 | +v_check = subprocess.run(["grep", "-m1", "__version__", f"{clone_dir}/src/crayon/__init__.py"], |
| 62 | + capture_output=True, text=True) |
| 63 | +print(f" {v_check.stdout.strip()}") |
| 64 | + |
| 65 | + |
| 66 | +# 5. Build & Install (Streaming Output) |
| 67 | +print("\n[5/7] Compiling and Installing (Streaming Logs)...") |
| 68 | +print("-" * 70) |
| 69 | + |
| 70 | +build_env = os.environ.copy() |
| 71 | +build_env["MAX_JOBS"] = "1" # Force serial build to prevent OOM |
| 72 | +build_env["CUDA_HOME"] = "/usr/local/cuda" |
| 73 | + |
| 74 | +# Stream output line-by-line |
| 75 | +cmd = [sys.executable, "-m", "pip", "install", "-v", "--no-build-isolation", clone_dir] |
| 76 | +process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=build_env, text=True) |
| 77 | + |
| 78 | +# Print output while running |
| 79 | +while True: |
| 80 | + line = process.stdout.readline() |
| 81 | + if not line and process.poll() is not None: |
| 82 | + break |
| 83 | + if line: |
| 84 | + print(line.rstrip()) |
| 85 | + |
| 86 | +rc = process.poll() |
| 87 | +print("-" * 70) |
| 88 | + |
| 89 | +if rc != 0: |
| 90 | + print("\n" + "!" * 70) |
| 91 | + print("FATAL ERROR: Installation failed!") |
| 92 | + print(f"Exit Code: {rc}") |
| 93 | + print("!" * 70) |
| 94 | + sys.exit(1) |
| 95 | + |
| 96 | + |
20 | 97 | # 6. Verification |
21 | 98 | print("\n[6/7] Verifying installation...") |
22 | 99 | # Reset module cache |
|
45 | 122 | vocab.load_profile("lite") |
46 | 123 | print(f"\nActive Device: {vocab.device.upper()}") |
47 | 124 |
|
48 | | -# USE CORRECT API |
49 | 125 | info = vocab.get_info() |
50 | 126 | print(f"Backend: {info['backend']}") |
51 | 127 |
|
|
0 commit comments