Skip to content

Code samples using features from PyTorch's Lazy Tensor Core

Notifications You must be signed in to change notification settings

ramiro050/lazy-tensor-samples

Repository files navigation

lazy-tensor-samples

Table of Contents

Table of contents generated with markdown-toc

How to Run Examples

Install Torchvision and Lazy Tensor Core

Install torchvision:

python -m pip install torchvision
python -m pip uninstall torch # if it was automatically installed by torchvision

Install the lazy-tensor-core Python package by following their instructions.

Update PYTHONPATH:

export PYTHONPATH=/path/to/pytorch/lazy_tensor_core:$PYTHONPATH

Bert

Setup

First install Lazy Tensor Core.

Install the following Python packages:

python -m pip transformers datasets

Running Example

From inside the lazy-tensor-samples directory, run:

python lazytensor_bert_example.py

The output of this example can be found in lazytensor_bert_example_output.txt.

MaskRCNN

Setup

First install Torchvision and Lazy Tensor Core.

Install the maskrcnn-benchmark using my fork, which includes some changes to make the benchmark run on LTC:

git clone https://github.com/ramiro050/maskrcnn-benchmark.git
cd maskrcnn-benchmark
git checkout lazy-tensor-maskrcnn

Follow the maskrcnn-benchmark installation instructions.

Update PYTHONPATH:

export PYTHONPATH=/path/to/maskrcnn-benchmark/demo:$PYTHONPATH

Running Example

From inside the lazy-tensor-samples directory, run:

python lazytensor_maskrcnn_example.py path/to/image.png path/to/maskrcnn-benchmark

where img.png is the image to run the model on.

The output of this example can be found in lazytensor_maskrcnn_example_output.txt.

Resnet-18 Inference and Training

Setup

First install Torchvision and Lazy Tensor Core.

Additional steps for Inference

Install the following Python packages:

python -m pip install pillow request

Additional steps for Training

Install the library libsndfile. On Ubuntu, simply run

sudo apt-get install libsndfile-dev

Install the PyTorch benchmarks using my fork, which includes some changes to make the benchmark run on LTC (the changes are based on this patch by @alanwaketan):

git clone https://github.com/ramiro050/benchmark.git
cd benchmark
git checkout lazytensor_support

Then follow these instructions to install the benchmark.

Running Inference Example

From inside the lazy-tensor-samples directory, run:

python lazytensor_resnet18_example.py

The output of this example can be found in lazytensor_resnet18_example_output.txt.

Running Training Example

From inside the benchmark directory, run:

python run.py resnet18 -d lazy -t train

About

Code samples using features from PyTorch's Lazy Tensor Core

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages