Skip to content

Latest commit

 

History

History
71 lines (61 loc) · 1.96 KB

environment_colab.md

File metadata and controls

71 lines (61 loc) · 1.96 KB

Colab Setup

  1. 获取源码与运行环境

    # %%capture
    
    # 安装/更新依赖
    %pip uninstall -y torchvision torchaudio torchdata torchtext fastai
    %pip install torch_geometric
    %pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-$(python -c "import torch; print(torch.__version__)").html
    %pip install torchmetrics
    %pip install torchinfo
    %pip install pympler
    %pip install -U mlxtend
    %pip install pyyaml
    %pip install colorama
    %pip install SciencePlots
    %pip install powerlaw
    
    # 导入脚本
    try:
        import training_engine
    except:
        print("[INFO] Couldn't find going_modular scripts... downloading them from GitHub.")
        !git clone https://github.com/HenryJi529/KeyNodeFinder
        !mv KeyNodeFinder/* ./
        !rm -rf KeyNodeFinder
        print("[INFO] Finish downloading...")
    
    # 挂载Google Drive
    from google.colab import drive
    drive.mount('/content/drive')
    
    # 清理Jupyter Cell
    from IPython.display import clear_output
    clear_output()
  2. 启动tensorboard

    # Let's view our experiments within TensorBoard from within the notebook
    %load_ext tensorboard
    %tensorboard --logdir drive/MyDrive/KeyNodeFinder/logs
    # !pkill -f tensorboard # kill the tensorboard instance if it's still running
  3. 公开tensorboard到: http://server.morningstar369.com:16006

    # 获取frpc
    !wget -q -c https://github.com/fatedier/frp/releases/download/v0.52.3/frp_0.52.3_linux_amd64.tar.gz
    !tar -xf frp_*
    !rm frp_*.gz
    !mv frp_*/frpc ./
    
    # 配置frpc
    config = """
    serverAddr = "server.morningstar369.com"
    
    [[proxies]]
    name = "tensorboard-colab"
    type = "tcp"
    localIP = "0.0.0.0"
    localPort = 6006
    remotePort = 16006
    """
    with open("frpc.toml", "w") as file:
        file.write(config)
    
    # 启动frpc
    !./frpc -c ./frpc.toml &