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
This commit is contained in:
Jeremy Reizenstein 2021-02-05 05:50:46 -08:00 committed by Facebook GitHub Bot
parent e0753f0b0d
commit db6fbfad90
11 changed files with 187 additions and 108 deletions

View File

@ -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. There are links at the project homepage for opening these directly in colab.
They install torch, torchvision and PyTorch3D from pip, which should work They install PyTorch3D from pip, which should work inside a GPU colab notebook.
with the CUDA 10.1 inside a GPU colab notebook. If you need to install If you need to install PyTorch3D from source inside colab, you can use
PyTorch3D from source inside colab, you can use
``` ```
import os import os
!curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz

View File

@ -63,7 +63,7 @@
"id": "WAHR1LMJmP-h" "id": "WAHR1LMJmP-h"
}, },
"source": [ "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:"
] ]
}, },
{ {
@ -80,19 +80,25 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip install torch torchvision\n",
"import os\n", "import os\n",
"import sys\n", "import sys\n",
"import torch\n", "import torch\n",
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n", "need_pytorch3d=False\n",
" !pip install pytorch3d\n", "try:\n",
"else:\n", " import pytorch3d\n",
" need_pytorch3d=False\n", "except ModuleNotFoundError:\n",
" try:\n", " need_pytorch3d=True\n",
" import pytorch3d\n", "if need_pytorch3d:\n",
" except ModuleNotFoundError:\n", " if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
" need_pytorch3d=True\n", " # We try to install PyTorch3D via a released wheel.\n",
" if need_pytorch3d:\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", " !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
" !tar xzf 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", " os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",

View File

@ -50,7 +50,7 @@
"id": "qkX7DiM6rmeM" "id": "qkX7DiM6rmeM"
}, },
"source": [ "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:"
] ]
}, },
{ {
@ -67,19 +67,25 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip install torch torchvision\n",
"import os\n", "import os\n",
"import sys\n", "import sys\n",
"import torch\n", "import torch\n",
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n", "need_pytorch3d=False\n",
" !pip install pytorch3d\n", "try:\n",
"else:\n", " import pytorch3d\n",
" need_pytorch3d=False\n", "except ModuleNotFoundError:\n",
" try:\n", " need_pytorch3d=True\n",
" import pytorch3d\n", "if need_pytorch3d:\n",
" except ModuleNotFoundError:\n", " if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
" need_pytorch3d=True\n", " # We try to install PyTorch3D via a released wheel.\n",
" if need_pytorch3d:\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", " !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
" !tar xzf 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", " os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",

View File

@ -33,7 +33,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "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:"
] ]
}, },
{ {
@ -42,19 +42,25 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip install torch torchvision\n",
"import os\n", "import os\n",
"import sys\n", "import sys\n",
"import torch\n", "import torch\n",
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n", "need_pytorch3d=False\n",
" !pip install pytorch3d\n", "try:\n",
"else:\n", " import pytorch3d\n",
" need_pytorch3d=False\n", "except ModuleNotFoundError:\n",
" try:\n", " need_pytorch3d=True\n",
" import pytorch3d\n", "if need_pytorch3d:\n",
" except ModuleNotFoundError:\n", " if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
" need_pytorch3d=True\n", " # We try to install PyTorch3D via a released wheel.\n",
" if need_pytorch3d:\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", " !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
" !tar xzf 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", " os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",

View File

@ -68,7 +68,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "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:"
] ]
}, },
{ {
@ -81,19 +81,25 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip install torch torchvision\n",
"import os\n", "import os\n",
"import sys\n", "import sys\n",
"import torch\n", "import torch\n",
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n", "need_pytorch3d=False\n",
" !pip install pytorch3d\n", "try:\n",
"else:\n", " import pytorch3d\n",
" need_pytorch3d=False\n", "except ModuleNotFoundError:\n",
" try:\n", " need_pytorch3d=True\n",
" import pytorch3d\n", "if need_pytorch3d:\n",
" except ModuleNotFoundError:\n", " if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
" need_pytorch3d=True\n", " # We try to install PyTorch3D via a released wheel.\n",
" if need_pytorch3d:\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", " !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
" !tar xzf 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", " os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",

View File

@ -38,7 +38,7 @@
"metadata": {}, "metadata": {},
"source": [ "source": [
"## 0. Install and Import modules\n", "## 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:"
] ]
}, },
{ {
@ -47,13 +47,29 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"# !pip install torch\n", "import os\n",
"# import sys\n", "import sys\n",
"# import torch\n", "import torch\n",
"# if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n", "need_pytorch3d=False\n",
"# !pip install pytorch3d\n", "try:\n",
"# else:\n", " import pytorch3d\n",
"# !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'" "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'"
] ]
}, },
{ {

View File

@ -46,8 +46,8 @@
"id": "okLalbR_g7NS" "id": "okLalbR_g7NS"
}, },
"source": [ "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", "cell_type": "code",
@ -59,19 +59,25 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip install torch torchvision\n",
"import os\n", "import os\n",
"import sys\n", "import sys\n",
"import torch\n", "import torch\n",
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n", "need_pytorch3d=False\n",
" !pip install pytorch3d\n", "try:\n",
"else:\n", " import pytorch3d\n",
" need_pytorch3d=False\n", "except ModuleNotFoundError:\n",
" try:\n", " need_pytorch3d=True\n",
" import pytorch3d\n", "if need_pytorch3d:\n",
" except ModuleNotFoundError:\n", " if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
" need_pytorch3d=True\n", " # We try to install PyTorch3D via a released wheel.\n",
" if need_pytorch3d:\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", " !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
" !tar xzf 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", " os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",

View File

@ -29,7 +29,7 @@
"metadata": {}, "metadata": {},
"source": [ "source": [
"## 0. Install and Import modules\n", "## 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:"
] ]
}, },
{ {
@ -38,13 +38,29 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"# !pip install torch\n", "import os\n",
"# import sys\n", "import sys\n",
"# import torch\n", "import torch\n",
"# if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n", "need_pytorch3d=False\n",
"# !pip install pytorch3d\n", "try:\n",
"# else:\n", " import pytorch3d\n",
"# !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'" "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'"
] ]
}, },
{ {

View File

@ -32,7 +32,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "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:"
] ]
}, },
{ {
@ -41,19 +41,25 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip install torch torchvision\n",
"import os\n", "import os\n",
"import sys\n", "import sys\n",
"import torch\n", "import torch\n",
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n", "need_pytorch3d=False\n",
" !pip install pytorch3d\n", "try:\n",
"else:\n", " import pytorch3d\n",
" need_pytorch3d=False\n", "except ModuleNotFoundError:\n",
" try:\n", " need_pytorch3d=True\n",
" import pytorch3d\n", "if need_pytorch3d:\n",
" except ModuleNotFoundError:\n", " if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
" need_pytorch3d=True\n", " # We try to install PyTorch3D via a released wheel.\n",
" if need_pytorch3d:\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", " !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
" !tar xzf 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", " os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",

View File

@ -39,7 +39,7 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "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:"
] ]
}, },
{ {
@ -48,19 +48,25 @@
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip install torch torchvision\n",
"import os\n", "import os\n",
"import sys\n", "import sys\n",
"import torch\n", "import torch\n",
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n", "need_pytorch3d=False\n",
" !pip install pytorch3d\n", "try:\n",
"else:\n", " import pytorch3d\n",
" need_pytorch3d=False\n", "except ModuleNotFoundError:\n",
" try:\n", " need_pytorch3d=True\n",
" import pytorch3d\n", "if need_pytorch3d:\n",
" except ModuleNotFoundError:\n", " if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
" need_pytorch3d=True\n", " # We try to install PyTorch3D via a released wheel.\n",
" if need_pytorch3d:\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", " !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
" !tar xzf 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", " os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",

View File

@ -47,7 +47,7 @@
"id": "okLalbR_g7NS" "id": "okLalbR_g7NS"
}, },
"source": [ "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:"
] ]
}, },
{ {
@ -64,19 +64,25 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip install torch torchvision\n",
"import os\n", "import os\n",
"import sys\n", "import sys\n",
"import torch\n", "import torch\n",
"if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n", "need_pytorch3d=False\n",
" !pip install pytorch3d\n", "try:\n",
"else:\n", " import pytorch3d\n",
" need_pytorch3d=False\n", "except ModuleNotFoundError:\n",
" try:\n", " need_pytorch3d=True\n",
" import pytorch3d\n", "if need_pytorch3d:\n",
" except ModuleNotFoundError:\n", " if torch.__version__.startswith(\"1.7\") and sys.platform.startswith(\"linux\"):\n",
" need_pytorch3d=True\n", " # We try to install PyTorch3D via a released wheel.\n",
" if need_pytorch3d:\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", " !curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz\n",
" !tar xzf 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", " os.environ[\"CUB_HOME\"] = os.getcwd() + \"/cub-1.10.0\"\n",