lijn14 commited on
Commit
5007ef5
·
1 Parent(s): 190c9ce

优化依赖包

Browse files
notebooks/EasyTranslate_Production.ipynb CHANGED
@@ -160,17 +160,19 @@
160
  "outputs": [],
161
  "source": [
162
  "if IN_COLAB:\n",
163
- " !pip install -q transformers>=4.36.0 datasets>=2.16.0 tokenizers>=0.15.0\n",
164
- " !pip install -q sentencepiece>=0.1.99 accelerate>=0.25.0\n",
165
- " !pip install -q peft>=0.7.0 sacrebleu>=2.4.0 unbabel-comet>=2.2.0\n",
166
- " !pip install -q omegaconf>=2.3.0 rich>=13.0.0 tqdm>=4.66.0\n",
167
- " !pip install -q wandb>=0.16.0 tensorboard>=2.15.0\n",
168
- " !pip install -q -e .\n",
 
169
  "else:\n",
170
- " !pip install -q -r requirements.txt\n",
171
- " !pip install -q -e .\n",
 
172
  "\n",
173
- "print(\"Dependencies installed successfully\")"
174
  ]
175
  },
176
  {
@@ -251,6 +253,19 @@
251
  "metadata": {},
252
  "outputs": [],
253
  "source": [
 
 
 
 
 
 
 
 
 
 
 
 
 
254
  "from easytranslate.utils.config import load_config, config_to_dict\n",
255
  "from easytranslate.utils.seed import set_seed\n",
256
  "from easytranslate.utils.logging import setup_logging\n",
@@ -268,15 +283,12 @@
268
  " log_file=\"easytranslate.log\",\n",
269
  ")\n",
270
  "\n",
271
- "# ── Colab overrides ──────────────────────────────────────────────────────────\n",
272
  "if IN_COLAB:\n",
273
- " # Disable fp16 if no GPU (avoids GradScaler errors on CPU)\n",
274
  " if not torch.cuda.is_available():\n",
275
  " config_dict[\"training\"][\"fp16\"] = False\n",
276
  " config_dict[\"training\"][\"bf16\"] = False\n",
277
- " # Fewer epochs for quick demo; increase for a real training run\n",
278
  " config_dict[\"training\"][\"epochs\"] = config_dict[\"training\"].get(\"epochs\", 30)\n",
279
- "# ─────────────────────────────────────────────────────────────────────────────\n",
280
  "\n",
281
  "print(f\"Configuration loaded successfully\")\n",
282
  "print(f\"Model type: {config_dict['model']['type']}\")\n",
 
160
  "outputs": [],
161
  "source": [
162
  "if IN_COLAB:\n",
163
+ " # Reuse Colab's preinstalled torch / numpy stack to avoid massive downgrades.\n",
164
+ " %pip install -q --upgrade pip setuptools wheel\n",
165
+ " %pip install -q -r requirements-colab.txt\n",
166
+ " %pip install -q --no-deps -e .\n",
167
+ "\n",
168
+ " print(\"Dependencies installed successfully\")\n",
169
+ " print(\"Using Colab's preinstalled torch/numpy stack to minimize dependency conflicts.\")\n",
170
  "else:\n",
171
+ " %pip install -q --upgrade pip setuptools wheel\n",
172
+ " %pip install -q -r requirements.txt\n",
173
+ " %pip install -q -e .\n",
174
  "\n",
175
+ " print(\"Dependencies installed successfully\")\n"
176
  ]
177
  },
178
  {
 
253
  "metadata": {},
254
  "outputs": [],
255
  "source": [
256
+ "import importlib\n",
257
+ "\n",
258
+ "try:\n",
259
+ " import numpy as np\n",
260
+ " import pandas as pd\n",
261
+ " print(f\"NumPy version: {np.__version__}\")\n",
262
+ " print(f\"Pandas version: {pd.__version__}\")\n",
263
+ "except Exception as exc:\n",
264
+ " raise RuntimeError(\n",
265
+ " \"Numeric Python stack is broken in this runtime. \"\n",
266
+ " \"Rerun the dependency installation cell, then restart the kernel and run the notebook from the top.\"\n",
267
+ " ) from exc\n",
268
+ "\n",
269
  "from easytranslate.utils.config import load_config, config_to_dict\n",
270
  "from easytranslate.utils.seed import set_seed\n",
271
  "from easytranslate.utils.logging import setup_logging\n",
 
283
  " log_file=\"easytranslate.log\",\n",
284
  ")\n",
285
  "\n",
286
+ "# Colab overrides\n",
287
  "if IN_COLAB:\n",
 
288
  " if not torch.cuda.is_available():\n",
289
  " config_dict[\"training\"][\"fp16\"] = False\n",
290
  " config_dict[\"training\"][\"bf16\"] = False\n",
 
291
  " config_dict[\"training\"][\"epochs\"] = config_dict[\"training\"].get(\"epochs\", 30)\n",
 
292
  "\n",
293
  "print(f\"Configuration loaded successfully\")\n",
294
  "print(f\"Model type: {config_dict['model']['type']}\")\n",