|
154 | 154 | }, |
155 | 155 | { |
156 | 156 | "cell_type": "code", |
157 | | - "execution_count": 8, |
| 157 | + "execution_count": 20, |
158 | 158 | "metadata": {}, |
159 | 159 | "outputs": [ |
160 | 160 | { |
161 | | - "ename": "NameError", |
162 | | - "evalue": "name 'AutoModel' is not defined", |
| 161 | + "name": "stdout", |
| 162 | + "output_type": "stream", |
| 163 | + "text": [ |
| 164 | + "Defaulting to user installation because normal site-packages is not writeable\n", |
| 165 | + "Requirement already satisfied: transformers in /home/rstudio/.local/lib/python3.10/site-packages (4.41.2)\n", |
| 166 | + "Requirement already satisfied: torch in /home/rstudio/.local/lib/python3.10/site-packages (2.3.0)\n", |
| 167 | + "Collecting torchvision\n", |
| 168 | + " Downloading torchvision-0.18.0-cp310-cp310-manylinux1_x86_64.whl (7.0 MB)\n", |
| 169 | + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m7.0/7.0 MB\u001b[0m \u001b[31m46.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", |
| 170 | + "\u001b[?25hRequirement already satisfied: pyyaml>=5.1 in /home/rstudio/.local/lib/python3.10/site-packages (from transformers) (6.0.1)\n", |
| 171 | + "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from transformers) (24.0)\n", |
| 172 | + "Requirement already satisfied: tqdm>=4.27 in /home/rstudio/.local/lib/python3.10/site-packages (from transformers) (4.66.4)\n", |
| 173 | + "Requirement already satisfied: tokenizers<0.20,>=0.19 in /home/rstudio/.local/lib/python3.10/site-packages (from transformers) (0.19.1)\n", |
| 174 | + "Requirement already satisfied: huggingface-hub<1.0,>=0.23.0 in /home/rstudio/.local/lib/python3.10/site-packages (from transformers) (0.23.2)\n", |
| 175 | + "Requirement already satisfied: requests in /home/rstudio/.local/lib/python3.10/site-packages (from transformers) (2.32.3)\n", |
| 176 | + "Requirement already satisfied: filelock in /home/rstudio/.local/lib/python3.10/site-packages (from transformers) (3.14.0)\n", |
| 177 | + "Requirement already satisfied: safetensors>=0.4.1 in /home/rstudio/.local/lib/python3.10/site-packages (from transformers) (0.4.3)\n", |
| 178 | + "Requirement already satisfied: regex!=2019.12.17 in /home/rstudio/.local/lib/python3.10/site-packages (from transformers) (2024.5.15)\n", |
| 179 | + "Requirement already satisfied: numpy>=1.17 in /home/rstudio/.local/lib/python3.10/site-packages (from transformers) (1.26.4)\n", |
| 180 | + "Requirement already satisfied: nvidia-cufft-cu12==11.0.2.54 in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (11.0.2.54)\n", |
| 181 | + "Requirement already satisfied: nvidia-cuda-nvrtc-cu12==12.1.105 in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (12.1.105)\n", |
| 182 | + "Requirement already satisfied: typing-extensions>=4.8.0 in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (4.12.1)\n", |
| 183 | + "Requirement already satisfied: triton==2.3.0 in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (2.3.0)\n", |
| 184 | + "Requirement already satisfied: nvidia-cusolver-cu12==11.4.5.107 in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (11.4.5.107)\n", |
| 185 | + "Requirement already satisfied: sympy in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (1.12.1)\n", |
| 186 | + "Requirement already satisfied: networkx in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (3.3)\n", |
| 187 | + "Requirement already satisfied: fsspec in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (2024.6.0)\n", |
| 188 | + "Requirement already satisfied: nvidia-cudnn-cu12==8.9.2.26 in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (8.9.2.26)\n", |
| 189 | + "Requirement already satisfied: nvidia-nvtx-cu12==12.1.105 in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (12.1.105)\n", |
| 190 | + "Requirement already satisfied: nvidia-cublas-cu12==12.1.3.1 in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (12.1.3.1)\n", |
| 191 | + "Requirement already satisfied: jinja2 in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (3.1.4)\n", |
| 192 | + "Requirement already satisfied: nvidia-curand-cu12==10.3.2.106 in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (10.3.2.106)\n", |
| 193 | + "Requirement already satisfied: nvidia-cuda-cupti-cu12==12.1.105 in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (12.1.105)\n", |
| 194 | + "Requirement already satisfied: nvidia-cuda-runtime-cu12==12.1.105 in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (12.1.105)\n", |
| 195 | + "Requirement already satisfied: nvidia-cusparse-cu12==12.1.0.106 in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (12.1.0.106)\n", |
| 196 | + "Requirement already satisfied: nvidia-nccl-cu12==2.20.5 in /home/rstudio/.local/lib/python3.10/site-packages (from torch) (2.20.5)\n", |
| 197 | + "Requirement already satisfied: nvidia-nvjitlink-cu12 in /home/rstudio/.local/lib/python3.10/site-packages (from nvidia-cusolver-cu12==11.4.5.107->torch) (12.5.40)\n", |
| 198 | + "Collecting pillow!=8.3.*,>=5.3.0\n", |
| 199 | + " Downloading pillow-10.3.0-cp310-cp310-manylinux_2_28_x86_64.whl (4.5 MB)\n", |
| 200 | + "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m4.5/4.5 MB\u001b[0m \u001b[31m54.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m:00:01\u001b[0m\n", |
| 201 | + "\u001b[?25hRequirement already satisfied: MarkupSafe>=2.0 in /home/rstudio/.local/lib/python3.10/site-packages (from jinja2->torch) (2.1.5)\n", |
| 202 | + "Requirement already satisfied: charset-normalizer<4,>=2 in /home/rstudio/.local/lib/python3.10/site-packages (from requests->transformers) (3.3.2)\n", |
| 203 | + "Requirement already satisfied: certifi>=2017.4.17 in /home/rstudio/.local/lib/python3.10/site-packages (from requests->transformers) (2024.6.2)\n", |
| 204 | + "Requirement already satisfied: idna<4,>=2.5 in /home/rstudio/.local/lib/python3.10/site-packages (from requests->transformers) (3.7)\n", |
| 205 | + "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/rstudio/.local/lib/python3.10/site-packages (from requests->transformers) (2.2.1)\n", |
| 206 | + "Requirement already satisfied: mpmath<1.4.0,>=1.1.0 in /home/rstudio/.local/lib/python3.10/site-packages (from sympy->torch) (1.3.0)\n", |
| 207 | + "Installing collected packages: pillow, torchvision\n", |
| 208 | + "Successfully installed pillow-10.3.0 torchvision-0.18.0\n", |
| 209 | + "Note: you may need to restart the kernel to use updated packages.\n" |
| 210 | + ] |
| 211 | + } |
| 212 | + ], |
| 213 | + "source": [ |
| 214 | + "pip install transformers torch torchvision\n" |
| 215 | + ] |
| 216 | + }, |
| 217 | + { |
| 218 | + "cell_type": "code", |
| 219 | + "execution_count": 21, |
| 220 | + "metadata": {}, |
| 221 | + "outputs": [], |
| 222 | + "source": [ |
| 223 | + "# added/edited\n", |
| 224 | + "from transformers import AutoModel" |
| 225 | + ] |
| 226 | + }, |
| 227 | + { |
| 228 | + "cell_type": "code", |
| 229 | + "execution_count": 22, |
| 230 | + "metadata": {}, |
| 231 | + "outputs": [ |
| 232 | + { |
| 233 | + "ename": "ImportError", |
| 234 | + "evalue": "\nAutoModel requires the PyTorch library but it was not found in your environment. Checkout the instructions on the\ninstallation page: https://pytorch.org/get-started/locally/ and follow the ones that match your environment.\nPlease note that you may need to restart your runtime after installation.\n", |
163 | 235 | "output_type": "error", |
164 | 236 | "traceback": [ |
165 | 237 | "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
166 | | - "\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)", |
167 | | - "Cell \u001b[0;32mIn[8], line 4\u001b[0m\n\u001b[1;32m 1\u001b[0m modelId \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdistilbert-base-uncased-finetuned-sst-2-english\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;66;03m# Instantiate the AutoModel class\u001b[39;00m\n\u001b[0;32m----> 4\u001b[0m model \u001b[38;5;241m=\u001b[39m \u001b[43mAutoModel\u001b[49m\u001b[38;5;241m.\u001b[39mfrom_pretrained(modelId)\n\u001b[1;32m 6\u001b[0m \u001b[38;5;66;03m# Save the model\u001b[39;00m\n\u001b[1;32m 7\u001b[0m model\u001b[38;5;241m.\u001b[39msave_pretrained(save_directory\u001b[38;5;241m=\u001b[39m\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmodels/\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmodelId\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", |
168 | | - "\u001b[0;31mNameError\u001b[0m: name 'AutoModel' is not defined" |
| 238 | + "\u001b[0;31mImportError\u001b[0m Traceback (most recent call last)", |
| 239 | + "Cell \u001b[0;32mIn[22], line 4\u001b[0m\n\u001b[1;32m 1\u001b[0m modelId \u001b[38;5;241m=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdistilbert-base-uncased-finetuned-sst-2-english\u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[1;32m 3\u001b[0m \u001b[38;5;66;03m# Instantiate the AutoModel class\u001b[39;00m\n\u001b[0;32m----> 4\u001b[0m model \u001b[38;5;241m=\u001b[39m \u001b[43mAutoModel\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mfrom_pretrained\u001b[49m(modelId)\n\u001b[1;32m 6\u001b[0m \u001b[38;5;66;03m# Save the model\u001b[39;00m\n\u001b[1;32m 7\u001b[0m model\u001b[38;5;241m.\u001b[39msave_pretrained(save_directory\u001b[38;5;241m=\u001b[39m\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmodels/\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mmodelId\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", |
| 240 | + "File \u001b[0;32m~/.local/lib/python3.10/site-packages/transformers/utils/import_utils.py:1475\u001b[0m, in \u001b[0;36mDummyObject.__getattribute__\u001b[0;34m(cls, key)\u001b[0m\n\u001b[1;32m 1473\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m key\u001b[38;5;241m.\u001b[39mstartswith(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m_\u001b[39m\u001b[38;5;124m\"\u001b[39m) \u001b[38;5;129;01mand\u001b[39;00m key \u001b[38;5;241m!=\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m_from_config\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n\u001b[1;32m 1474\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28msuper\u001b[39m()\u001b[38;5;241m.\u001b[39m\u001b[38;5;21m__getattribute__\u001b[39m(key)\n\u001b[0;32m-> 1475\u001b[0m \u001b[43mrequires_backends\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;28;43mcls\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43mcls\u001b[39;49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43m_backends\u001b[49m\u001b[43m)\u001b[49m\n", |
| 241 | + "File \u001b[0;32m~/.local/lib/python3.10/site-packages/transformers/utils/import_utils.py:1463\u001b[0m, in \u001b[0;36mrequires_backends\u001b[0;34m(obj, backends)\u001b[0m\n\u001b[1;32m 1461\u001b[0m failed \u001b[38;5;241m=\u001b[39m [msg\u001b[38;5;241m.\u001b[39mformat(name) \u001b[38;5;28;01mfor\u001b[39;00m available, msg \u001b[38;5;129;01min\u001b[39;00m checks \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m available()]\n\u001b[1;32m 1462\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m failed:\n\u001b[0;32m-> 1463\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mImportError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(failed))\n", |
| 242 | + "\u001b[0;31mImportError\u001b[0m: \nAutoModel requires the PyTorch library but it was not found in your environment. Checkout the instructions on the\ninstallation page: https://pytorch.org/get-started/locally/ and follow the ones that match your environment.\nPlease note that you may need to restart your runtime after installation.\n" |
169 | 243 | ] |
170 | 244 | } |
171 | 245 | ], |
|
0 commit comments