diff --git a/docs/tutorials/README.md b/docs/tutorials/README.md index e81b0dfc..1f3f3649 100644 --- a/docs/tutorials/README.md +++ b/docs/tutorials/README.md @@ -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 diff --git a/docs/tutorials/bundle_adjustment.ipynb b/docs/tutorials/bundle_adjustment.ipynb index 38d02c9c..b17e4ac0 100644 --- a/docs/tutorials/bundle_adjustment.ipynb +++ b/docs/tutorials/bundle_adjustment.ipynb @@ -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:" ] }, { @@ -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", diff --git a/docs/tutorials/camera_position_optimization_with_differentiable_rendering.ipynb b/docs/tutorials/camera_position_optimization_with_differentiable_rendering.ipynb index d84db529..c905fd64 100644 --- a/docs/tutorials/camera_position_optimization_with_differentiable_rendering.ipynb +++ b/docs/tutorials/camera_position_optimization_with_differentiable_rendering.ipynb @@ -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:" ] }, { @@ -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", diff --git a/docs/tutorials/dataloaders_ShapeNetCore_R2N2.ipynb b/docs/tutorials/dataloaders_ShapeNetCore_R2N2.ipynb index 7dc0f4d0..1b561a45 100644 --- a/docs/tutorials/dataloaders_ShapeNetCore_R2N2.ipynb +++ b/docs/tutorials/dataloaders_ShapeNetCore_R2N2.ipynb @@ -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:" ] }, { @@ -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", diff --git a/docs/tutorials/deform_source_mesh_to_target_mesh.ipynb b/docs/tutorials/deform_source_mesh_to_target_mesh.ipynb index cf676ee6..d36efb0d 100644 --- a/docs/tutorials/deform_source_mesh_to_target_mesh.ipynb +++ b/docs/tutorials/deform_source_mesh_to_target_mesh.ipynb @@ -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:" ] }, { @@ -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", diff --git a/docs/tutorials/fit_simple_neural_radiance_field.ipynb b/docs/tutorials/fit_simple_neural_radiance_field.ipynb index 6546920d..55de597e 100644 --- a/docs/tutorials/fit_simple_neural_radiance_field.ipynb +++ b/docs/tutorials/fit_simple_neural_radiance_field.ipynb @@ -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:" ] }, { @@ -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'" ] }, { diff --git a/docs/tutorials/fit_textured_mesh.ipynb b/docs/tutorials/fit_textured_mesh.ipynb index ff02afbf..59e44e8f 100644 --- a/docs/tutorials/fit_textured_mesh.ipynb +++ b/docs/tutorials/fit_textured_mesh.ipynb @@ -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", @@ -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", diff --git a/docs/tutorials/fit_textured_volume.ipynb b/docs/tutorials/fit_textured_volume.ipynb index a82efb60..e7645efc 100644 --- a/docs/tutorials/fit_textured_volume.ipynb +++ b/docs/tutorials/fit_textured_volume.ipynb @@ -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:" ] }, { @@ -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'" ] }, { diff --git a/docs/tutorials/render_colored_points.ipynb b/docs/tutorials/render_colored_points.ipynb index 6aa206a6..133f4ca5 100644 --- a/docs/tutorials/render_colored_points.ipynb +++ b/docs/tutorials/render_colored_points.ipynb @@ -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:" ] }, { @@ -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", diff --git a/docs/tutorials/render_densepose.ipynb b/docs/tutorials/render_densepose.ipynb index 264499d3..250db70a 100644 --- a/docs/tutorials/render_densepose.ipynb +++ b/docs/tutorials/render_densepose.ipynb @@ -39,7 +39,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:" ] }, { @@ -48,19 +48,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", diff --git a/docs/tutorials/render_textured_meshes.ipynb b/docs/tutorials/render_textured_meshes.ipynb index c28acbf0..138ca369 100644 --- a/docs/tutorials/render_textured_meshes.ipynb +++ b/docs/tutorials/render_textured_meshes.ipynb @@ -47,7 +47,7 @@ "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:" ] }, { @@ -64,19 +64,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",