Skip to content

Commit db6fbfa

Browse files
bottlerfacebook-github-bot
authored andcommitted
update notebooks for s3 wheels
Summary: Prepare the tutorial notebooks to use wheels from S3 when run on colab. Reviewed By: nikhilaravi Differential Revision: D26226932 fbshipit-source-id: 1f9366c3fb4ba195333a5d5dfa3f6876ea934508
1 parent e0753f0 commit db6fbfa

11 files changed

+187
-108
lines changed

docs/tutorials/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ https://github.com/facebookresearch/pytorch3d/tree/stable/docs/tutorials .
66

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

9-
They install torch, torchvision and PyTorch3D from pip, which should work
10-
with the CUDA 10.1 inside a GPU colab notebook. If you need to install
11-
PyTorch3D from source inside colab, you can use
9+
They install PyTorch3D from pip, which should work inside a GPU colab notebook.
10+
If you need to install PyTorch3D from source inside colab, you can use
1211
```
1312
import os
1413
!curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz

docs/tutorials/bundle_adjustment.ipynb

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"id": "WAHR1LMJmP-h"
6464
},
6565
"source": [
66-
"If `torch`, `torchvision` and `pytorch3d` are not installed, run the following cell:"
66+
"Ensure `torch` and `torchvision` are installed. If `pytorch3d` is not installed, install it using the following cell:"
6767
]
6868
},
6969
{
@@ -80,19 +80,25 @@
8080
},
8181
"outputs": [],
8282
"source": [
83-
"!pip install torch torchvision\n",
8483
"import os\n",
8584
"import sys\n",
8685
"import torch\n",
87-
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
88-
" !pip install pytorch3d\n",
89-
"else:\n",
90-
" need_pytorch3d=False\n",
91-
" try:\n",
92-
" import pytorch3d\n",
93-
" except ModuleNotFoundError:\n",
94-
" need_pytorch3d=True\n",
95-
" if need_pytorch3d:\n",
86+
"need_pytorch3d=False\n",
87+
"try:\n",
88+
" import pytorch3d\n",
89+
"except ModuleNotFoundError:\n",
90+
" need_pytorch3d=True\n",
91+
"if need_pytorch3d:\n",
92+
" if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
93+
" # We try to install PyTorch3D via a released wheel.\n",
94+
" version_str=\"\".join([\n",
95+
" f\"py3{sys.version_info.minor}_cu\",\n",
96+
" torch.version.cuda.replace(\".\",\"\"),\n",
97+
" f\"_pyt{torch.__version__[0:5:2]}\"\n",
98+
" ])\n",
99+
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
100+
" else:\n",
101+
" # We try to install PyTorch3D from source.\n",
96102
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
97103
" !tar xzf 1.10.0.tar.gz\n",
98104
" os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",

docs/tutorials/camera_position_optimization_with_differentiable_rendering.ipynb

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"id": "qkX7DiM6rmeM"
5151
},
5252
"source": [
53-
"If `torch`, `torchvision` and `pytorch3d` are not installed, run the following cell:"
53+
"Ensure `torch` and `torchvision` are installed. If `pytorch3d` is not installed, install it using the following cell:"
5454
]
5555
},
5656
{
@@ -67,19 +67,25 @@
6767
},
6868
"outputs": [],
6969
"source": [
70-
"!pip install torch torchvision\n",
7170
"import os\n",
7271
"import sys\n",
7372
"import torch\n",
74-
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
75-
" !pip install pytorch3d\n",
76-
"else:\n",
77-
" need_pytorch3d=False\n",
78-
" try:\n",
79-
" import pytorch3d\n",
80-
" except ModuleNotFoundError:\n",
81-
" need_pytorch3d=True\n",
82-
" if need_pytorch3d:\n",
73+
"need_pytorch3d=False\n",
74+
"try:\n",
75+
" import pytorch3d\n",
76+
"except ModuleNotFoundError:\n",
77+
" need_pytorch3d=True\n",
78+
"if need_pytorch3d:\n",
79+
" if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
80+
" # We try to install PyTorch3D via a released wheel.\n",
81+
" version_str=\"\".join([\n",
82+
" f\"py3{sys.version_info.minor}_cu\",\n",
83+
" torch.version.cuda.replace(\".\",\"\"),\n",
84+
" f\"_pyt{torch.__version__[0:5:2]}\"\n",
85+
" ])\n",
86+
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
87+
" else:\n",
88+
" # We try to install PyTorch3D from source.\n",
8389
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
8490
" !tar xzf 1.10.0.tar.gz\n",
8591
" os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",

docs/tutorials/dataloaders_ShapeNetCore_R2N2.ipynb

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"cell_type": "markdown",
3434
"metadata": {},
3535
"source": [
36-
"If `torch`, `torchvision` and `pytorch3d` are not installed, run the following cell:"
36+
"Ensure `torch` and `torchvision` are installed. If `pytorch3d` is not installed, install it using the following cell:"
3737
]
3838
},
3939
{
@@ -42,19 +42,25 @@
4242
"metadata": {},
4343
"outputs": [],
4444
"source": [
45-
"!pip install torch torchvision\n",
4645
"import os\n",
4746
"import sys\n",
4847
"import torch\n",
49-
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
50-
" !pip install pytorch3d\n",
51-
"else:\n",
52-
" need_pytorch3d=False\n",
53-
" try:\n",
54-
" import pytorch3d\n",
55-
" except ModuleNotFoundError:\n",
56-
" need_pytorch3d=True\n",
57-
" if need_pytorch3d:\n",
48+
"need_pytorch3d=False\n",
49+
"try:\n",
50+
" import pytorch3d\n",
51+
"except ModuleNotFoundError:\n",
52+
" need_pytorch3d=True\n",
53+
"if need_pytorch3d:\n",
54+
" if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
55+
" # We try to install PyTorch3D via a released wheel.\n",
56+
" version_str=\"\".join([\n",
57+
" f\"py3{sys.version_info.minor}_cu\",\n",
58+
" torch.version.cuda.replace(\".\",\"\"),\n",
59+
" f\"_pyt{torch.__version__[0:5:2]}\"\n",
60+
" ])\n",
61+
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
62+
" else:\n",
63+
" # We try to install PyTorch3D from source.\n",
5864
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
5965
" !tar xzf 1.10.0.tar.gz\n",
6066
" os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",

docs/tutorials/deform_source_mesh_to_target_mesh.ipynb

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"cell_type": "markdown",
6969
"metadata": {},
7070
"source": [
71-
"If `torch`, `torchvision` and `pytorch3d` are not installed, run the following cell:"
71+
"Ensure `torch` and `torchvision` are installed. If `pytorch3d` is not installed, install it using the following cell:"
7272
]
7373
},
7474
{
@@ -81,19 +81,25 @@
8181
},
8282
"outputs": [],
8383
"source": [
84-
"!pip install torch torchvision\n",
8584
"import os\n",
8685
"import sys\n",
8786
"import torch\n",
88-
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
89-
" !pip install pytorch3d\n",
90-
"else:\n",
91-
" need_pytorch3d=False\n",
92-
" try:\n",
93-
" import pytorch3d\n",
94-
" except ModuleNotFoundError:\n",
95-
" need_pytorch3d=True\n",
96-
" if need_pytorch3d:\n",
87+
"need_pytorch3d=False\n",
88+
"try:\n",
89+
" import pytorch3d\n",
90+
"except ModuleNotFoundError:\n",
91+
" need_pytorch3d=True\n",
92+
"if need_pytorch3d:\n",
93+
" if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
94+
" # We try to install PyTorch3D via a released wheel.\n",
95+
" version_str=\"\".join([\n",
96+
" f\"py3{sys.version_info.minor}_cu\",\n",
97+
" torch.version.cuda.replace(\".\",\"\"),\n",
98+
" f\"_pyt{torch.__version__[0:5:2]}\"\n",
99+
" ])\n",
100+
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
101+
" else:\n",
102+
" # We try to install PyTorch3D from source.\n",
97103
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
98104
" !tar xzf 1.10.0.tar.gz\n",
99105
" os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",

docs/tutorials/fit_simple_neural_radiance_field.ipynb

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"metadata": {},
3939
"source": [
4040
"## 0. Install and Import modules\n",
41-
"If `torch` and `pytorch3d` are not installed, run the following cell:"
41+
"Ensure `torch` and `torchvision` are installed. If `pytorch3d` is not installed, install it using the following cell:"
4242
]
4343
},
4444
{
@@ -47,13 +47,29 @@
4747
"metadata": {},
4848
"outputs": [],
4949
"source": [
50-
"# !pip install torch\n",
51-
"# import sys\n",
52-
"# import torch\n",
53-
"# if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
54-
"# !pip install pytorch3d\n",
55-
"# else:\n",
56-
"# !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'"
50+
"import os\n",
51+
"import sys\n",
52+
"import torch\n",
53+
"need_pytorch3d=False\n",
54+
"try:\n",
55+
" import pytorch3d\n",
56+
"except ModuleNotFoundError:\n",
57+
" need_pytorch3d=True\n",
58+
"if need_pytorch3d:\n",
59+
" if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
60+
" # We try to install PyTorch3D via a released wheel.\n",
61+
" version_str=\"\".join([\n",
62+
" f\"py3{sys.version_info.minor}_cu\",\n",
63+
" torch.version.cuda.replace(\".\",\"\"),\n",
64+
" f\"_pyt{torch.__version__[0:5:2]}\"\n",
65+
" ])\n",
66+
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
67+
" else:\n",
68+
" # We try to install PyTorch3D from source.\n",
69+
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
70+
" !tar xzf 1.10.0.tar.gz\n",
71+
" os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",
72+
" !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'"
5773
]
5874
},
5975
{

docs/tutorials/fit_textured_mesh.ipynb

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
"id": "okLalbR_g7NS"
4747
},
4848
"source": [
49-
"If `torch`, `torchvision` and `pytorch3d` are not installed, run the following cell:"
50-
]
49+
"Ensure `torch` and `torchvision` are installed. If `pytorch3d` is not installed, install it using the following cell:"
50+
]
5151
},
5252
{
5353
"cell_type": "code",
@@ -59,19 +59,25 @@
5959
},
6060
"outputs": [],
6161
"source": [
62-
"!pip install torch torchvision\n",
6362
"import os\n",
6463
"import sys\n",
6564
"import torch\n",
66-
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
67-
" !pip install pytorch3d\n",
68-
"else:\n",
69-
" need_pytorch3d=False\n",
70-
" try:\n",
71-
" import pytorch3d\n",
72-
" except ModuleNotFoundError:\n",
73-
" need_pytorch3d=True\n",
74-
" if need_pytorch3d:\n",
65+
"need_pytorch3d=False\n",
66+
"try:\n",
67+
" import pytorch3d\n",
68+
"except ModuleNotFoundError:\n",
69+
" need_pytorch3d=True\n",
70+
"if need_pytorch3d:\n",
71+
" if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
72+
" # We try to install PyTorch3D via a released wheel.\n",
73+
" version_str=\"\".join([\n",
74+
" f\"py3{sys.version_info.minor}_cu\",\n",
75+
" torch.version.cuda.replace(\".\",\"\"),\n",
76+
" f\"_pyt{torch.__version__[0:5:2]}\"\n",
77+
" ])\n",
78+
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
79+
" else:\n",
80+
" # We try to install PyTorch3D from source.\n",
7581
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
7682
" !tar xzf 1.10.0.tar.gz\n",
7783
" os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",

docs/tutorials/fit_textured_volume.ipynb

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"metadata": {},
3030
"source": [
3131
"## 0. Install and Import modules\n",
32-
"If `torch` and `pytorch3d` are not installed, run the following cell:"
32+
"Ensure `torch` and `torchvision` are installed. If `pytorch3d` is not installed, install it using the following cell:"
3333
]
3434
},
3535
{
@@ -38,13 +38,29 @@
3838
"metadata": {},
3939
"outputs": [],
4040
"source": [
41-
"# !pip install torch\n",
42-
"# import sys\n",
43-
"# import torch\n",
44-
"# if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
45-
"# !pip install pytorch3d\n",
46-
"# else:\n",
47-
"# !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'"
41+
"import os\n",
42+
"import sys\n",
43+
"import torch\n",
44+
"need_pytorch3d=False\n",
45+
"try:\n",
46+
" import pytorch3d\n",
47+
"except ModuleNotFoundError:\n",
48+
" need_pytorch3d=True\n",
49+
"if need_pytorch3d:\n",
50+
" if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
51+
" # We try to install PyTorch3D via a released wheel.\n",
52+
" version_str=\"\".join([\n",
53+
" f\"py3{sys.version_info.minor}_cu\",\n",
54+
" torch.version.cuda.replace(\".\",\"\"),\n",
55+
" f\"_pyt{torch.__version__[0:5:2]}\"\n",
56+
" ])\n",
57+
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
58+
" else:\n",
59+
" # We try to install PyTorch3D from source.\n",
60+
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
61+
" !tar xzf 1.10.0.tar.gz\n",
62+
" os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",
63+
" !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'"
4864
]
4965
},
5066
{

docs/tutorials/render_colored_points.ipynb

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"cell_type": "markdown",
3333
"metadata": {},
3434
"source": [
35-
"If `torch`, `torchvision` and `pytorch3d` are not installed, run the following cell:"
35+
"Ensure `torch` and `torchvision` are installed. If `pytorch3d` is not installed, install it using the following cell:"
3636
]
3737
},
3838
{
@@ -41,19 +41,25 @@
4141
"metadata": {},
4242
"outputs": [],
4343
"source": [
44-
"!pip install torch torchvision\n",
4544
"import os\n",
4645
"import sys\n",
4746
"import torch\n",
48-
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
49-
" !pip install pytorch3d\n",
50-
"else:\n",
51-
" need_pytorch3d=False\n",
52-
" try:\n",
53-
" import pytorch3d\n",
54-
" except ModuleNotFoundError:\n",
55-
" need_pytorch3d=True\n",
56-
" if need_pytorch3d:\n",
47+
"need_pytorch3d=False\n",
48+
"try:\n",
49+
" import pytorch3d\n",
50+
"except ModuleNotFoundError:\n",
51+
" need_pytorch3d=True\n",
52+
"if need_pytorch3d:\n",
53+
" if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
54+
" # We try to install PyTorch3D via a released wheel.\n",
55+
" version_str=\"\".join([\n",
56+
" f\"py3{sys.version_info.minor}_cu\",\n",
57+
" torch.version.cuda.replace(\".\",\"\"),\n",
58+
" f\"_pyt{torch.__version__[0:5:2]}\"\n",
59+
" ])\n",
60+
" !pip install pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html\n",
61+
" else:\n",
62+
" # We try to install PyTorch3D from source.\n",
5763
" !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
5864
" !tar xzf 1.10.0.tar.gz\n",
5965
" os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",

0 commit comments

Comments
 (0)