Kaggle - Qiita Advent Calendar 2024 - Qiita 25æ¥ç®ã®è¨äºã§ãã
ã¯ããã«: Kaggleã«ãããè¨ç®ãªã½ã¼ã¹ã®éè¦æ§
Kaggleã§ã¯ããã¼ã¿ãµã¤ã¨ã³ã¹ã®ã³ã³ããã£ã·ã§ã³ãéå¬ããã¦ããããã®å¤ãã¯GPUã使ã£ãè¨ç®ãå¿ è¦ã ã ä¾ãã°ãç»åèªèã®ã³ã³ããã£ã·ã§ã³ã§ã¯ãç»åãã¼ã¿ãå¦ç¿ããããã«ã大éã®ç»åãã¼ã¿ãGPUã§å¦ç¿ããå¿ è¦ãããã ãããã®è¨ç®ã¯ããã¼ã«ã«ã®PCã§ã¯é£ãããããã¯ã©ã¦ãä¸ã®è¨ç®ãªã½ã¼ã¹ãå©ç¨ãããã¨ãä¸è¬çã ã
ããã¦ãKaggleã®ã³ã³ããã£ã·ã§ã³ã«ããã¦ã¯ãè¨ç®ãªã½ã¼ã¹ã®æ§è½ãåæãåãããã¨ãå¤ãã ã¶ã£ã¡ããç§ã®ãããªã»ã³ã¹ã®ãªã人éã§ããå¤ãã®è¨ç®ãªã½ã¼ã¹ã確ä¿ãã試è¡åæ°ãã¨ã«ããå¢ããã°ãä¸ä½ã«å ¥ã確çãé«ã¾ãã®ã§ããã (競ãããæ°å¦ãªãªã³ããã¯ã§ã¯ããã¯ãããªããè³æ¬ä¸»ç¾©ãã³ã¶ã¤ã)
è¨ç®ãªã½ã¼ã¹ã¨ãã¦ã¯ãAWSãGCPãæåã ãããããã¯æéãé«ããç§ã®ãããªè²§æ°ãããããå¤ç¨ãã¦ãã¾ã£ãããç ´ç£å¾ ã£ããªãã§ããã(è³æ¬ä¸»ç¾©ãæãã) ãããªéè¦ãæºãããã®ããã«ãæ¨ä»ã§ã¯GPUãå°éã«å®ãæä¾ãããµã¼ãã¹ãå¢ãã¦ãã¦ããããã®ä¸ã§ãRunpodã¯ç¹ã«åªãããµã¼ãã¹ã ã¨æããã
æ¬ããã°ã§ã¯ãKaggleråãã«ãKaggleã«ç¹åããRunpodã®ä½¿ãæ¹ããã®Tipsãç´¹ä»ããã ããã«ãç¹å¥ã²ã¹ãã¨ãã¦ãKaggle Grandmaster ã§ããã¨ãã¬ã³( @ethylene_66 ) ããããæå¾ ãããéå»ã³ã³ãã§ã©ã®ããã«Runpodã使ã£ã¦ããããå®ä¾ã交ãã¦èªã£ã¦ããã ãã
Runpodã®ç´¹ä»: ãªãRunpodã使ãã®ã
Runpodã¯ããªã³ããã³ãã§GPUãã·ã³ãå©ç¨ã§ããã¯ã©ã¦ããã©ãããã©ã¼ã ã®ã²ã¨ã¤ã ã AWSãGCPãªã©ã®å¤§æã¯ã©ã¦ãã¨æ¯ã¹ãã¨ãæ軽ãªä¾¡æ ¼å¸¯ãã¢ã«ã¦ã³ãä½æããã·ã³æ§ç¯ã¾ã§ã®ç°¡åãã大ããªç¹å¾´ã§ãããã¯ã©ã¦ãçµé¨ãæµ ãæ¹ã§ãå°å ¥ããããè¨è¨ã ã¨æãããã¾ããä»ã®GPUã¯ã©ã¦ãã¨æ¯ã¹ã¦ãã¤ã³ã¿ã¼ãã§ã¤ã¹ããããããããSecrets(ããã¼ã¸ããªç°å¢å¤æ°ç®¡ç)ãªã©ã®æä½éã¨ã³ã¸ãã¢ãªã³ã°ã«å¿ è¦ãªæ©è½ãæã£ã¦ããã®ãé åã ã è¦ç´ãã¦ãã¾ãã°ããä¾¡æ ¼ãå®ãã使ãããããã¨ããã®ãRunpodã使ãçç±ã ã
ã©ããã£ã¦Kaggleåãã«Runpodã使ã£ã¦ããã®ããå®éã«GUIã®æä½ã交ãã¦èª¬æãã¦ãããã ä¸ç·ã«æä½ãé²ãã¦ããæ¹ã¯ãã¾ã以ä¸ã®ãªã³ã¯ããRunpodã«ç»é²ãã¦ãããã
https://runpod.io?ref=6x122dhk ç§ã®ãªãã¡ã©ã«ãªã³ã¯ã ããæ¬è¨äºã¸ã®æãé代ããã«ãç»é²ããã ããã¨å¬ããã
ç»é²ãå®äºããããä½æ¥ãé²ããåã«ã¯ã¬ã¸ããããã£ã¼ã¸ãã¦ããããRunpodã¯åæãå¶ã®ãµã¼ãã¹ã§ãã(ã¯ã©ã¦ãç ´ç£ãå ããã®ã§ãããããéãã§ãã)ã
å¤å$10ãããã£ã¼ã¸ã§ããã
ã¾ãã¯Storageããå§ããã
https://www.runpod.io/console/home ã«ãã°ã¤ã³ããã¨ãGPU Cloud, Serverless, Storage ã®3ã¤ã®é¸æè¢ã表示ãããã
GPU Cloudã¯ãGPUã使ã£ãè¨ç®ç°å¢ããããã¤ããããã®æ©è½ã ãKaggleã§ã¯ãã®æ©è½ãã¡ã¤ã³ã«ä½¿ããã¨ã«ãªãã ããã Serverlessã¯ãGPUãç¨ãããµã¼ãã¼ã¬ã¹ã¢ã¼ããã¯ãã£ãæ§ç¯ããããã®æ©è½ã ãä»åã¯ä½¿ããªãã Storageã¯ãè¨ç®ç°å¢ããåãé¢ãããæ°¸ç¶ãã¼ã¿ãä¿åããããã®æ©è½ã ã
å®ã¯ä¸çªãã¾ãæ´»ç¨ããã¹ããªã®ã¯ãStorageæ©è½ã§ãããçç±ã¯ã¡ãã£ã¨è¤éãªã®ã§ãã¨ã§èª¬æããã è²ã ã¨ä¾¿å©ãªã®ã§ãã¾ãã¯GPU Cloudã使ãåã«ãStorageãä½ã£ã¦ãããã
Homeãã Storage -> New Network Storage ãã¯ãªãã¯ããã¨ã以ä¸ã®ãããªç»é¢ã«ãªãã
ããã§ãStorageããªã¼ã¸ã§ã³ã¨ãµã¤ãºãé¸æãã¦ä½æããããªã¼ã¸ã§ã³ã«ãã£ã¦ã使ããGPUã®ç¨®é¡ãç°ãªãã®ã§ä½æããåã«ã¯ä½¿ãããGPUã使ãããªã¼ã¸ã§ã³ãªã®ãããã§ãã¯ãã¦ãããã ãµã¤ãºã¯ããã¨ããã§ãå¢éã¯ã§ããã®ã§ãæåã¯å°ããã§ãåé¡ãªãã è¨å®ãçµãã£ãããCreateãã¯ãªãã¯ãã¦Storageãä½æããã
ãã®åæºåããã¦ãããã»ããããçç±ã¯ã次ã«GPU Cloudã®ç´¹ä»ãããéã«ãããã
GPU Cloudã§è¨ç®ç°å¢ããããã¤ãã¦ã¿ãã
ãã¦ãããããGPU Cloudã使ã£ã¦è¨ç®ç°å¢(Podã¨å¼ã°ãã)ããããã¤ãã¦ã¿ããã å ã»ã©ä½ã£ãStorageã®å³ä¸ã®Deployãã¿ã³ãã¯ãªãã¯ãããã
ããã¨ãGPUãé¸æããããTemplate(è¦ã¯Docker Image)ãé¸æãããããç»é¢ãåºã¦ãããä»åã¯ã¨ãããããA100ã®GPUãé¸æãã¦é²ãã¦ã¿ããã
Pod Templateã«ã¯Runpod Pytorch 2.1
ãé¸ã¶ãã¨ããããããããKaggleã®æ¨è«ç°å¢ã¨Pythonã®ãã¼ã¸ã§ã³ãåã³ãCudaã®ãã¼ã¸ã§ã³ãåã£ã¦ããããã ã
ä»ã«ã
- GPUãããã¤æè¼ãããï¼
- é·æéã®ä½¿ç¨ãç´æãã代ããã«å²å¼ãé©ç¨ãããï¼
ã¨ãã£ãè¨å®é ç®ãããããåèªè¨å®ãã¦ã»ããã çµé¨ä¸Spotã¯ããã«æ¢ã¾ãã®ã§ãç§ã¯åºæ¬çã«On-Demandã使ç¨ãã¦ããã
è¨å®ãçµãã£ãããDeployãã¯ãªãã¯ãã¦Podããããã¤ãããã
以ä¸ã®ãããªç»é¢ãåºã¦ããããPodã®ãããã¤ãå®äºã ããã¨ã¯ããã®ç°å¢ä¸ã§ãããªãã®ã³ã¼ããåããã ãã§ãããConnectã¨æ¸ãã¦ãããã¿ã³ãæ¼ãã°ãsshæ¥ç¶ã«å¿ è¦ãªæ å ±ãåºã¦ããã®ã§ãã¨ã¯ç ®ããªãç¼ããªãã ã
ãã®è¨ç®ç°å¢ã®ã©ã¤ããµã¤ã¯ã«ã¯æåãç¹å¥ãªã®ã§ãããã説æããªãã¨ãããªãã
- ãããã¤ãããPodãä¸æåæ¢(å¦çç¶æ ããã®ã¾ã¾ä¿åããé課éç¶æ ã«ç§»è¡ãããã¨)ãããã¨ã¯ã§ããªããåæ¢ããå ´åã«ã¯ãã´ãç®±ã®ã¢ã¤ã³ã³ãæ¼ããããªãã
/workspace
ã«ä¿åããããã¼ã¿ã¯æ°¸ç¶åããããã¤ã¾ãããã以å¤ã®ãã£ã¬ã¯ã¿ã«ä¿åãããã¼ã¿ã¯Podãçµäºããã¨æ¶ããã/workspace
ã«ã¯ãStorageã§ä½æããVolumeããã¦ã³ãããã¦ããã(ã ããã¯ããã«Storageã§Volumeãä½ãå¿ è¦ããã£ããã§ãã)
ãã®æåã¯ãDocker Containerã¨æããã°ç´ ç´ãªæåã§ãããããæ©æ¢°å¦ç¿ã¨ã®ç¸æ§ã¯æªãã ãªããªãã°ãæ©æ¢°å¦ç¿ã§ã¯ãäºåå¦ç¿æ¸ã¿ã¢ãã«ãç¨ããããå¦ç¿ãã¼ã¿ãç¨ããè¨ç®ããããã¨ãå¤ããããã«ã¯ã使ãã©ã¤ãã©ãªãå¤ããã©ã¤ãã©ãªã®ã¤ã³ã¹ãã¼ã«ã«ã¯æéããããç©ãå¤ãããã ã èµ·åãããã³ã«ç°å¢ãåæåããã¦ãã¾ã以ä¸ãå¹ççãªæ©æ¢°å¦ç¿ç°å¢ã®ã»ããã¢ãããéè¦ã ããã®ããã®Tipsãã次ã®ç« ã§èª¬æãã¦ãããã
è£è¶³:
- Storageã使ããªãã¦ããGPU Cloudã§Podããããã¤ãããã¨ã¯ã§ããããã®å ´åãPodãåæ¢ãããã¨ãå¯è½ã¨ãªããããããPodã®å®ä½ã®ãã·ã¼ã³ãä»äººã«ä½¿ããã¦ããã¨ãã«ãPodãåéãããã¨ãã§ããªããããã§ã¯ä½¿ãããã¨ãã«ä½¿ããªãããåæ¢ä¸ã®Podå ã«ãããã¼ã¿ãéé¿ããããã¨ãã§ããªããã ããåæStorageã§Volumeãä½ãå¿ è¦ããã£ããã§ããã
- Templateãé¸æãããã¨ãEdit Templateãæ¼ãã¨ãportã®è¨å®ããç°å¢å¤æ°ã®è¨å®ãã§ãããããå¦ç¿ãã°ã®å¯è¦åã«tensorboardã使ãããå ´åã«ã¯ã対å¿ããçªå·ã®portãéãã¦ããã¨ããã ãããç°å¢å¤æ°ã«é¢ãã¦ã¯Secretsæ©è½ã¨æ·±ãé¢ä¿ããã®ã§ã次ã®ç« ã§èª¬æããã
Kaggleåãç°å¢æ§ç¯ã®Tips
Runpodã使ã£ã¦ãKaggleåãã®è¨ç®ç°å¢ãæ§ç¯ããéã®TipsãQAå½¢å¼ã§ç´¹ä»ããã
Q: ä½æ¥å ´æã¯ã©ãã«ããã¹ããï¼
A: /workspace
ã®é
ä¸ã«kaggleã³ã³ãç¨ã®ãªãã¸ããªãé
ç½®ããã®ãããããããããã¼ã¿ãã¢ãã«çããã¹ã¦ãã®é
ä¸ã«ä¿åãããã¨ã§ãPodãåèµ·åãã¦ããã¼ã¿ãæ¶ããªãããã«ããã
Q: Pythonç°å¢ã¯ï¼ã©ã¤ãã©ãªã®ã¤ã³ã¹ãã¼ã«ã«æéãããããã ãã©
A: Kaggleã³ã³ãç¨ã®ãªãã¸ããªã«Poetryç°å¢ãä½æãããPoetryã§ã¯ãªãã¸ããªç´ä¸ã®.venv/
ã«ã©ã¤ãã©ãªãã¤ã³ã¹ãã¼ã«ããã®ã§ãPodãåèµ·åãã¦ãã©ã¤ãã©ãªã®ã¤ã³ã¹ãã¼ã«ãä¸è¦ã«ãªãã
ãªãããªãã¸ããªç´ä¸ã«.venv/
ãä½æããããã«ã¯ãPoetryã®è¨å®ãã¡ã¤ã«pyproject.toml
ã«ä»¥ä¸ã®è¨å®ã追å ããå¿
è¦ãããã
[tool.poetry] virtualenvs-in-project = true
Q: VSCodeã§ãªã¢ã¼ãéçºããã«ã¯ï¼
A: ãããè¦ããhttps://docs.runpod.io/tutorials/pods/connect-to-vscode ãããè¦ãã https://blog.runpod.io/how-to-connect-vscode-to-runpod/
Q: shellã®ç°å¢ãæ¯ååæåãããã®ãä¸ä¾¿ã ãã©ãããã°ããï¼
A: ç°å¢setupç¨ã®shell scriptãä½æãã¾ããããããã°ããã¯ã©ããããããªãã£ãã ä¾ãã°ãç§ã¯ä»¥ä¸ã®ãããªã¹ã¯ãªãããç¨ãã¦ãããPodãèµ·åãããåæã§ãããå®è¡ãã¦ããã
apt update apt upgrade -y apt install -y fish tmux htop pip install poetry kaggle mkdir ~/.kaggle echo $RUNPOD_SECRET_kaggle_json > ~/.kaggle/kaggle.json # ãã¼ããã·ã§ã³ãè¨å® chmod 600 ~/.kaggle/kaggle.json git config --global user.email "{githubã®ã¡ã¢ã}" git config --global user.name "{githubã®ã¦ã¼ã¶å}"
$RUNPOD_SECRET_kaggle_json
ã¯ãRunpodã®Secretsæ©è½ã使ã£ã¦ãKaggle APIã®ãã¼ã¯ã³ãè¨å®ãã¦ããã
èªè¨¼æ
å ±ç³»ã¯Secretsæ©è½ã使ãã°ãã»ãã¥ã¢ã«ç°å¢å¤æ°ã¨ãã¦ç®¡çã»åã渡ããå¯è½ã ãsetupç¨ã®scriptã«ãç°¡åã«çµã¿è¾¼ãããããªã¹ã¹ã¡ã§ããã
Podãä½ãã¨ãã«ç°å¢å¤æ°ã®ã¨ããã§ãããªæãã«æ¸ãã¦ããã
Q: å¦ç¿ããã¢ãã«ãä¿åãã¦ãããã£ã¹ã¯å®¹éã大ãããªããè²»ç¨ã嵩ãã§ãããã©ãããã°ããï¼
A: å¦ç¿ã«æ¯å使ããªããã®ã«é¢ãã¦ã¯ãGoogle Cloud Storageã«ã¢ãããã¼ããããã¨ã¦ãå®ãã
å®ç¨ä¾ by ã¨ãã¬ã³ãã
ããããããã¨ã« ãKaggle RunPod é¨ãã®ä¸å¡ã¨ãã¦ä¸ç« æ¸ããã¦ãããããã¨ã«ãªã£ãã®ã§ãå¸æã®ããã«éå»ã³ã³ãã§ã® RunPod æ´»ç¨ä¾ã«ã¤ãã¦ç´¹ä»ããã¦ããã ããã¨ã«ããã
ã©ã¡ãã RunPod ã®ã¹ã±ã¼ã©ããªãã£ã«å©ããããäºä¾ã§ãããããããã£ããã«ç§ã使ãããã®ã¤ã³ã¹ã¿ã³ã¹ãé£ãå°½ãããªãç¨åº¦ã« RunPod 使ç¨è
ãå¢ããã¨å¬ããã
ã³ã³ãå 容ã解æ³ã®è©³ç´°ã«ã¯è¸ã¿è¾¼ã¾ãªãã®ã§ããã¡ããæ°ã«ãªãæ¹ã¯ã³ã³ãã® Discussion ãä»ã®æ¹ã®è§£æ³ã¾ã¨ããåç §ãã¦ãããããã
é£è¡æ©é²ã³ã³ã
ã³ã³ãå 容ï¼ç»åã»ã°ã¡ã³ãã¼ã·ã§ã³
ã³ã³ãã®è§£æ³ : https://www.kaggle.com/competitions/google-research-identify-contrails-reduce-global-warming/discussion/430543
ã³ã³ãçµäº1é±éåãéåä¸ä½ããã¾ãã£ã¦ããã¨ããå½æã¯æ³¨ç®ããã¦ããªãã£ãå¼·ãã¢ãã«ããã¼ã ã¡ã¤ããçºè¦ãããããã§éåãè¦ãã¦ãã¦ããã ã·ã³ã°ã«ã¢ãã«ã§éåä¸ä½ãåããã¨ãå¯è½ãªå¼·åãªã¢ãã«ã§ãããªãã¨ãã¦ã§ãã¢ã³ãµã³ãã«ã«çµã¿è¾¼ã¿ããã£ããã®ã®ãlearning rate çã®ãã¤ãã©èª¿æ´ãé£ãããå¦ç¿ã«åæ¥ã»ã©è¦ããæã®ãããã¢ãã«ã§ãæ®ãæéã§è¯ããã¤ãã©ãå¼ããããæªããã£ãã
ããã§è¨ç®è³æºãå¢ããããã«ã¯ã©ã¦ã GPU ãµã¼ãã¼ãåãããã¨ã«ãããã®ã®ãGCP/AWS ã¯é«ä¾¡ã ããå®ä¾¡ãªãã¨ã§æå㪠vast.ai ã¯ã¯ã¬ã«ãéãããéæ¹ã«ããã¦ããã ãããã®æµ·ãããªãã¨ãæ¢ãåºãã RunPod ã«ã¯ç¡äºç»é²ã§ãããããæçµçã«ã¯ã¤ã³ã¹ã¿ã³ã¹ãè¤æ°ï¼ããã RTX 4090 㨠A6000 ããããã2å°ï¼ç«ã¦ããã¨ã§ãã¤ãã©èª¿æ´ã¨ 5-fold ã§ã®è¨ç·´ãã³ã³ãçµäºåã«å®äºã§ããç»åã³ã³ãã§ã®åã®éã¡ãã«ãç²å¾ããã
LLM 20 Questions ã³ã³ã
ã³ã³ãå 容ï¼20 Questions ã¨ããè¨èªã²ã¼ã ãbotå士ã«æ¦ããã
ã³ã³ãã®è§£æ³ : https://www.kaggle.com/competitions/llm-20-questions/discussion/531106
詳細ã¯çç¥ããããè¤æ°ã® 7Bã8B ã¢ãã«ãæå ã§ãããã 400,000,000 å以ä¸æ¨è«ãããå¿ è¦ããã解æ³ãé¸æãããããèªå® ã® RTX 4090 1å°ã§ã¯å°åºè¨ç®ãªã½ã¼ã¹ã足ããªãã£ãã
ããã§ä¾ã®ãã¨ã RunPod 㧠GPU ã¤ã³ã¹ã¿ã³ã¹ãåãããã¨ã«ããã
ã³ã³ãçµäº2é±éåã§ã®è§£æ³é¸æã ã£ããããè´
沢㫠RTX 4090 ã8å°åºãã£ãã¤ã³ã¹ã¿ã³ã¹ãåãããã¨ã«ããã
$3/hour ã§æ¸ã£ã¦ããæ®é«ãè¦ãã®ã¯å¿ãå·ãã ããç¡äºã«1é±éç¨åº¦ã§å¿
è¦ãªæ¨è«ãçµäºãã$500ã®æ¯åºã§æ¸ãã ã
仮㫠GCP ã§åç¨åº¦ã®ã¤ã³ã¹ã¿ã³ã¹ãåãããã¨ããã¨4å以ä¸ã®ä¾¡æ ¼ã®ããã軽çã§æ¸ãã ã¨ãè¨ãããåªåè³éã§ååã§ããããã ãã
ã¾ã¨ã
Runpodã使ãã°ãå®ä¾¡ãã¤æ軽ã«GPUãªã½ã¼ã¹ã確ä¿ã§ããKaggleã®åçãå¼ãä¸ãããã¨ãã§ããã大æã¯ã©ã¦ãã«æ¯ã¹ã¦ç ´ç£ãªã¹ã¯ãå°ãªãã®ãè¯ãç¹ã§ããã
æ¬è¨äºã§ã¯ãKaggleåãã«Runpodã使ãéã®Tipsãç´¹ä»ãããç¹ã«ãStorageã®æ´»ç¨ããPoetryã使ã£ãPythonç°å¢ã®æ§ç¯ãSecretsæ©è½ã®æ´»ç¨ãªã©ã¯ãã¾ãæ å ±ãåºåã£ã¦ããªãã®ã§ã¯ãªããã¨æãã®ã§ãåèã«ãã¦ããã ããã°å¹¸ãã§ããã
ããä¸åº¦ãªãã¡ã©ã«ãªã³ã¯ãè²¼ã£ã¦ããã®ã§ããKaggle Runpod é¨(?)ãã¸ã®å ¥ä¼ããå¾ ã¡ãã¦ã¾ãã https://runpod.io?ref=6x122dhk
Kaggle - Qiita Advent Calendar 2024 - Qiitaã®9æ¥ç®ã®è¨äºã¯Runpodã®å¯¾æ馬ã§ããvast.aiã®è§£èª¬ããªããã¦ããã®ã§ãèå³ãããæ¹ã¯ãã¡ããåããã¦åç §ããããã