Skip to content

Commit da23386

Browse files
committed
Merge remote-tracking branch 'upstream/master' into mp
2 parents f68ecd6 + beb7e27 commit da23386

16 files changed

+206
-43
lines changed

.circleci/config.yml

+20-13
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,24 @@ install_official_git_client: &install_official_git_client
66
sudo apt-get -qq update
77
sudo apt-get -qq install openssh-client git
88
9+
# This system setup script is meant to run before the CI-related scripts, e.g.,
10+
# installing Git client, checking out code, setting up CI env, and
11+
# building/testing.
12+
setup_linux_system_environment: &setup_linux_system_environment
13+
name: Set Up System Environment
14+
no_output_timeout: "1h"
15+
command: |
16+
set -e
17+
# Set up CircleCI GPG keys for apt, if needed
18+
curl -L https://packagecloud.io/circleci/trusty/gpgkey | sudo apt-key add -
19+
920
pytorch_tutorial_build_defaults: &pytorch_tutorial_build_defaults
1021
machine:
1122
image: default
1223
steps:
1324
- checkout
25+
- run:
26+
<<: *setup_linux_system_environment
1427
- run:
1528
name: Set Up CI Environment
1629
no_output_timeout: "1h"
@@ -29,7 +42,8 @@ pytorch_tutorial_build_defaults: &pytorch_tutorial_build_defaults
2942
linux-image-generic \
3043
moreutils \
3144
nvidia-docker2 \
32-
expect-dev
45+
expect-dev \
46+
docker-ce=18.06.2~ce~3-0~ubuntu
3347
3448
sudo pkill -SIGHUP dockerd
3549
@@ -51,15 +65,8 @@ pytorch_tutorial_build_defaults: &pytorch_tutorial_build_defaults
5165
command: |
5266
set -e
5367
54-
# Get latest PyTorch docker image version
55-
curl -O https://raw.githubusercontent.com/pytorch/pytorch/master/.circleci/config.yml
56-
while read line; do
57-
if [[ "$line" == *PyTorchDockerVersion* ]]; then
58-
export pyTorchDockerImageTag=${line:23} # len("# PyTorchDockerVersion:") == 23
59-
echo "PyTorchDockerImageTag: "${pyTorchDockerImageTag}
60-
break
61-
fi
62-
done < config.yml
68+
export pyTorchDockerImageTag=291
69+
echo "PyTorchDockerImageTag: "${pyTorchDockerImageTag}
6370
6471
cat >/home/circleci/project/ci_build_script.sh <<EOL
6572
# =================== The following code will be executed inside Docker container ===================
@@ -107,14 +114,14 @@ pytorch_tutorial_build_defaults: &pytorch_tutorial_build_defaults
107114
108115
pytorch_tutorial_build_worker_defaults: &pytorch_tutorial_build_worker_defaults
109116
environment:
110-
DOCKER_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-cuda8-cudnn7-py3"
111-
CUDA_VERSION: "8"
117+
DOCKER_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-cuda9-cudnn7-py3"
118+
CUDA_VERSION: "9"
112119
resource_class: gpu.medium
113120
<<: *pytorch_tutorial_build_defaults
114121

115122
pytorch_tutorial_build_manager_defaults: &pytorch_tutorial_build_manager_defaults
116123
environment:
117-
DOCKER_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-cuda8-cudnn7-py3"
124+
DOCKER_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-cuda9-cudnn7-py3"
118125
resource_class: medium
119126
<<: *pytorch_tutorial_build_defaults
120127

.jenkins/build.sh

+13-14
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,6 @@ rm -rf src
1616
pip install -r $DIR/../requirements.txt
1717
pip uninstall -y torchvision || true
1818

19-
# Install a nightly build of pytorch
20-
21-
# GPU, requires CUDA version 8.0
22-
pip install cython torch_nightly -f https://download.pytorch.org/whl/nightly/cu80/torch_nightly.html
23-
24-
# GPU, requires CUDA version 9.0
25-
# pip install cython torch_nightly -f https://download.pytorch.org/whl/nightly/cu90/torch_nightly.html
26-
27-
# GPU, requires CUDA version 9.2
28-
# pip install cython torch_nightly -f https://download.pytorch.org/whl/nightly/cu92/torch_nightly.html
29-
30-
# CPU
31-
# pip install cython torch_nightly -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
32-
3319
export PATH=/opt/conda/bin:$PATH
3420
conda install -y sphinx==1.8.2 pandas
3521
# PyTorch Theme
@@ -53,11 +39,24 @@ popd
5339

5440
aws configure set default.s3.multipart_threshold 5120MB
5541

42+
if [[ $(pip show torch) ]]; then
43+
# Clean up previous PyTorch installations
44+
pip uninstall -y torch || true
45+
pip uninstall -y torch || true
46+
fi
47+
48+
# Install a nightly build of pytorch
49+
50+
# GPU, requires CUDA version 9.0
51+
pip install cython torch_nightly -f https://download.pytorch.org/whl/nightly/cu90/torch_nightly.html
52+
5653
# Decide whether to parallelize tutorial builds, based on $JOB_BASE_NAME
5754
export NUM_WORKERS=20
5855
if [[ "${JOB_BASE_NAME}" == *worker_* ]]; then
5956
# Step 1: Remove runnable code from tutorials that are not supposed to be run
6057
python $DIR/remove_runnable_code.py beginner_source/aws_distributed_training_tutorial.py beginner_source/aws_distributed_training_tutorial.py
58+
# TODO: Fix bugs in these tutorials to make them runnable again
59+
python $DIR/remove_runnable_code.py beginner_source/audio_classifier_tutorial.py beginner_source/audio_classifier_tutorial.py
6160

6261
# Step 2: Keep certain tutorials based on file count, and remove runnable code in all other tutorials
6362
# IMPORTANT NOTE: We assume that each tutorial has a UNIQUE filename.

_templates/layout.html

+68
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,73 @@
1212
ga('send', 'pageview');
1313

1414
</script>
15+
16+
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-117752657-2"></script>
17+
18+
<script>
19+
20+
window.dataLayer = window.dataLayer || [];
21+
22+
function gtag(){dataLayer.push(arguments);}
23+
24+
gtag('js', new Date());
25+
gtag('config', 'UA-117752657-2');
26+
27+
</script>
28+
29+
<script>
30+
!function(f,b,e,v,n,t,s)
31+
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
32+
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
33+
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
34+
n.queue=[];t=b.createElement(e);t.async=!0;
35+
t.src=v;s=b.getElementsByTagName(e)[0];
36+
s.parentNode.insertBefore(t,s)}(window,document,'script',
37+
'https://connect.facebook.net/en_US/fbevents.js');
38+
fbq('init', '243028289693773');
39+
fbq('track', 'PageView');
40+
41+
$("[data-behavior='call-to-action-event']").on('click', function(){
42+
fbq('trackCustom', "Download", {
43+
tutorialTitle: $('h1:first').text(),
44+
downloadLink: this.href,
45+
tutorialLink: window.location.href,
46+
downloadTitle: $(this).attr("data-response")
47+
});
48+
ga('send', {
49+
hitType: 'event',
50+
eventCategory: 'Download',
51+
eventAction: 'click',
52+
eventLabel: $(this).attr("data-response")
53+
});
54+
});
55+
56+
$("[data-behavior='was-this-helpful-event']").on('click', function(){
57+
$(".helpful-question").hide();
58+
$(".was-helpful-thank-you").show();
59+
fbq('trackCustom', "Was this Helpful?", {
60+
tutorialLink: window.location.href,
61+
tutorialTitle: $('h1:first').text(),
62+
helpful: $(this).attr("data-response")
63+
});
64+
ga('send', {
65+
hitType: 'event',
66+
eventCategory: 'Was this Helpful?',
67+
eventAction: 'click',
68+
eventLabel: $(this).attr("data-response")
69+
});
70+
});
71+
72+
if (location.pathname == "/") {
73+
$(".helpful-container").hide();
74+
$(".hr-bottom").hide();
75+
}
76+
</script>
77+
78+
<noscript>
79+
<img height="1" width="1"
80+
src="https://www.facebook.com/tr?id=243028289693773&ev=PageView
81+
&noscript=1"/>
82+
</noscript>
1583
<img height="1" width="1" style="border-style:none;" alt="" src="https://www.googleadservices.com/pagead/conversion/795629140/?label=txkmCPmdtosBENSssfsC&amp;guid=ON&amp;script=0"/>
1684
{% endblock %}

advanced_source/numpy_extensions_tutorial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
=========================================
55
**Author**: `Adam Paszke <https://github.com/apaszke>`_
66
7-
**Updated by**: `Adam Dziedzic` [https://github.com/adam-dziedzic](https://github.com/adam-dziedzic)
7+
**Updated by**: `Adam Dziedzic <https://github.com/adam-dziedzic>`_
88
99
In this tutorial, we shall go through two tasks:
1010

beginner_source/colab.rst

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
Using Tutorial Data from Google Drive in Colab
2+
==============================================
3+
4+
We've added a new feature to tutorials that allows users to open the
5+
notebook associated with a tutorial in Google Colab. You may need to
6+
copy data to your Google drive account to get the more complex tutorials
7+
to work.
8+
9+
In this example, we'll demonstrate how to change the notebook in Colab
10+
to work with the Chatbot Tutorial. To do this, you'll first need to be
11+
logged into Google Drive. (For a full description of how to access data
12+
in Colab, you can view their example notebook
13+
`here <https://colab.research.google.com/notebooks/io.ipynb#scrollTo=XDg9OBaYqRMd>`__.)
14+
15+
To get started open the `Chatbot
16+
Tutorial <https://pytorch.org/tutorials/beginner/chatbot_tutorial.html>`__
17+
in your browser.
18+
19+
At the top of the page click **Run in Google Colab**.
20+
21+
The file will open in Colab.
22+
23+
If you choose, **Runtime** then **Run All**, you'll get an error as the
24+
file can't be found.
25+
26+
To fix this, we'll copy the required file into our Google Drive account.
27+
28+
1. Log into Google Drive.
29+
2. In Google Drive, make a folder named **data**, with a subfolder named
30+
**cornell**.
31+
3. Visit the Cornell Movie Dialogs Corpus and download the ZIP file.
32+
4. Unzip the file on your local machine.
33+
5. Copy the file **movie\_lines.txt** to **data/cornell** folder you
34+
created in Google Drive.
35+
36+
Now we'll need to edit the file in\_ \_Colab to point to the file on
37+
Google Drive.
38+
39+
In Colab, add the following to top of the code section over the line
40+
that begins *corpus\_name*:
41+
42+
::
43+
44+
from google.colab import drive
45+
drive.mount('/content/gdrive')
46+
47+
Change the two lines that follow:
48+
49+
1. Change the **corpus\_name** value to **"cornell"**.
50+
2. Change the line that begins with **corpus** to this:
51+
52+
::
53+
54+
corpus = os.path.join("/content/gdrive/My Drive/data", corpus_name)
55+
56+
We're now pointing to the file we uploaded to Drive.
57+
58+
Now when you click on the **Run cell** button for the code section,
59+
you'll be prompted to authorize Google Drive and you'll get an
60+
authorization code. Paste the code into the prompt in Colab and you
61+
should be set.
62+
63+
Rerun the notebook from **Runtime** / **Run All** menu command and
64+
you'll see it process. (Note that this tutorial takes a long time to
65+
run.)
66+
67+
Hopefully this example will give you a good starting point for running
68+
some of the more complex tutorials in Colab. As we evolve our use of
69+
Colab on the PyTorch tutorials site, we'll look at ways to make this
70+
easier for users.

beginner_source/data_loading_tutorial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def show_landmarks(image, landmarks):
111111
# stored in the memory at once but read as required.
112112
#
113113
# Sample of our dataset will be a dict
114-
# ``{'image': image, 'landmarks': landmarks}``. Our datset will take an
114+
# ``{'image': image, 'landmarks': landmarks}``. Our dataset will take an
115115
# optional argument ``transform`` so that any required processing can be
116116
# applied on the sample. We will see the usefulness of ``transform`` in the
117117
# next section.

beginner_source/dcgan_faces_tutorial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
# :math:`D` will predict its outputs are fake (:math:`log(1-D(G(x)))`).
7575
# From the paper, the GAN loss function is
7676
#
77-
# .. math:: \underset{G}{\text{min}} \underset{D}{\text{max}}V(D,G) = \mathbb{E}_{x\sim p_{data}(x)}\big[logD(x)\big] + \mathbb{E}_{z\sim p_{z}(z)}\big[log(1-D(G(x)))\big]
77+
# .. math:: \underset{G}{\text{min}} \underset{D}{\text{max}}V(D,G) = \mathbb{E}_{x\sim p_{data}(x)}\big[logD(x)\big] + \mathbb{E}_{z\sim p_{z}(z)}\big[log(1-D(G(z)))\big]
7878
#
7979
# In theory, the solution to this minimax game is where
8080
# :math:`p_g = p_{data}`, and the discriminator guesses randomly if the

beginner_source/former_torchies/README.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
Autograd
1010
https://pytorch.org/tutorials/beginner/former_torchies/autograd_tutorial_old.html
1111

12-
3. nn_tutorial.py
12+
3. nnft_tutorial.py
1313
nn package
14-
https://pytorch.org/tutorials/beginner/former_torchies/nn_tutorial.html
14+
https://pytorch.org/tutorials/beginner/former_torchies/nnft_tutorial.html
1515

1616
4. parallelism_tutorial.py
1717
Multi-GPU examples

beginner_source/former_torchies/parallelism_tutorial.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
One can wrap a Module in ``DataParallel`` and it will be parallelized
1212
over multiple GPUs in the batch dimension.
1313
14+
1415
DataParallel
1516
-------------
1617
"""
@@ -41,7 +42,20 @@ def forward(self, x):
4142
#
4243
# The documentation for DataParallel can be found
4344
# `here <https://pytorch.org/docs/nn.html#dataparallel>`_.
44-
#
45+
#
46+
# **Attributes of the wrapped module**
47+
#
48+
# After wrapping a Module with ``DataParallel``, the attributes of the module
49+
# (e.g. custom methods) became inaccessible. This is because ``DataParallel``
50+
# defines a few new members, and allowing other attributes might lead to
51+
# clashes in their names. For those who still want to access the attributes,
52+
# a workaround is to use a subclass of ``DataParallel`` as below.
53+
54+
class MyDataParallel(nn.DataParallel):
55+
def __getattr__(self, name):
56+
return getattr(self.module, name)
57+
58+
########################################################################
4559
# **Primitives on which DataParallel is implemented upon:**
4660
#
4761
#

beginner_source/former_torchies_tutorial.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ In this tutorial, you will learn the following:
1919

2020
/beginner/former_torchies/tensor_tutorial_old
2121
/beginner/former_torchies/autograd_tutorial_old
22-
/beginner/former_torchies/nn_tutorial
22+
/beginner/former_torchies/nnft_tutorial
2323
/beginner/former_torchies/parallelism_tutorial
2424

2525
.. galleryitem:: /beginner/former_torchies/tensor_tutorial_old.py
2626
:figure: /_static/img/tensor_illustration_flat.png
2727

2828
.. galleryitem:: /beginner/former_torchies/autograd_tutorial_old.py
2929

30-
.. galleryitem:: /beginner/former_torchies/nn_tutorial.py
30+
.. galleryitem:: /beginner/former_torchies/nnft_tutorial.py
3131
:figure: /_static/img/torch-nn-vs-pytorch-nn.png
3232

3333
.. galleryitem:: /beginner/former_torchies/parallelism_tutorial.py

beginner_source/nlp/word_embeddings_tutorial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
.. math::
9494
9595
\text{Similarity}(\text{physicist}, \text{mathematician}) = \frac{q_\text{physicist} \cdot q_\text{mathematician}}
96-
{\| q_\text{\physicist} \| \| q_\text{mathematician} \|} = \cos (\phi)
96+
{\| q_\text{physicist} \| \| q_\text{mathematician} \|} = \cos (\phi)
9797
9898
Where :math:`\phi` is the angle between the two vectors. That way,
9999
extremely similar words (words whose embeddings point in the same

beginner_source/nn_tutorial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77
###############################################################################
88
# We recommend running this tutorial as a notebook, not a script. To download the notebook (.ipynb) file,
9-
# click `here <https://pytorch.org/tutorials/beginner/nn_tutorial.html#sphx-glr-download-beginner-nn-tutorial-py>`_ .
9+
# click the link at the top of the page.
1010
#
1111
# PyTorch provides the elegantly designed modules and classes `torch.nn <https://pytorch.org/docs/stable/nn.html>`_ ,
1212
# `torch.optim <https://pytorch.org/docs/stable/optim.html>`_ ,

index.rst

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ starting point, and provides a broad view into how to use PyTorch from the basic
77

88
Some considerations:
99

10+
* We’ve added a new feature to tutorials that allows users to open the notebook associated with a tutorial in Google Colab.
11+
Visit `this page <https://pytorch.org/tutorials/beginner/colab.html>`_ for more information.
1012
* If you would like to do the tutorials interactively via IPython / Jupyter,
1113
each tutorial has a download link for a Jupyter Notebook and Python source code.
1214
* Additional high-quality examples are available, including image classification,

0 commit comments

Comments
 (0)