# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# + [markdown] id="SxK5ABsgH0_l"
# [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/vsalavatov/pytorch_resnet_cifar10/blob/master/ResNet_20_Consensus_Notebook.ipynb)

# + colab={"base_uri": "https://localhost:8080/"} id="yFFp5gyHfMMc" outputId="9a3dd3bf-d1b8-4252-d0ad-4ebf63b327b1"
# ! apt-get install python3.7 python3.7-dev gcc
# ! curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
# ! python3.7 get-pip.py

# + colab={"base_uri": "https://localhost:8080/"} id="jCTd2vMPgbT6" outputId="c1840eb1-02a1-44bd-ff56-6077710b459d"
# %cd /content
# ! rm -rf pytorch_resnet_cifar10

# + colab={"base_uri": "https://localhost:8080/"} id="qgn5deKGhMVp" outputId="4759bde2-0e80-45b6-915b-66d96735bcb1"
# ! git clone https://github.com/vsalavatov/pytorch_resnet_cifar10 --recursive
# %cd pytorch_resnet_cifar10
# ! echo '' > distributed-learning/utils/__init__.py

# + colab={"base_uri": "https://localhost:8080/"} id="jC2Vo9ItT_Lv" outputId="a7aeecc0-a634-4a6b-f1a6-3f4702cbfd5f"
# ! pip3 install -r requirements.txt

# + colab={"base_uri": "https://localhost:8080/"} id="DuwYH3MZUkF9" outputId="66cb30fa-e6f2-47ef-c56a-286e0e010c57"
# ! cd distributed-learning && pip3 install -r requirements.txt

# + colab={"base_uri": "https://localhost:8080/"} id="0aeJBjMn9t7b" outputId="c89305e6-ca03-4936-d06c-4ba29a0e7530"
# ! pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html

# + colab={"base_uri": "https://localhost:8080/"} id="_kxqddVV0Qwa" outputId="8c50725c-f157-429c-c359-ba70e8b9b3e1"
# ! pip install cvxpy

# + colab={"base_uri": "https://localhost:8080/"} id="VcgJqAKKqGPE" outputId="11b7e954-810f-4ca4-f2e0-b6d1eb1ddaf2"
import os
os.environ['CHECKPOINT_PATH'] = './data'
# ! echo $CHECKPOINT_PATH

# + [markdown] id="NtMkNOfyp4O0"
# # If you want to connect GDrive to store checkpoints, run this

# + colab={"base_uri": "https://localhost:8080/"} id="wjUsXBtWoqHp" outputId="f21c2246-23cc-4db5-b6d8-c85f250a6acd"
from google.colab import drive
drive.mount('/content/gdrive')

# + colab={"base_uri": "https://localhost:8080/"} id="FKn-UiNPo5Or" outputId="f4b98f7d-5414-451c-81d5-77bf35160548"
# DO NOT FORGET TO MODIFY THE PATH
import os
os.environ['CHECKPOINT_PATH'] = '/content/gdrive/MyDrive/' + 'resnet20-plain-consensus-batch32-k5-freq=1/'
# ! echo $CHECKPOINT_PATH

# + [markdown] id="-lBPzgw3qEq7"
# # Training stage
#

# + colab={"base_uri": "https://localhost:8080/"} id="p8PsmE2E-Efy" outputId="d67028ca-daad-4d91-9af8-162a22f1e931"
# !nvidia-smi

# + colab={"base_uri": "https://localhost:8080/"} id="MF4Saa01UK1F" outputId="6480b219-f89f-4061-c210-fce88df10d6a"
# %cd /content/pytorch_resnet_cifar10/

# + colab={"base_uri": "https://localhost:8080/"} id="ipow8BmiN3Mo" outputId="1e2a39b2-0feb-4ce3-cee7-9b0d88305749"
# ! python3.7 prepare_agent_datasets.py -n 5

# + colab={"base_uri": "https://localhost:8080/"} id="YvXHKpNwCRCa" outputId="c701cf5e-7225-49bd-c175-dce832e1294f"
# !pkill -9 -f python3\.7.*
# %cd /content/pytorch_resnet_cifar10/

# + colab={"base_uri": "https://localhost:8080/"} id="oqdAF6Hgf2oX" outputId="e8c82599-98eb-4be5-9729-800f6efba626"
# check out "run_consensus.py --help" to see customizable options

# ! python3.7 run_consensus.py -n 5 --topology mesh --validation-agents 0,3 

# + id="BhRqL97xwmtD"
# ! ps -aux

StarcoderdataJupyterScriptsDedupFiltered