{"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","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":"none","dataSources":[{"sourceId":84795,"databundleVersionId":10934030,"sourceType":"competition"},{"sourceId":218890054,"sourceType":"kernelVersion"},{"sourceId":162797,"sourceType":"modelInstanceVersion","modelInstanceId":138434,"modelId":161088},{"sourceId":162855,"sourceType":"modelInstanceVersion","modelInstanceId":138488,"modelId":161088},{"sourceId":238929,"sourceType":"modelInstanceVersion","modelInstanceId":204059,"modelId":225262}],"dockerImageVersionId":30839,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false},"papermill":{"default_parameters":{},"duration":22.341371,"end_time":"2024-12-11T03:22:13.479076","environment_variables":{},"exception":null,"input_path":"__notebook__.ipynb","output_path":"__notebook__.ipynb","parameters":{},"start_time":"2024-12-11T03:21:51.137705","version":"2.6.0"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"!python -m pip install  /kaggle/input/browser-notifications-in-a-kaggle-kernel/*.whl\n!python -m pip install jupyter -q --no-index --find-links=/kaggle/input/browser-notifications-in-a-kaggle-kernel/\n!python -m pip install -q /kaggle/input/browser-notifications-in-a-kaggle-kernel/jupyter-notify/dist/jupyternotify-0.1.15-py2.py3-none-any.whl --no-index\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-29T10:32:58.349279Z","iopub.execute_input":"2025-01-29T10:32:58.3496Z","iopub.status.idle":"2025-01-29T10:33:14.77264Z","shell.execute_reply.started":"2025-01-29T10:32:58.349568Z","shell.execute_reply":"2025-01-29T10:33:14.770614Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%reload_ext jupyternotify\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-29T10:33:14.77454Z","iopub.execute_input":"2025-01-29T10:33:14.774999Z","iopub.status.idle":"2025-01-29T10:33:15.07153Z","shell.execute_reply.started":"2025-01-29T10:33:14.774937Z","shell.execute_reply":"2025-01-29T10:33:15.070462Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip install vllm -q --target=/kaggle/working/\n!pip uninstall pynvml -y -q\n!pip install nvidia-ml-py -q --target=/kaggle/working/\n!pip install triton -q --target=/kaggle/working/","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-29T10:33:15.072586Z","iopub.execute_input":"2025-01-29T10:33:15.072928Z","iopub.status.idle":"2025-01-29T10:37:29.621849Z","shell.execute_reply.started":"2025-01-29T10:33:15.072903Z","shell.execute_reply":"2025-01-29T10:37:29.620361Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# # %cd vllm\n# # !git clone https://github.com/vllm-project/vllm.git\n\n# !pip install -e .","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-29T10:37:29.62494Z","iopub.execute_input":"2025-01-29T10:37:29.625288Z","iopub.status.idle":"2025-01-29T10:37:29.630199Z","shell.execute_reply.started":"2025-01-29T10:37:29.625249Z","shell.execute_reply":"2025-01-29T10:37:29.629096Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pip install pyngrok -q\nfrom pyngrok import ngrok, conf\nfrom kaggle_secrets import UserSecretsClient\nuser_secrets = UserSecretsClient()\nsecret_value_0 = user_secrets.get_secret(\"ngrok_auth_key\")\n\nconf.get_default().auth_token = secret_value_0\npublic_url = ngrok.connect(8000).public_url\npublic_url + '/v1'","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-29T10:37:29.632482Z","iopub.execute_input":"2025-01-29T10:37:29.632908Z","iopub.status.idle":"2025-01-29T10:37:36.867174Z","shell.execute_reply.started":"2025-01-29T10:37:29.632861Z","shell.execute_reply":"2025-01-29T10:37:36.86602Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"import subprocess\nlog_file = open(\"vllm_output.log\", \"w\")\nmodel_path = '/kaggle/input/deepseek-r1/transformers/deepseek-r1-distill-qwen-32b/1'\n\n# background task\ncommand = [\n    \"python\", \n    \"-m\", \n    \"vllm.scripts\", \n    \"serve\",\n    model_path,\n    \"--tensor_parallel_size\", \"4\",\n    \"--gpu_memory_utilization\", \"0.99\",\n    \"--enforce_eager\",\n    \"--enable_prefix_caching\",\n    \"--dtype=half\",\n    '--max_model_len', '80000'\n]\n\nprocess = subprocess.Popen(command, stdout=log_file, stderr=log_file)\n\nprint(f\"Background process started with PID: {process.pid}\")\n\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-29T10:37:36.868442Z","iopub.execute_input":"2025-01-29T10:37:36.868807Z","iopub.status.idle":"2025-01-29T10:37:36.878117Z","shell.execute_reply.started":"2025-01-29T10:37:36.868762Z","shell.execute_reply":"2025-01-29T10:37:36.876713Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!chmod +x /kaggle/working/triton/backends/nvidia/bin/ptxas\n!ls -l /kaggle/working/triton/backends/nvidia/bin/ptxas","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-29T10:37:36.879507Z","iopub.execute_input":"2025-01-29T10:37:36.879944Z","iopub.status.idle":"2025-01-29T10:37:37.215845Z","shell.execute_reply.started":"2025-01-29T10:37:36.879903Z","shell.execute_reply":"2025-01-29T10:37:37.214246Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# !pip install scikit-learn","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-29T10:37:37.217709Z","iopub.execute_input":"2025-01-29T10:37:37.21818Z","iopub.status.idle":"2025-01-29T10:37:37.22375Z","shell.execute_reply.started":"2025-01-29T10:37:37.218126Z","shell.execute_reply":"2025-01-29T10:37:37.222273Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!pkill -9 9179  ","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-29T10:37:37.224933Z","iopub.execute_input":"2025-01-29T10:37:37.225434Z","iopub.status.idle":"2025-01-29T10:37:37.387043Z","shell.execute_reply.started":"2025-01-29T10:37:37.225383Z","shell.execute_reply":"2025-01-29T10:37:37.385264Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"!tail -n 100 vllm_output.log","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-29T10:37:37.388937Z","iopub.execute_input":"2025-01-29T10:37:37.389582Z","iopub.status.idle":"2025-01-29T10:37:37.513452Z","shell.execute_reply.started":"2025-01-29T10:37:37.389537Z","shell.execute_reply":"2025-01-29T10:37:37.511972Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# !python -m pip list | grep jax","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-29T10:37:37.514849Z","iopub.execute_input":"2025-01-29T10:37:37.515228Z","iopub.status.idle":"2025-01-29T10:37:37.520067Z","shell.execute_reply.started":"2025-01-29T10:37:37.515173Z","shell.execute_reply":"2025-01-29T10:37:37.518924Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"# !pip install -U jax jaxlib --target=/kaggle/working/","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-29T10:37:37.521198Z","iopub.execute_input":"2025-01-29T10:37:37.521606Z","iopub.status.idle":"2025-01-29T10:37:37.53868Z","shell.execute_reply.started":"2025-01-29T10:37:37.521528Z","shell.execute_reply":"2025-01-29T10:37:37.53755Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"\n%%notify\nimport requests\nimport time\ntry:\n    while True:\n        try:\n            !tail -1 vllm_output.log\n            requests.get('http://localhost:8000/v1/models')\n            break\n        except Exception as e:\n            print(end='.')\n            time.sleep(30)\nexcept KeyboardInterrupt:\n    print('KeyboardInterrupt')\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-29T10:37:37.542242Z","iopub.execute_input":"2025-01-29T10:37:37.542603Z","iopub.status.idle":"2025-01-29T12:13:39.107555Z","shell.execute_reply.started":"2025-01-29T10:37:37.542573Z","shell.execute_reply":"2025-01-29T12:13:39.105832Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"%%notify\n!pip install pause -q\nfrom datetime import datetime, timedelta\nfrom pause import until\ndt = datetime.now()\ndt = dt + timedelta(minutes=40, seconds=30)\nprint(dt + timedelta(hours=5, minutes=30))\nuntil(dt)\n\n","metadata":{"trusted":true,"execution":{"iopub.status.busy":"2025-01-29T12:13:39.110503Z","iopub.execute_input":"2025-01-29T12:13:39.111013Z","iopub.status.idle":"2025-01-29T12:13:43.848273Z","shell.execute_reply.started":"2025-01-29T12:13:39.110919Z","shell.execute_reply":"2025-01-29T12:13:43.847063Z"}},"outputs":[],"execution_count":null}]}