Skip to content

Commit

Permalink
Merge branch 'master' into change_conv_size
Browse files Browse the repository at this point in the history
  • Loading branch information
holly1238 authored Apr 26, 2021
2 parents 5850ed3 + 03341a2 commit 479ea7c
Show file tree
Hide file tree
Showing 144 changed files with 12,906 additions and 3,977 deletions.
34 changes: 30 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pytorch_tutorial_build_defaults: &pytorch_tutorial_build_defaults
sudo pip -q install awscli==1.16.35
if [ -n "${CUDA_VERSION}" ]; then
DRIVER_FN="NVIDIA-Linux-x86_64-440.59.run"
DRIVER_FN="NVIDIA-Linux-x86_64-460.39.run"
wget "https://s3.amazonaws.com/ossci-linux/nvidia_driver/$DRIVER_FN"
sudo /bin/bash "$DRIVER_FN" -s --no-drm || (sudo cat /var/log/nvidia-installer.log && false)
nvidia-smi
Expand All @@ -116,13 +116,15 @@ pytorch_tutorial_build_defaults: &pytorch_tutorial_build_defaults
export AWS_ACCESS_KEY_ID=${CIRCLECI_AWS_ACCESS_KEY_FOR_ECR_READ_ONLY}
export AWS_SECRET_ACCESS_KEY=${CIRCLECI_AWS_SECRET_KEY_FOR_ECR_READ_ONLY}
eval $(aws ecr get-login --region us-east-1 --no-include-email)
- restore_cache:
key: v1.0-tutorial-{{ .Environment.CIRCLE_JOB }}
- run:
name: Build
no_output_timeout: "20h"
command: |
set -e
export pyTorchDockerImageTag=291
export pyTorchDockerImageTag=9de29bef4a5dc0dd1dd19428d83e5a66a44a1ed2
echo "PyTorchDockerImageTag: "${pyTorchDockerImageTag}
cat >/home/circleci/project/ci_build_script.sh \<<EOL
Expand Down Expand Up @@ -164,21 +166,45 @@ pytorch_tutorial_build_defaults: &pytorch_tutorial_build_defaults
fi
set -x
# This also copies the cached build to docker.
docker cp /home/circleci/project/. "$id:/var/lib/jenkins/workspace"
export COMMAND='((echo "source ./workspace/env" && echo "sudo chown -R jenkins workspace && cd workspace && ./ci_build_script.sh") | docker exec -u jenkins -i "$id" bash) 2>&1'
echo ${COMMAND} > ./command.sh && unbuffer bash ./command.sh | ts
# Copy the last build from docker
docker cp "$id:/var/lib/jenkins/workspace/_build" /home/circleci/project
docker cp "$id:/var/lib/jenkins/workspace/docs" /home/circleci/project
docker cp "$id:/var/lib/jenkins/workspace/advanced" /home/circleci/project
docker cp "$id:/var/lib/jenkins/workspace/beginner" /home/circleci/project
docker cp "$id:/var/lib/jenkins/workspace/intermediate" /home/circleci/project
docker cp "$id:/var/lib/jenkins/workspace/prototype" /home/circleci/project
docker cp "$id:/var/lib/jenkins/workspace/recipes" /home/circleci/project
docker cp "$id:/var/lib/jenkins/workspace/src" /home/circleci/project
- save_cache:
# Save to cache for incremental build
key: v1.0-tutorial-{{ .Environment.CIRCLE_JOB }}
paths:
- /home/circleci/project/_build
- /home/circleci/project/docs
- /home/circleci/project/advanced
- /home/circleci/project/beginner
- /home/circleci/project/intermediate
- /home/circleci/project/prototype
- /home/circleci/project/recipes
- /home/circleci/project/src

pytorch_tutorial_build_worker_defaults: &pytorch_tutorial_build_worker_defaults
environment:
DOCKER_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-cuda9-cudnn7-py3"
DOCKER_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-cuda10.2-cudnn7-py3-gcc7"
CUDA_VERSION: "9"
resource_class: gpu.medium
<<: *pytorch_tutorial_build_defaults

pytorch_tutorial_build_manager_defaults: &pytorch_tutorial_build_manager_defaults
environment:
DOCKER_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-cuda9-cudnn7-py3"
DOCKER_IMAGE: "308535385114.dkr.ecr.us-east-1.amazonaws.com/pytorch/pytorch-linux-xenial-cuda10.2-cudnn7-py3-gcc7"
resource_class: medium
<<: *pytorch_tutorial_build_defaults

Expand Down
18 changes: 12 additions & 6 deletions .circleci/scripts/build_for_windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ eval "$(conda shell.bash hook)"
conda create -qyn testenv python=3.7
conda activate testenv

conda install sphinx
pip install sphinx_gallery==0.3.1 sphinx-copybutton flask pandas spacy ipython scipy pySoundFile scikit-image
pip install -e git+git://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
pip install ray[tune] tabulate
conda install -yq -c pytorch "cudatoolkit=10.1" pytorch torchvision torchtext
conda install torchaudio -c pytorch-test
REQUIREMENTS="$(grep -v '^ *#\|^torch\|^torchaudio\|^torchvision|^torchtext' $PROJECT_DIR/requirements.txt | grep .)"
echo $REQUIREMENTS > requirements.txt
pip install -r requirements.txt
pip install pySoundFile
# Force uninstall torch & related packages, we'll install them using conda later.
pip uninstall -y torch torchvision torchtext
conda install -yq -c pytorch "cudatoolkit=10.1" pytorch torchvision torchtext torchaudio
python -m spacy download de
python -m spacy download en
pushd ${PROJECT_DIR}
Expand All @@ -47,6 +48,11 @@ if [[ "${CIRCLE_JOB}" == *worker_* ]]; then
python $DIR/remove_runnable_code.py intermediate_source/model_parallel_tutorial.py intermediate_source/model_parallel_tutorial.py || true
python $DIR/remove_runnable_code.py advanced_source/static_quantization_tutorial.py advanced_source/static_quantization_tutorial.py || true
python $DIR/remove_runnable_code.py beginner_source/hyperparameter_tuning_tutorial.py beginner_source/hyperparameter_tuning_tutorial.py || true
python $DIR/remove_runnable_code.py beginner_source/audio_preprocessing_tutorial.py beginner_source/audio_preprocessing_tutorial.py || true
python $DIR/remove_runnable_code.py beginner_source/dcgan_faces_tutorial.py beginner_source/dcgan_faces_tutorial.py || true
python $DIR/remove_runnable_code.py intermediate_source/tensorboard_profiler_tutorial.py intermediate_source/tensorboard_profiler_tutorial.py || true
# Temp remove for mnist download issue. (Re-enabled for 1.8.1)
# python $DIR/remove_runnable_code.py beginner_source/fgsm_tutorial.py beginner_source/fgsm_tutorial.py || true

export WORKER_ID=$(echo "${CIRCLE_JOB}" | tr -dc '0-9')
count=0
Expand Down
8 changes: 8 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM mcr.microsoft.com/vscode/devcontainers/python:3.8

COPY requirements.txt /tmp/pip-tmp/

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get install git gcc unzip make -y \
&& pip3 install --disable-pip-version-check --no-cache-dir -r /tmp/pip-tmp/requirements.txt \
&& rm -rf /tmp/pip-tmp
18 changes: 18 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "PyTorch Tutorials",
"build": {
"context": "..",
"dockerfile": "Dockerfile",
"args": {}
},
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"workbench.startupEditor": "none",
"files.autoSave": "afterDelay",
"python.dataScience.enabled": true,
"python.dataScience.alwaysTrustNotebooks": true,
"python.insidersChannel": "weekly",
"python.showStartPage": false
},
"extensions": ["ms-python.python", "lextudio.restructuredtext"]
}
31 changes: 31 additions & 0 deletions .devcontainer/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Refer to ./jenkins/build.sh for tutorial build instructions

sphinx==1.8.2
sphinx-gallery==0.3.1
tqdm
numpy
matplotlib
torch
torchvision
torchtext
torchaudio
PyHamcrest
bs4
awscli==1.16.35
flask
spacy
ray[tune]

# PyTorch Theme
-e git+git://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme

ipython

# to run examples
pandas
scikit-image
pillow==8.1.1
wget

# for codespaces env
pylint
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,4 @@ cleanup.sh
*.swp

# PyTorch things
*.pt
*.pt
19 changes: 16 additions & 3 deletions .jenkins/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ else
export BUCKET_NAME=pytorch-tutorial-build-pull-request
fi

# set locale for click dependency in spacy
export LC_ALL=C.UTF-8
export LANG=C.UTF-8

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"

sudo apt-get update
Expand All @@ -18,6 +22,12 @@ pip install -r $DIR/../requirements.txt
# export PATH=/opt/conda/bin:$PATH
# pip install sphinx==1.8.2 pandas

#Install PyTorch Nightly for test.
# Nightly - pip install --pre torch torchvision torchaudio -f https://download.pytorch.org/whl/nightly/cu102/torch_nightly.html
# RC Link
# pip uninstall -y torch torchvision torchaudio torchtext
# pip install -f https://download.pytorch.org/whl/test/cu102/torch_test.html torch torchvision torchaudio torchtext

# For Tensorboard. Until 1.14 moves to the release channel.
pip install tb-nightly

Expand All @@ -28,9 +38,7 @@ python -m spacy download de
# PyTorch Theme
rm -rf src
pip install -e git+git://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
# pillow >= 4.2 will throw error when trying to write mode RGBA as JPEG,
# this is a workaround to the issue.
pip install sphinx-gallery==0.3.1 tqdm matplotlib ipython pillow==4.1.1
pip install sphinx-gallery==0.3.1 tqdm matplotlib ipython pillow==8.1.0

aws configure set default.s3.multipart_threshold 5120MB

Expand All @@ -39,6 +47,11 @@ export NUM_WORKERS=20
if [[ "${JOB_BASE_NAME}" == *worker_* ]]; then
# Step 1: Remove runnable code from tutorials that are not supposed to be run
python $DIR/remove_runnable_code.py beginner_source/aws_distributed_training_tutorial.py beginner_source/aws_distributed_training_tutorial.py || true
# python $DIR/remove_runnable_code.py advanced_source/ddp_pipeline_tutorial.py advanced_source/ddp_pipeline_tutorial.py || true
# Temp remove for mnist download issue. (Re-enabled for 1.8.1)
# python $DIR/remove_runnable_code.py beginner_source/fgsm_tutorial.py beginner_source/fgsm_tutorial.py || true
# python $DIR/remove_runnable_code.py intermediate_source/spatial_transformer_tutorial.py intermediate_source/spatial_transformer_tutorial.py || true

# TODO: Fix bugs in these tutorials to make them runnable again
# python $DIR/remove_runnable_code.py beginner_source/audio_classifier_tutorial.py beginner_source/audio_classifier_tutorial.py || true

Expand Down
6 changes: 0 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,11 @@ download:
wget -N https://download.pytorch.org/models/mobilenet_v2-b0353104.pth -P $(DATADIR)
cp $(DATADIR)/mobilenet_v2-b0353104.pth advanced_source/data/mobilenet_pretrained_float.pth

# Download dataset for advanced_source/static_quantization_tutorial.py
wget -N https://s3.amazonaws.com/pytorch-tutorial-assets/imagenet_1k.zip -P $(DATADIR)
unzip $(ZIPOPTS) $(DATADIR)/imagenet_1k.zip -d advanced_source/data/

# Download model for prototype_source/graph_mode_static_quantization_tutorial.py
wget -N https://download.pytorch.org/models/resnet18-5c106cde.pth -P $(DATADIR)
cp $(DATADIR)/resnet18-5c106cde.pth prototype_source/data/resnet18_pretrained_float.pth

# Download dataset for prototype_source/graph_mode_static_quantization_tutorial.py
wget -N https://s3.amazonaws.com/pytorch-tutorial-assets/imagenet_1k.zip -P $(DATADIR)
unzip $(ZIPOPTS) $(DATADIR)/imagenet_1k.zip -d prototype_source/data/

docs:
make download
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ In case you prefer to write your tutorial in jupyter, you can use [this script](
- Then you can build using `make docs`. This will download the data, execute the tutorials and build the documentation to `docs/` directory. This will take about 60-120 min for systems with GPUs. If you do not have a GPU installed on your system, then see next step.
- You can skip the computationally intensive graph generation by running `make html-noplot` to build basic html documentation to `_build/html`. This way, you can quickly preview your tutorial.

> If you get **ModuleNotFoundError: No module named 'pytorch_sphinx_theme' make: *** [html-noplot] Error 2**, from /tutorials/src/pytorch-sphinx-theme run `python setup.py install`.
> If you get **ModuleNotFoundError: No module named 'pytorch_sphinx_theme' make: *** [html-noplot] Error 2** from /tutorials/src/pytorch-sphinx-theme or /venv/src/pytorch-sphinx-theme (while using virtualenv), run `python setup.py install`.

## About contributing to PyTorch Documentation and Tutorials
* You can find information about contributing to PyTorch documentation in the
PyTorch Repo [README.md](https://github.com/pytorch/pytorch/blob/master/README.md) file.
* Additional information can be found in [PyTorch CONTRIBUTING.md](https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md).

* Additional information can be found in [PyTorch CONTRIBUTING.md](https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md).
Binary file added _static/img/8_workers.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/img/basics/comp-graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/img/basics/fashion_mnist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/img/basics/optimizationloops.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/img/basics/typesdata.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/img/dag_autograd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/img/mario.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/img/mario_env.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/img/oneworker.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/img/profiler_overview1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/img/profiler_overview2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/img/profiler_trace_view1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/img/profiler_trace_view2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/img/profiler_views_list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified _static/img/tensorboard_pr_curves.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added _static/mnist.pkl.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion _static/torchvision_finetuning_instance_segmentation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@
" self.masks = list(sorted(os.listdir(os.path.join(root, \"PedMasks\"))))\n",
"\n",
" def __getitem__(self, idx):\n",
" # load images ad masks\n",
" # load images and masks\n",
" img_path = os.path.join(self.root, \"PNGImages\", self.imgs[idx])\n",
" mask_path = os.path.join(self.root, \"PedMasks\", self.masks[idx])\n",
" img = Image.open(img_path).convert(\"RGB\")\n",
Expand Down
2 changes: 1 addition & 1 deletion _static/tv-training-code.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, root, transforms):
self.masks = list(sorted(os.listdir(os.path.join(root, "PedMasks"))))

def __getitem__(self, idx):
# load images ad masks
# load images and masks
img_path = os.path.join(self.root, "PNGImages", self.imgs[idx])
mask_path = os.path.join(self.root, "PedMasks", self.masks[idx])
img = Image.open(img_path).convert("RGB")
Expand Down
37 changes: 18 additions & 19 deletions _templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@
tutorialLink: window.location.href,
downloadTitle: $(this).attr("data-response")
});

gtag('event', 'click', {
'event_category': 'Download',
'event_label': $(this).attr("data-response")
ga('send', {
hitType: 'event',
eventCategory: $(this).attr("data-response"),
eventAction: 'click',
eventLabel: window.location.href
});

gtag('event', 'click', {
Expand All @@ -47,29 +48,22 @@
});
});

$("[data-behavior='was-this-helpful-event']").on('click', function(){
$(".helpful-question").hide();
$(".was-helpful-thank-you").show();

fbq('trackCustom', "Was this Helpful?", {
$("[data-behavior='tutorial-rating']").on('click', function(){
fbq('trackCustom', "Tutorial Rating", {
tutorialLink: window.location.href,
tutorialTitle: $('h1:first').text(),
helpful: $(this).attr("data-response")
});

gtag('event', $(this).attr("data-response"), {
'event_category': 'Was this Helpful?',
'event_label': $(this).attr("data-response")
rating: $(this).attr("data-count")
});

gtag('event', $(this).attr("data-response"), {
'event_category': 'Was this Helpful?',
'event_label': $("h1").first().text()
gtag('event', 'click', {
'event_category': 'Tutorial Rating',
'event_label': $("h1").first().text(),
'value': $(this).attr("data-count")
});
});

if (location.pathname == "/") {
$(".helpful-container").hide();
$(".rating-container").hide();
$(".hr-bottom").hide();
}
</script>
Expand All @@ -79,5 +73,10 @@
src="https://www.facebook.com/tr?id=243028289693773&ev=PageView
&noscript=1"/>
</noscript>

<script type="text/javascript">
var collapsedSections = ['PyTorch Recipes', 'Learning PyTorch', 'Image and Video', 'Audio', 'Text', 'Reinforcement Learning', 'Deploying PyTorch Models in Production', 'Code Transforms with FX', 'Frontend APIs', 'Extending PyTorch', 'Model Optimization', 'Parallel and Distributed Training', 'Mobile'];
</script>

<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"/>
{% endblock %}
4 changes: 2 additions & 2 deletions advanced_source/cpp_export.rst
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ If you need to exclude some methods in your ``nn.Module``
because they use Python features that TorchScript doesn't support yet,
you could annotate those with ``@torch.jit.ignore``

``my_module`` is an instance of
``sm`` is an instance of
``ScriptModule`` that is ready for serialization.

Step 2: Serializing Your Script Module to a File
Expand All @@ -132,7 +132,7 @@ on the module and pass it a filename::
traced_script_module.save("traced_resnet_model.pt")

This will produce a ``traced_resnet_model.pt`` file in your working directory.
If you also would like to serialize ``my_module``, call ``my_module.save("my_module_model.pt")``
If you also would like to serialize ``sm``, call ``sm.save("my_module_model.pt")``
We have now officially left the realm of Python and are ready to cross over to the sphere
of C++.

Expand Down
Loading

0 comments on commit 479ea7c

Please sign in to comment.