|
| 1 | +Installation in the Google Colaboratory environment |
| 2 | +=================================================== |
| 3 | + |
| 4 | +If you want to install TC in a Google Colaboratory environment, copy/paste and run |
| 5 | +the following code in the notebook. Please note, it will take 2-3 minutes to execute. |
| 6 | + |
| 7 | +Step 1: Create new Notebook in the Google Research Colaboratory |
| 8 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 9 | + |
| 10 | +Open https://colab.research.google.com/ , create a new notebook and switch Runtime to GPU. |
| 11 | + |
| 12 | +Step 2: Create a new Code Cell, with the following code |
| 13 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 14 | + |
| 15 | +.. code-block:: python |
| 16 | +
|
| 17 | + !wget -c https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh |
| 18 | + !chmod +x Anaconda3-5.1.0-Linux-x86_64.sh |
| 19 | + !bash ./Anaconda3-5.1.0-Linux-x86_64.sh -b -f -p /usr/local |
| 20 | + !conda install -q -y --prefix /usr/local -c pytorch -c tensorcomp tensor_comprehensions |
| 21 | + |
| 22 | + import sys |
| 23 | + sys.path.append('/usr/local/lib/python3.6/site-packages/') |
| 24 | + |
| 25 | +Step 3: Use TC normally, from Python/Torch environment |
| 26 | +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 27 | + |
| 28 | +As an example, paste and execute the following code in a new Code Cell: |
| 29 | + |
| 30 | +.. code-block:: python |
| 31 | +
|
| 32 | + import tensor_comprehensions as tc |
| 33 | + import torch |
| 34 | + lang = """ |
| 35 | + def matmul(float(M, K) A, float(K, N) B) -> (C) { |
| 36 | + C(m, n) +=! A(m, r_k) * B(r_k, n) |
| 37 | + } |
| 38 | + """ |
| 39 | + matmul = tc.define(lang, name="matmul") |
| 40 | + mat1, mat2 = torch.randn(3, 4).cuda(), torch.randn(4, 5).cuda() |
| 41 | + out = matmul(mat1, mat2) |
0 commit comments