CUB when installing inside tutorials

Summary:
We now require CUB for building, here we make the tutorials include it.

Also make the installation cell do nothing if it has already succeeded.

I use curl not wget, and `os.environ` to set the variables not shell methods, because they are more likely to work on Windows.

Reviewed By: nikhilaravi

Differential Revision: D24860574

fbshipit-source-id: 5be86af15e53f8db016ee0e96fb43153bd69adbc
This commit is contained in:
Jeremy Reizenstein 2020-11-10 13:04:57 -08:00 committed by Facebook GitHub Bot
parent fb2763dc78
commit de7af4a704
9 changed files with 107 additions and 13 deletions

View File

@ -8,11 +8,17 @@ 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 torch, torchvision and PyTorch3D from pip, which should work
with the CUDA 10.1 inside a GPU colab notebook. If you need to install with the CUDA 10.1 inside a GPU colab notebook. If you need to install
pytorch3d from source inside colab, you can use PyTorch3D from source inside colab, you can use
`!pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'` ```
import os
!curl -O https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz
!tar xzf 1.10.0.tar.gz
os.environ["CUB_HOME"] = os.getcwd() + "/cub-1.10.0"
!pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'`
```
instead. instead.
The versions of these tutorials on the main branch may need to use the latest The versions of these tutorials on the main branch may need to use the latest
pytorch3d from the main branch. You may be able to install this from source PyTorch3D from the main branch. You may be able to install this from source
with with the same commands as above, but replacing the last line with
`!pip install 'git+https://github.com/facebookresearch/pytorch3d.git'`. `!pip install 'git+https://github.com/facebookresearch/pytorch3d.git'`.

View File

@ -81,11 +81,21 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip install torch torchvision\n", "!pip install torch torchvision\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", "if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
" !pip install pytorch3d\n", " !pip install pytorch3d\n",
"else:\n", "else:\n",
" need_pytorch3d=False\n",
" try:\n",
" import pytorch3d\n",
" except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
" if need_pytorch3d:\n",
" !curl -O 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'" " !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'"
] ]
}, },

View File

@ -68,11 +68,21 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip install torch torchvision\n", "!pip install torch torchvision\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", "if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
" !pip install pytorch3d\n", " !pip install pytorch3d\n",
"else:\n", "else:\n",
" need_pytorch3d=False\n",
" try:\n",
" import pytorch3d\n",
" except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
" if need_pytorch3d:\n",
" !curl -O 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'" " !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'"
] ]
}, },

View File

@ -43,11 +43,21 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip install torch torchvision\n", "!pip install torch torchvision\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", "if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
" !pip install pytorch3d\n", " !pip install pytorch3d\n",
"else:\n", "else:\n",
" need_pytorch3d=False\n",
" try:\n",
" import pytorch3d\n",
" except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
" if need_pytorch3d:\n",
" !curl -O 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'" " !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'"
] ]
}, },

View File

@ -82,11 +82,21 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip install torch torchvision\n", "!pip install torch torchvision\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", "if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
" !pip install pytorch3d\n", " !pip install pytorch3d\n",
"else:\n", "else:\n",
" need_pytorch3d=False\n",
" try:\n",
" import pytorch3d\n",
" except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
" if need_pytorch3d:\n",
" !curl -O 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'" " !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'"
] ]
}, },

View File

@ -60,11 +60,21 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip install torch torchvision\n", "!pip install torch torchvision\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", "if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
" !pip install pytorch3d\n", " !pip install pytorch3d\n",
"else:\n", "else:\n",
" need_pytorch3d=False\n",
" try:\n",
" import pytorch3d\n",
" except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
" if need_pytorch3d:\n",
" !curl -O 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'" " !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'"
] ]
}, },

View File

@ -42,11 +42,21 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip install torch torchvision\n", "!pip install torch torchvision\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", "if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
" !pip install pytorch3d\n", " !pip install pytorch3d\n",
"else:\n", "else:\n",
" need_pytorch3d=False\n",
" try:\n",
" import pytorch3d\n",
" except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
" if need_pytorch3d:\n",
" !curl -O 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'" " !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'"
] ]
}, },

View File

@ -49,13 +49,31 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip install torch torchvision\n", "!pip install torch torchvision\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", "if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
" !pip install pytorch3d\n", " !pip install pytorch3d\n",
"else:\n", "else:\n",
" !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'\n", " need_pytorch3d=False\n",
"# we also install chumpy as it is needed to load the SMPL model pickle file\n", " try:\n",
" import pytorch3d\n",
" except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
" if need_pytorch3d:\n",
" !curl -O 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'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# We also install chumpy as it is needed to load the SMPL model pickle file.\n",
"!pip install chumpy" "!pip install chumpy"
] ]
}, },

View File

@ -65,11 +65,21 @@
"outputs": [], "outputs": [],
"source": [ "source": [
"!pip install torch torchvision\n", "!pip install torch torchvision\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", "if torch.__version__=='1.6.0+cu101' and sys.platform.startswith('linux'):\n",
" !pip install pytorch3d\n", " !pip install pytorch3d\n",
"else:\n", "else:\n",
" need_pytorch3d=False\n",
" try:\n",
" import pytorch3d\n",
" except ModuleNotFoundError:\n",
" need_pytorch3d=True\n",
" if need_pytorch3d:\n",
" !curl -O 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'" " !pip install 'git+https://github.com/facebookresearch/pytorch3d.git@stable'"
] ]
}, },