Skip to content

Commit

Permalink
update notebooks for s3 wheels
Browse files Browse the repository at this point in the history
Summary: Prepare the tutorial notebooks to use wheels from S3 when run on colab.

Reviewed By: nikhilaravi

Differential Revision: D26226932

fbshipit-source-id: 1f9366c3fb4ba195333a5d5dfa3f6876ea934508
  • Loading branch information
bottler authored and facebook-github-bot committed Feb 5, 2021
1 parent e0753f0 commit db6fbfa
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 108 deletions.
5 changes: 2 additions & 3 deletions docs/tutorials/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ https://github.com/facebookresearch/pytorch3d/tree/stable/docs/tutorials .

There are links at the project homepage for opening these directly in colab.

They install torch, torchvision and PyTorch3D from pip, which should work
with the CUDA 10.1 inside a GPU colab notebook. If you need to install
PyTorch3D from source inside colab, you can use
They install PyTorch3D from pip, which should work inside a GPU colab notebook.
If you need to install PyTorch3D from source inside colab, you can use
```
import os
!curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz
Expand Down
28 changes: 17 additions & 11 deletions docs/tutorials/bundle_adjustment.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"id": "WAHR1LMJmP-h"
},
"source": [
"If `torch`, `torchvision` and `pytorch3d` are not installed, run the following cell:"
"Ensure `torch` and `torchvision` are installed. If `pytorch3d` is not installed, install it using the following cell:"
]
},
{
Expand All @@ -80,19 +80,25 @@
},
"outputs": [],
"source": [
"!pip install torch torchvision\n",
"import os\n",
"import sys\n",
"import torch\n",
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
" !pip install pytorch3d\n",
"else:\n",
" need_pytorch3d=False\n",
" try:\n",
" import pytorch3d\n",
" except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
" if need_pytorch3d:\n",
"need_pytorch3d=False\n",
"try:\n",
" import pytorch3d\n",
"except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
"if need_pytorch3d:\n",
" if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
" # We try to install PyTorch3D via a released wheel.\n",
" version_str=\"\".join([\n",
" f\"py3{sys.version_info.minor}_cu\",\n",
" torch.version.cuda.replace(\".\",\"\"),\n",
" f\"_pyt{torch.__version__[0:5:2]}\"\n",
" ])\n",
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
" else:\n",
" # We try to install PyTorch3D from source.\n",
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
" !tar xzf 1.10.0.tar.gz\n",
" os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"id": "qkX7DiM6rmeM"
},
"source": [
"If `torch`, `torchvision` and `pytorch3d` are not installed, run the following cell:"
"Ensure `torch` and `torchvision` are installed. If `pytorch3d` is not installed, install it using the following cell:"
]
},
{
Expand All @@ -67,19 +67,25 @@
},
"outputs": [],
"source": [
"!pip install torch torchvision\n",
"import os\n",
"import sys\n",
"import torch\n",
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
" !pip install pytorch3d\n",
"else:\n",
" need_pytorch3d=False\n",
" try:\n",
" import pytorch3d\n",
" except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
" if need_pytorch3d:\n",
"need_pytorch3d=False\n",
"try:\n",
" import pytorch3d\n",
"except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
"if need_pytorch3d:\n",
" if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
" # We try to install PyTorch3D via a released wheel.\n",
" version_str=\"\".join([\n",
" f\"py3{sys.version_info.minor}_cu\",\n",
" torch.version.cuda.replace(\".\",\"\"),\n",
" f\"_pyt{torch.__version__[0:5:2]}\"\n",
" ])\n",
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
" else:\n",
" # We try to install PyTorch3D from source.\n",
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
" !tar xzf 1.10.0.tar.gz\n",
" os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",
Expand Down
28 changes: 17 additions & 11 deletions docs/tutorials/dataloaders_ShapeNetCore_R2N2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"If `torch`, `torchvision` and `pytorch3d` are not installed, run the following cell:"
"Ensure `torch` and `torchvision` are installed. If `pytorch3d` is not installed, install it using the following cell:"
]
},
{
Expand All @@ -42,19 +42,25 @@
"metadata": {},
"outputs": [],
"source": [
"!pip install torch torchvision\n",
"import os\n",
"import sys\n",
"import torch\n",
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
" !pip install pytorch3d\n",
"else:\n",
" need_pytorch3d=False\n",
" try:\n",
" import pytorch3d\n",
" except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
" if need_pytorch3d:\n",
"need_pytorch3d=False\n",
"try:\n",
" import pytorch3d\n",
"except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
"if need_pytorch3d:\n",
" if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
" # We try to install PyTorch3D via a released wheel.\n",
" version_str=\"\".join([\n",
" f\"py3{sys.version_info.minor}_cu\",\n",
" torch.version.cuda.replace(\".\",\"\"),\n",
" f\"_pyt{torch.__version__[0:5:2]}\"\n",
" ])\n",
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
" else:\n",
" # We try to install PyTorch3D from source.\n",
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
" !tar xzf 1.10.0.tar.gz\n",
" os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",
Expand Down
28 changes: 17 additions & 11 deletions docs/tutorials/deform_source_mesh_to_target_mesh.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"If `torch`, `torchvision` and `pytorch3d` are not installed, run the following cell:"
"Ensure `torch` and `torchvision` are installed. If `pytorch3d` is not installed, install it using the following cell:"
]
},
{
Expand All @@ -81,19 +81,25 @@
},
"outputs": [],
"source": [
"!pip install torch torchvision\n",
"import os\n",
"import sys\n",
"import torch\n",
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
" !pip install pytorch3d\n",
"else:\n",
" need_pytorch3d=False\n",
" try:\n",
" import pytorch3d\n",
" except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
" if need_pytorch3d:\n",
"need_pytorch3d=False\n",
"try:\n",
" import pytorch3d\n",
"except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
"if need_pytorch3d:\n",
" if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
" # We try to install PyTorch3D via a released wheel.\n",
" version_str=\"\".join([\n",
" f\"py3{sys.version_info.minor}_cu\",\n",
" torch.version.cuda.replace(\".\",\"\"),\n",
" f\"_pyt{torch.__version__[0:5:2]}\"\n",
" ])\n",
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
" else:\n",
" # We try to install PyTorch3D from source.\n",
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
" !tar xzf 1.10.0.tar.gz\n",
" os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",
Expand Down
32 changes: 24 additions & 8 deletions docs/tutorials/fit_simple_neural_radiance_field.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"metadata": {},
"source": [
"## 0. Install and Import modules\n",
"If `torch` and `pytorch3d` are not installed, run the following cell:"
"Ensure `torch` and `torchvision` are installed. If `pytorch3d` is not installed, install it using the following cell:"
]
},
{
Expand All @@ -47,13 +47,29 @@
"metadata": {},
"outputs": [],
"source": [
"# !pip install torch\n",
"# import sys\n",
"# import torch\n",
"# if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
"# !pip install pytorch3d\n",
"# else:\n",
"# !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'"
"import os\n",
"import sys\n",
"import torch\n",
"need_pytorch3d=False\n",
"try:\n",
" import pytorch3d\n",
"except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
"if need_pytorch3d:\n",
" if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
" # We try to install PyTorch3D via a released wheel.\n",
" version_str=\"\".join([\n",
" f\"py3{sys.version_info.minor}_cu\",\n",
" torch.version.cuda.replace(\".\",\"\"),\n",
" f\"_pyt{torch.__version__[0:5:2]}\"\n",
" ])\n",
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
" else:\n",
" # We try to install PyTorch3D from source.\n",
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
" !tar xzf 1.10.0.tar.gz\n",
" os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",
" !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'"
]
},
{
Expand Down
30 changes: 18 additions & 12 deletions docs/tutorials/fit_textured_mesh.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"id": "okLalbR_g7NS"
},
"source": [
"If `torch`, `torchvision` and `pytorch3d` are not installed, run the following cell:"
]
"Ensure `torch` and `torchvision` are installed. If `pytorch3d` is not installed, install it using the following cell:"
]
},
{
"cell_type": "code",
Expand All @@ -59,19 +59,25 @@
},
"outputs": [],
"source": [
"!pip install torch torchvision\n",
"import os\n",
"import sys\n",
"import torch\n",
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
" !pip install pytorch3d\n",
"else:\n",
" need_pytorch3d=False\n",
" try:\n",
" import pytorch3d\n",
" except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
" if need_pytorch3d:\n",
"need_pytorch3d=False\n",
"try:\n",
" import pytorch3d\n",
"except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
"if need_pytorch3d:\n",
" if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
" # We try to install PyTorch3D via a released wheel.\n",
" version_str=\"\".join([\n",
" f\"py3{sys.version_info.minor}_cu\",\n",
" torch.version.cuda.replace(\".\",\"\"),\n",
" f\"_pyt{torch.__version__[0:5:2]}\"\n",
" ])\n",
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
" else:\n",
" # We try to install PyTorch3D from source.\n",
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
" !tar xzf 1.10.0.tar.gz\n",
" os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",
Expand Down
32 changes: 24 additions & 8 deletions docs/tutorials/fit_textured_volume.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"metadata": {},
"source": [
"## 0. Install and Import modules\n",
"If `torch` and `pytorch3d` are not installed, run the following cell:"
"Ensure `torch` and `torchvision` are installed. If `pytorch3d` is not installed, install it using the following cell:"
]
},
{
Expand All @@ -38,13 +38,29 @@
"metadata": {},
"outputs": [],
"source": [
"# !pip install torch\n",
"# import sys\n",
"# import torch\n",
"# if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
"# !pip install pytorch3d\n",
"# else:\n",
"# !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'"
"import os\n",
"import sys\n",
"import torch\n",
"need_pytorch3d=False\n",
"try:\n",
" import pytorch3d\n",
"except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
"if need_pytorch3d:\n",
" if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
" # We try to install PyTorch3D via a released wheel.\n",
" version_str=\"\".join([\n",
" f\"py3{sys.version_info.minor}_cu\",\n",
" torch.version.cuda.replace(\".\",\"\"),\n",
" f\"_pyt{torch.__version__[0:5:2]}\"\n",
" ])\n",
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
" else:\n",
" # We try to install PyTorch3D from source.\n",
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
" !tar xzf 1.10.0.tar.gz\n",
" os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",
" !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'"
]
},
{
Expand Down
28 changes: 17 additions & 11 deletions docs/tutorials/render_colored_points.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"If `torch`, `torchvision` and `pytorch3d` are not installed, run the following cell:"
"Ensure `torch` and `torchvision` are installed. If `pytorch3d` is not installed, install it using the following cell:"
]
},
{
Expand All @@ -41,19 +41,25 @@
"metadata": {},
"outputs": [],
"source": [
"!pip install torch torchvision\n",
"import os\n",
"import sys\n",
"import torch\n",
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
" !pip install pytorch3d\n",
"else:\n",
" need_pytorch3d=False\n",
" try:\n",
" import pytorch3d\n",
" except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
" if need_pytorch3d:\n",
"need_pytorch3d=False\n",
"try:\n",
" import pytorch3d\n",
"except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
"if need_pytorch3d:\n",
" if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
" # We try to install PyTorch3D via a released wheel.\n",
" version_str=\"\".join([\n",
" f\"py3{sys.version_info.minor}_cu\",\n",
" torch.version.cuda.replace(\".\",\"\"),\n",
" f\"_pyt{torch.__version__[0:5:2]}\"\n",
" ])\n",
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
" else:\n",
" # We try to install PyTorch3D from source.\n",
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
" !tar xzf 1.10.0.tar.gz\n",
" os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",
Expand Down
Loading

0 comments on commit db6fbfa

Please sign in to comment.