{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.12","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"gpu","dataSources":[{"sourceId":87939,"databundleVersionId":10049490,"sourceType":"competition"}],"dockerImageVersionId":30822,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":true},"colab":{"provenance":[]}},"nbformat_minor":0,"nbformat":4,"cells":[{"cell_type":"code","source":["# This Python 3 environment comes with many helpful analytics libraries installed\n","# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n","# For example, here's several helpful packages to load\n","\n","import numpy as np # linear algebra\n","import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n","\n","# Input data files are available in the read-only \"../input/\" directory\n","# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n","\n","import os\n","for dirname, _, filenames in os.walk('/kaggle/input'):\n","    for filename in filenames:\n","        print(os.path.join(dirname, filename))\n","\n","# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\"\n","# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session"],"metadata":{"_uuid":"58da089e-6563-44e1-bd60-f453e047084e","_cell_guid":"22bbce47-2598-4628-81dc-ee45b407352d","trusted":true,"jupyter":{"outputs_hidden":false},"id":"QiB4WX9osygZ"},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":["Confirm the status of the NVIDIA GPUs available in the environment."],"metadata":{"id":"gL3Hdr7wsygb"}},{"cell_type":"code","source":["!nvidia-smi"],"metadata":{"_uuid":"ce8b10a7-dcd6-43b7-920a-61adba967006","_cell_guid":"b8d38c11-2bf6-41c6-b5c5-37be45487181","trusted":true,"execution":{"iopub.status.busy":"2024-12-26T11:29:52.764657Z","iopub.execute_input":"2024-12-26T11:29:52.764967Z","iopub.status.idle":"2024-12-26T11:29:52.928440Z","shell.execute_reply.started":"2024-12-26T11:29:52.764947Z","shell.execute_reply":"2024-12-26T11:29:52.927526Z"},"jupyter":{"outputs_hidden":false},"id":"E-KeZTgZsygd","outputId":"25d4865a-f03b-477c-cc3b-5432f9756553"},"outputs":[{"name":"stdout","text":"Thu Dec 26 11:29:52 2024       \n+-----------------------------------------------------------------------------------------+\n| NVIDIA-SMI 560.35.03              Driver Version: 560.35.03      CUDA Version: 12.6     |\n|-----------------------------------------+------------------------+----------------------+\n| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |\n| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |\n|                                         |                        |               MIG M. |\n|=========================================+========================+======================|\n|   0  Tesla P100-PCIE-16GB           Off |   00000000:00:04.0 Off |                    0 |\n| N/A   35C    P0             26W /  250W |       0MiB /  16384MiB |      0%      Default |\n|                                         |                        |                  N/A |\n+-----------------------------------------+------------------------+----------------------+\n                                                                                         \n+-----------------------------------------------------------------------------------------+\n| Processes:                                                                              |\n|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |\n|        ID   ID                                                               Usage      |\n|=========================================================================================|\n|  No running processes found                                                             |\n+-----------------------------------------------------------------------------------------+\n","output_type":"stream"}],"execution_count":null},{"cell_type":"markdown","source":["To confirm the list of pre-installed libraries and their versions in a Kaggle notebook"],"metadata":{"id":"NRyfGt-qsygf"}},{"cell_type":"code","source":["!pip list"],"metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-26T04:25:46.075838Z","iopub.execute_input":"2024-12-26T04:25:46.076212Z","iopub.status.idle":"2024-12-26T04:25:47.356872Z","shell.execute_reply.started":"2024-12-26T04:25:46.076183Z","shell.execute_reply":"2024-12-26T04:25:47.355783Z"},"id":"76BnAyOXsygg","outputId":"c4481772-0082-4687-cea7-76a27a7a1f94"},"outputs":[{"name":"stdout","text":"pytorch-ignite                   0.5.1\npytorch-lightning                2.4.0\n","output_type":"stream"}],"execution_count":null},{"cell_type":"code","source":["import torch"],"metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-26T04:33:02.436705Z","iopub.execute_input":"2024-12-26T04:33:02.437072Z","iopub.status.idle":"2024-12-26T04:33:06.100825Z","shell.execute_reply.started":"2024-12-26T04:33:02.437041Z","shell.execute_reply":"2024-12-26T04:33:06.099925Z"},"id":"T2Qo3004sygh"},"outputs":[],"execution_count":null},{"cell_type":"markdown","source":["**Kaggle API Demo** <br>\n","The Kaggle API allows you to programmatically interact with Kaggle's platform, enabling tasks like downloading datasets, submitting to competitions, and managing kernels."],"metadata":{"id":"eIWCFG0Xsygi"}},{"cell_type":"code","source":["!pip install --upgrade --force-reinstall --no-deps kaggle==1.5.8\n","!mkdir /root/.kaggle\n","\n","with open(\"/root/.kaggle/kaggle.json\", \"w+\") as f:\n","    f.write('{\"username\":\"dami1012\",\"key\":\"86fa338382e074eb76d024d69ab69f7f\"}')\n","    # Put your kaggle username & key here\n","\n","!chmod 600 /root/.kaggle/kaggle.json"],"metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-26T09:41:44.916717Z","iopub.execute_input":"2024-12-26T09:41:44.917066Z","iopub.status.idle":"2024-12-26T09:41:49.124846Z","shell.execute_reply.started":"2024-12-26T09:41:44.917037Z","shell.execute_reply":"2024-12-26T09:41:49.123934Z"},"id":"L4mOz8P3sygj","outputId":"b44a453f-c49f-454a-f63a-3c9fa932afbf"},"outputs":[{"name":"stdout","text":"Collecting kaggle==1.5.8\n  Downloading kaggle-1.5.8.tar.gz (59 kB)\n\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m59.2/59.2 kB\u001b[0m \u001b[31m2.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n\u001b[?25h  Preparing metadata (setup.py) ... \u001b[?25l\u001b[?25hdone\nBuilding wheels for collected packages: kaggle\n  Building wheel for kaggle (setup.py) ... \u001b[?25l\u001b[?25hdone\n  Created wheel for kaggle: filename=kaggle-1.5.8-py3-none-any.whl size=73248 sha256=47ecb297cc4bf50de873fbddf7a3a46ab6cf4d6ac0001be73c364095d64ab34e\n  Stored in directory: /root/.cache/pip/wheels/0b/76/ca/e58f8afa83166a0e68f0d5cd2e7f99d260bdc40e35da080eee\nSuccessfully built kaggle\nInstalling collected packages: kaggle\n  Attempting uninstall: kaggle\n    Found existing installation: kaggle 1.6.17\n    Uninstalling kaggle-1.6.17:\n      Successfully uninstalled kaggle-1.6.17\nSuccessfully installed kaggle-1.5.8\n","output_type":"stream"}],"execution_count":null},{"cell_type":"markdown","source":["Submit to a Competition"],"metadata":{"id":"61jP0jidsygk"}},{"cell_type":"code","source":["# !kaggle competitions submit -c <competition-name> -f <submission-file> -m \"<message>\"\n","!kaggle competitions submit -c hw3p2-785-f24 -f submission.csv -m \"I made it!\""],"metadata":{"trusted":true,"id":"T3ox8wRzsygl"},"outputs":[],"execution_count":null},{"cell_type":"code","source":["!kaggle competitions leaderboard -c hw3p2-785-f24 --show | head -n 21\n","!kaggle competitions leaderboard -c hw3p2-785-f24 --download"],"metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-26T09:46:07.287788Z","iopub.execute_input":"2024-12-26T09:46:07.288171Z","iopub.status.idle":"2024-12-26T09:46:08.717030Z","shell.execute_reply.started":"2024-12-26T09:46:07.288144Z","shell.execute_reply":"2024-12-26T09:46:08.715963Z"},"id":"3Jrtb9ORsygl","outputId":"97ee57f0-f71b-4f3d-8906-d37bfc77111b"},"outputs":[{"name":"stdout","text":"Warning: Looks like you're using an outdated API Version, please consider updating (server 1.6.17 / client 1.5.8)\n  teamId  teamName       submissionDate       score     \n--------  -------------  -------------------  --------  \n12810601  Jackie Wang    2024-10-27 19:57:06  6.58142   \n12824520  Darren Siegel  2024-10-27 20:23:11  7.02798   \n12838384  isxixi         2024-10-27 19:56:04  7.96310   \n12829996  Jessica Ruan   2024-10-28 17:35:04  8.38994   \n12835394  Aditya Aayush  2024-10-28 04:50:12  8.74427   \n12838306  Cassandra Shi  2024-10-27 19:06:33  10.27862  \n12834308  Matthew Li     2024-10-27 18:43:08  10.85432  \nWarning: Looks like you're using an outdated API Version, please consider updating (server 1.6.17 / client 1.5.8)\nDownloading hw3p2-785-f24.zip to /kaggle/working\n  0%|                                                 | 0.00/556 [00:00<?, ?B/s]\n100%|██████████████████████████████████████████| 556/556 [00:00<00:00, 1.46MB/s]\n","output_type":"stream"}],"execution_count":null},{"cell_type":"code","source":["!kaggle --help"],"metadata":{"trusted":true,"execution":{"iopub.status.busy":"2024-12-26T09:26:22.578552Z","iopub.execute_input":"2024-12-26T09:26:22.578841Z","iopub.status.idle":"2024-12-26T09:26:23.059873Z","shell.execute_reply.started":"2024-12-26T09:26:22.578820Z","shell.execute_reply":"2024-12-26T09:26:23.059060Z"},"id":"YKWRNTDbsygm","outputId":"81bf1458-3845-434f-d445-f3fc3c90d0d6"},"outputs":[{"name":"stdout","text":"usage: kaggle [-h] [-v] [-W] {competitions,c,datasets,d,kernels,k,models,m,files,f,config} ...\n\noptions:\n  -h, --help            show this help message and exit\n  -v, --version         Print the Kaggle API version\n  -W, --no-warn         Disable out-of-date API version warning\n\ncommands:\n  {competitions,c,datasets,d,kernels,k,models,m,files,f,config}\n                        Use one of:\n                        competitions {list, files, download, submit, submissions, leaderboard}\n                        datasets {list, files, download, create, version, init, metadata, status}\n                        kernels {list, files, init, push, pull, output, status}\n                        models {instances, get, list, init, create, delete, update}\n                        models instances {versions, get, files, init, create, delete, update}\n                        models instances versions {init, create, download, delete, files}\n                        config {view, set, unset}\n    competitions (c)    Commands related to Kaggle competitions\n    datasets (d)        Commands related to Kaggle datasets\n    kernels (k)         Commands related to Kaggle kernels\n    models (m)          Commands related to Kaggle models\n    files (f)           Commands related files\n    config              Configuration settings\n","output_type":"stream"}],"execution_count":null}]}