{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"# Train MAE on Kaggle","metadata":{}},{"cell_type":"markdown","source":"## 1. Clone the repo\n- https://github.com/thinh-re/mae","metadata":{}},{"cell_type":"code","source":"#@title\n\nimport os, sys\n\ndef clone_or_pull_repo():\n    if os.path.isdir(repo_dir_path):\n        %cd $repo_dir_path\n        !git pull\n    else:\n        %cd $root_dir\n        !git clone https://github.com/thinh-re/mae mae\n        %cd $repo_dir_path\n\nroot_dir = '/kaggle/working'\nrepo_dir_path = os.path.join(root_dir, 'mae')\nclone_or_pull_repo()","metadata":{"_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## 2. Setup \n- Install Python3.10, venv (Virtual ENVironment), Pytorch, and required packages in `requirements.txt`\n- ... It will take a while !","metadata":{}},{"cell_type":"code","source":"!bash ./setup_python3_10.sh","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"markdown","source":"## 3. Start training\n- Set number of GPUs by parameter `nproc_per_node=2` (GPUs T4x2)\n- Set experiment name shown in Wandb.ai","metadata":{}},{"cell_type":"code","source":"clone_or_pull_repo()\n!./env/bin/torchrun --nnodes=1 --nproc_per_node=2 main_pretrain.py \\\n    --name v1.0.2 \\\n    --batch_size 130 \\\n    --model mae_vit_base_patch16 \\\n    --norm_pix_loss True \\\n    --mask_ratio 0.75 \\\n    --epochs 800 \\\n    --warmup_epochs 40 \\\n    --blr 1.5e-4 --weight_decay 0.05 \\\n    --data_path /kaggle/input/maev1","metadata":{"trusted":true},"execution_count":null,"outputs":[]}]}