Giter Site home page Giter Site logo

tpu_experiment's Introduction

tpu_experiment

Repository for TPU Experiment

By Pytorch

  1. Download Imagenet data and save different directory per label. (like below)
├── train
│   ├── n01440764
│   ├── n01443537
│   ├── n01484850
│   ├── n01491361
│   ├── n01494475
|   :
|
└── val
    ├── n01440764
    ├── n01443537
    ├── n01484850
    ├── n01491361
    ├── n01494475
    :
  1. Create VM and TPU
  • Create VM which has many cpu cores by UI or CLI. (ex: n1-highmem-96)

    • Many cpus are important for only Pytorch.
  • Create TPU by UI or CLI at same zone where VM is created.

$ ctpu up --tpu-size=v3-8 --name=resnet-tutorial --preemptible --zone='us-central1-a' --tf-version=pytorch-nightly
  1. Pull docker image
$ dokcer pull gcr.io/tpu-pytorch/xla:nightly
  1. Set TPU_IP_ADDRESS (TPU internal IP Address)
$ export TPU_IP_ADDRESS=hogehoge
  1. RUN ImageNet training
  • by MultiProcessing
$ docker run --rm -it --shm-size 126G \
    -e XRT_TPU_CONFIG="tpu_worker;0;$TPU_IP_ADDRESS:8470" \
    -e XLA_USE_BF16=1 \
    -v $PWD/xla/test:/pytorch/xla/test \
    -v $PWD/input/imagenet/:/imagenet_data/ \
    -v $PWD/reports:/reports \
    -v ~/.config/gcloud:/root/.config/gcloud \
    --ipc=host \
    gcr.io/tpu-pytorch/xla:nightly \
    python /pytorch/xla/test/test_train_mp_imagenet.py --model resnet50 --datadir /imagenet_data/ --num_worker 24 --num_cores 8 --logdir ./reports --log_steps 200
  • by MultiThreading
$ docker run --rm -it --shm-size 126G \
    -e XRT_TPU_CONFIG="tpu_worker;0;$TPU_IP_ADDRESS:8470" \
    -e XLA_USE_BF16=1 \
    -v $PWD/xla/test:/pytorch/xla/test \
    -v $PWD/input/imagenet/:/imagenet_data/ \
    -v $PWD/reports:/reports \
    -v ~/.config/gcloud:/root/.config/gcloud \
    --ipc=host \
    gcr.io/tpu-pytorch/xla:nightly \
    python /pytorch/xla/test/test_train_imagenet.py --model resnet50 --datadir /imagenet_data/ --num_worker 24 --num_cores 8 --logdir ./reports --log_steps 200

By Tensorflow1.xx

  1. 1-2 is same above training by Pytorch.

    • VM dosen't need so many cpus like Pytorch. (ex: n1-standard-8)
  2. Create TFRecord. (Take long time...)

$ cd ./tpu/tools/datasets
$ python imagenet_to_gcs.py --raw_data_dir ./input/imagenet/raw_data --project [gcp-project-name] --gcs_output_path gs://hoge
  1. RUN ImageNet training
$ cd ./tpu/official/resnet
$ python resnet_main.py --tpu=resnet-tutorial --data_dir=gs://hoge/train --model_dir=gs://hoge/model --config_file=configs/cloud/v3-8.yaml

tpu_experiment's People

Contributors

shimacos37 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.