Difference between revisions of "Graphcore Github Code Examples"

From Define Wiki
Jump to navigation Jump to search
(Created page with "= Initial Setup = == Clone the Graphcore Git repo == At a location of your choosing, clone the Graphcore repo: <pre> ipuuser@ipu-host-3:~$ git clone https://github.com/graphco...")
 
(No difference)

Latest revision as of 22:31, 2 February 2021

Initial Setup

Clone the Graphcore Git repo

At a location of your choosing, clone the Graphcore repo:

ipuuser@ipu-host-3:~$ git clone https://github.com/graphcore/examples

Virtual Environment

It is advised to run python codes from within a virtual environment (called pop torch_test in this example):

ipuuser@ipu-host-3:~$ virtualenv -p python3 poptorch_test
Already using interpreter /usr/bin/python3
Using base prefix '/usr'
New python executable in /home/ipuuser/poptorch_test/bin/python3
Also creating executable in /home/ipuuser/poptorch_test/bin/python
Installing setuptools, pkg_resources, pip, wheel...done.

BERT

  • Source your virtual environment:
ipuuser@ipu-host-3:~$ source poptorch_test/bin/activate
(poptorch_test) ipuuser@ipu-host-3:~$
  • Install the pop torch wheel:
(poptorch_test) ipuuser@ipu-host-3:~$ pip install poplar_sdk-ubuntu_18_04-1.4.0+365-665f971c8f/poptorch-1.0.0+5352+e86081acc9+ubuntu_18_04-cp36-cp36m-linux_x86_64.whl 
Processing ./poplar_sdk-ubuntu_18_04-1.4.0+365-665f971c8f/poptorch-1.0.0+5352+e86081acc9+ubuntu_18_04-cp36-cp36m-linux_x86_64.whl
Collecting torch@ https://download.pytorch.org/whl/cpu/torch-1.6.0%2Bcpu-cp36-cp36m-linux_x86_64.whl
  Downloading https://download.pytorch.org/whl/cpu/torch-1.6.0%2Bcpu-cp36-cp36m-linux_x86_64.whl (154.6 MB)
     |████████████████████████████████| 154.6 MB 55 kB/s 
Collecting future
  Using cached future-0.18.2.tar.gz (829 kB)
Collecting numpy
  Downloading numpy-1.19.5-cp36-cp36m-manylinux2010_x86_64.whl (14.8 MB)
     |████████████████████████████████| 14.8 MB 10.5 MB/s 
Building wheels for collected packages: future
  Building wheel for future (setup.py) ... done
  Created wheel for future: filename=future-0.18.2-py3-none-any.whl size=491059 sha256=a205f403c6972aa0df8ab84113967b7731bb2a664cf174a9c8fff6cd7703f775
  Stored in directory: /home/ipuuser/.cache/pip/wheels/6e/9c/ed/4499c9865ac1002697793e0ae05ba6be33553d098f3347fb94
Successfully built future
Installing collected packages: numpy, future, torch, poptorch
Successfully installed future-0.18.2 numpy-1.19.5 poptorch-1.0.0+5352 torch-1.6.0+cpu
  • Change to the BERT directory:
(poptorch_test) ipuuser@ipu-host-3:~$ cd /home/ipuuser/Downloads/examples/code_examples/pytorch/bert
  • Install the requirements:
(poptorch_test) ipuuser@ipu-host-3:~/Downloads/examples/code_examples/pytorch/bert$ python3 -m pip install -r requirements.txt 
Collecting transformers==2.11
  Using cached transformers-2.11.0-py3-none-any.whl (674 kB)
Requirement already satisfied: torch==1.6.0 in /home/ipuuser/poptorch_test/lib/python3.6/site-packages (from -r requirements.txt (line 2)) (1.6.0+cpu)
Requirement already satisfied: numpy in /home/ipuuser/poptorch_test/lib/python3.6/site-packages (from torch==1.6.0->-r requirements.txt (line 2)) (1.19.5)
Requirement already satisfied: future in /home/ipuuser/poptorch_test/lib/python3.6/site-packages (from torch==1.6.0->-r requirements.txt (line 2)) (0.18.2)
Collecting tqdm>=4.27
  Using cached tqdm-4.56.0-py2.py3-none-any.whl (72 kB)
Collecting filelock
  Using cached filelock-3.0.12-py3-none-any.whl (7.6 kB)
Collecting requests
  Using cached requests-2.25.1-py2.py3-none-any.whl (61 kB)
Collecting tokenizers==0.7.0
  Using cached tokenizers-0.7.0-cp36-cp36m-manylinux1_x86_64.whl (3.8 MB)
Collecting sentencepiece
  Downloading sentencepiece-0.1.95-cp36-cp36m-manylinux2014_x86_64.whl (1.2 MB)
     |████████████████████████████████| 1.2 MB 8.7 MB/s 
Collecting regex!=2019.12.17
  Downloading regex-2020.11.13-cp36-cp36m-manylinux2014_x86_64.whl (723 kB)
     |████████████████████████████████| 723 kB 52.4 MB/s 
Collecting packaging
  Using cached packaging-20.8-py2.py3-none-any.whl (39 kB)
Collecting dataclasses
  Using cached dataclasses-0.8-py3-none-any.whl (19 kB)
Collecting sacremoses
  Using cached sacremoses-0.0.43.tar.gz (883 kB)
Collecting pyparsing>=2.0.2
  Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Collecting idna<3,>=2.5
  Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Collecting certifi>=2017.4.17
  Using cached certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
Collecting chardet<5,>=3.0.2
  Using cached chardet-4.0.0-py2.py3-none-any.whl (178 kB)
Collecting urllib3<1.27,>=1.21.1
  Using cached urllib3-1.26.3-py2.py3-none-any.whl (137 kB)
Collecting six
  Using cached six-1.15.0-py2.py3-none-any.whl (10 kB)
Collecting click
  Using cached click-7.1.2-py2.py3-none-any.whl (82 kB)
Collecting joblib
  Using cached joblib-1.0.0-py3-none-any.whl (302 kB)
Building wheels for collected packages: sacremoses
  Building wheel for sacremoses (setup.py) ... done
  Created wheel for sacremoses: filename=sacremoses-0.0.43-py3-none-any.whl size=893258 sha256=01fff2a61df84167df6fdf0754596381e974782aeb1835565df2c8758672dc05
  Stored in directory: /home/ipuuser/.cache/pip/wheels/49/25/98/cdea9c79b2d9a22ccc59540b1784b67f06b633378e97f58da2
Successfully built sacremoses
Installing collected packages: urllib3, tqdm, six, regex, pyparsing, joblib, idna, click, chardet, certifi, tokenizers, sentencepiece, sacremoses, requests, packaging, filelock, dataclasses, transformers
Successfully installed certifi-2020.12.5 chardet-4.0.0 click-7.1.2 dataclasses-0.8 filelock-3.0.12 idna-2.10 joblib-1.0.0 packaging-20.8 pyparsing-2.4.7 regex-2020.11.13 requests-2.25.1 sacremoses-0.0.43 sentencepiece-0.1.95 six-1.15.0 tokenizers-0.7.0 tqdm-4.56.0 transformers-2.11.0 urllib3-1.26.3