Skip to content

Commit

Permalink
script to run tutorials
Browse files Browse the repository at this point in the history
Summary: Script to execute tutorials inside docker with the nightly build.

Reviewed By: nikhilaravi

Differential Revision: D24503200

fbshipit-source-id: cfa010a7750627d4e87d224a112ff77952feeb55
  • Loading branch information
bottler authored and facebook-github-bot committed Oct 26, 2020
1 parent 2084160 commit b149bbf
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions dev/run_tutorials.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/bash
# Copyright (c) Facebook, Inc. and its affiliates. All rights reserved.

# This script is for running some of the tutorials using the nightly build in
# an isolated environment. It is designed to be run in docker.

# If you run this script in this directory with
# sudo docker run --runtime=nvidia -it --rm -v $PWD/../docs/tutorials:/notebooks -v $PWD:/loc pytorch/conda-cuda bash /loc/run_tutorials.sh | tee log.txt
# it should execute some tutorials with the nightly build and resave them, and
# save a log in the current directory.

# We use nbconvert. runipy would be an alternative but it currently doesn't
# work well with plotly.

set -e

conda init bash
# shellcheck source=/dev/null
source ~/.bashrc
conda create -y -n myenv python=3.8 matplotlib ipython ipywidgets nbconvert
conda activate myenv
conda install -y -c conda-forge fvcore
conda install -y -c pytorch pytorch=1.6.0 cudatoolkit=10.1 torchvision
conda install -y -c pytorch3d-nightly pytorch3d
pip install plotly scikit-image

for notebook in /notebooks/*.ipynb
do
name=$(basename "$notebook")

if [[ "$name" == "dataloaders_ShapeNetCore_R2N2.ipynb" ]]
then
#skip as data not easily available
continue
fi
if [[ "$name" == "render_densepose.ipynb" ]]
then
#skip as data not easily available
continue
fi

#comment the lines which install torch, torchvision and pytorch3d
sed -Ei '/(torchvision)|(pytorch3d)/ s/!pip/!#pip/' "$notebook"
#Don't let tqdm use widgets
sed -i 's/from tqdm.notebook import tqdm/from tqdm import tqdm/' "$notebook"

echo
echo "### ### ###"
echo "starting $name"
time jupyter nbconvert --to notebook --inplace --ExecutePreprocessor.kernel_name=python3 --execute "$notebook" || true
echo "ending $name"
done

0 comments on commit b149bbf

Please sign in to comment.