PyTorch is a Python package that provides two high-level features:
-
Tensor computation (like NumPy) with strong GPU acceleration
-
Deep neural networks built on a tape-based autograd system
For the previous step we will need a GCP account. It’s free.
$ wget https://raw.githubusercontent.com/makramjandar/AwesomeScripts/master/gcs/gcp_vm_instantiation.sh && bash gcp_vm_instantiation.sh
Once the VM has been deployed, we can login into it from Google Cloud Shell: $ gcloud compute --project $PROJECT_ID ssh --zone $ZONE $MACHINE_NAME
$ wget -O - -q "https://raw.githubusercontent.com/makramjandar/AwesomeScripts/master/bash/install-nvidia.sh" | bash
When building anything, it’s safer to do it in a conda environment lest you mess up and pollute your system environment. $ wget -O - -q 'https://raw.githubusercontent.com/makramjandar/AwesomeScripts/master/bash/install-anaconda.sh' | bash
$ wget https://raw.githubusercontent.com/makramjandar/AwesomeScripts/master/bash/build-pytorch.sh && bash build-pytorch.sh cuda
$ wget https://raw.githubusercontent.com/makramjandar/AwesomeScripts/master/bash/build-pytorch.sh && bash build-pytorch.sh
Still under the pytorch-build environment, let’s run some examples to make sure your installation is correct.
Build the torchvision library from source.
cd ~ && git https://github.com/pytorch/vision.git && python ~/setup.py install
Install tqdm (a dependency for downloading torchvision datasets) with pip in order to run the MNIST example.
pip install tqdm
Now download the examples and run MNIST:
cd ~ && git clone https://github.com/pytorch/examples.git && /examples/mnist/python/main.py
Voilà!!!
PyTorch is BSD-style licensed, as found in the LICENSE file.