To verify that your Ubuntu ARM64 system meets all the PyTorch3D requirements, you can execute a series of commands to check each dependency. Below is a step-by-step guide to help you verify each requirement:
1. Operating System
Verification:
Since you're using Ubuntu ARM64, your OS is compatible with PyTorch3D, which supports Linux, macOS, and Windows.
2. Python Installation
Check Python Version:
PyTorch3D typically requires Python 3.6 or newer, but it's recommended to use Python 3.9 as per the installation instructions.
python3 --version
Expected Output:
Python 3.9.x
If Python is not installed or you need a specific version:
sudo apt update
sudo apt install python3.9 python3.9-venv python3.9-dev
3. PyTorch and torchvision Installation
Check PyTorch Version:
Start a Python shell:
python3
Then, run:
import torch
print(torch.__version__)
Expected Output:
One of the following versions should be displayed:
2.1.0, 2.1.1, 2.1.2, 2.2.0, 2.2.1, 2.2.2, 2.3.0, 2.3.1, 2.4.0, or 2.4.1
Check torchvision Version:
In the same Python shell, run:
import torchvision
print(torchvision.__version__)
Expected Outcome:
The torchvision version should be compatible with your installed PyTorch version. Refer to PyTorch's compatibility matrix to ensure they match.
If PyTorch or torchvision is not installed or needs updating:
Follow the official PyTorch installation guide to install the appropriate versions. For example, using conda:
conda install pytorch=2.4.1 torchvision=0.15.2 cudatoolkit=11.6 -c pytorch -c nvidia
Ensure you adjust the versions and cudatoolkit according to your requirements.
4. GCC and G++ Installation
Check GCC Version:
gcc --version
Check G++ Version:
g++ --version
Expected Output:
Both should be version 4.9 or higher. For example:
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
If GCC/G++ is not installed or needs updating:
sudo apt update
sudo apt install build-essential
5. iopath Installation
Check if iopath is installed:
Start a Python shell:
python3
Then, run:
import iopath
print(iopath.__version__)
Expected Outcome:
A version number should be displayed, indicating that iopath is installed.
If iopath is not installed:
Using conda:
conda install -c iopath iopath
Or using pip:
pip install iopath
6. CUDA Installation and Version
Check CUDA Version via nvcc:
nvcc --version
Expected Output:
nvcc: NVIDIA (R) Cuda compiler driver
...
Cuda compilation tools, release X.Y, VZ.ZZ.Z
Ensure that the CUDA version is ≥ 9.2 and compatible with your PyTorch version.
Alternative Method Using PyTorch:
Start a Python shell:
python3
Then, run:
import torch
print(torch.version.cuda)
If CUDA is not installed or needs updating:
Follow the official CUDA installation guide for Ubuntu ARM64.
Note: Ensure that the CUDA version you install is compatible with your PyTorch version. Refer to PyTorch's CUDA compatibility for guidance.
7. CUB Library Installation (If CUDA < 11.7)
Check if CUB is Installed via Conda:
conda list | grep cub
Expected Output:
nvidiacub 1.10.0 ...
If CUB is not installed and you need it (for CUDA < 11.7):
Using conda:
conda install -c bottler nvidiacub=1.10.0
Or, install manually:
# Download CUB
curl -LO https://github.com/NVIDIA/cub/archive/1.10.0.tar.gz
# Extract the archive
tar xzf 1.10.0.tar.gz
# Set the CUB_HOME environment variable
export CUB_HOME=$PWD/cub-1.10.0
You can add the export CUB_HOME line to your ~/.bashrc or ~/.bash_profile to make it persistent.
8. Runtime Dependencies for Tests, Linting, and Demos
Check Installed Python Packages:
Start a Python shell:
python3 -m pip list
Look for the following packages with their versions:
scikit-image
black
usort
flake8
matplotlib
tqdm
jupyter
imageio
fvcore
plotly
opencv-python
Alternatively, try importing them individually:
Start a Python shell and run:
import skimage
import black
import usort
import flake8
import matplotlib
import tqdm
import jupyter
import imageio
import fvcore
import plotly
import cv2
If any imports fail, install the missing packages:
Using conda and pip as specified:
# Activate your environment if not already activated
conda activate pytorch3d
# Install demos and examples dependencies
conda install jupyter
pip install scikit-image matplotlib imageio plotly opencv-python
# Install tests and linting dependencies
conda install -c fvcore -c conda-forge fvcore
pip install black usort flake8 flake8-bugbear flake8-comprehensions
9. Installing Prebuilt Binaries for PyTorch3D
After verifying all dependencies, you can proceed to install PyTorch3D.
Option 1: Install with CUDA Support from Anaconda Cloud (Linux Only)
conda install pytorch3d -c pytorch3d
Option 2: Install a Nightly (Alpha) Build
conda install pytorch3d -c pytorch3d-nightly
Option 3: Install Prebuilt Wheels for Linux
Example for Python 3.8, PyTorch 1.11.0, and CUDA 11.3:
pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/py38_cu113_pyt1110/download.html
General Installation in IPython, Google Colab, or Jupyter Notebook:
import sys
import torch
pyt_version_str = torch.__version__.split("+")[0].replace(".", "")
version_str = "".join([
f"py3{sys.version_info.minor}_cu",
torch.version.cuda.replace(".", ""),
f"_pyt{pyt_version_str}"
])
!pip install iopath
!pip install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html
10. Building and Installing PyTorch3D from Source (Optional)
If you prefer building PyTorch3D from source, follow these steps:
Option 1: Install Directly from GitHub
pip install "git+https://github.com/facebookresearch/pytorch3d.git"
For the Stable Release:
pip install "git+https://github.com/facebookresearch/pytorch3d.git@stable"
On macOS:
MACOSX_DEPLOYMENT_TARGET=10.14 CC=clang CXX=clang++ pip install "git+https://github.com/facebookresearch/pytorch3d.git"
Option 2: Install from a Local Clone
# Clone the repository
git clone https://github.com/facebookresearch/pytorch3d.git
# Navigate to the directory
cd pytorch3d
# Install in editable mode
pip install -e .
To Rebuild After Changes:
rm -rf build/ **/*.so
pip install -e .
On macOS from Local Clone:
MACOSX_DEPLOYMENT_TARGET=10.14 CC=clang CXX=clang++ pip install -e .
On Windows from Local Clone:
-
Apply Any Necessary Patches: Check issues for patches related to your PyTorch version.
-
Compile and Install:
Open "x64 Native Tools Command Prompt for VS 2019" and run:
cd pytorch3d
python setup.py install
Running Unit Tests After Installation:
python3 -m unittest discover -v -s tests -t .
11. Frequently Asked Questions (FAQ)
Q: Can I use Docker?
A: PyTorch3D does not officially provide a Dockerfile. However, you can refer to Issue #113 where a user-shared Dockerfile is available. Note that it hasn’t been officially tested by the PyTorch3D team.
12. Additional Tips
-
Using Conda Environments:
It's advisable to create a separate conda environment for PyTorch3D to manage dependencies without conflicts.
conda create -n pytorch3d python=3.9
conda activate pytorch3d
-
Setting Environment Variables Permanently:
If you need to set CUB_HOME or other environment variables regularly, add them to your ~/.bashrc or ~/.bash_profile:
echo 'export CUB_HOME=/path/to/cub' >> ~/.bashrc
source ~/.bashrc
-
Verifying CUDA Compatibility:
Ensure that the CUDA version installed on your system is compatible with your PyTorch installation. Mismatched CUDA versions can lead to runtime errors.
By following the above steps, you can thoroughly verify that your Ubuntu ARM64 system meets all the necessary requirements for installing and running PyTorch3D. If you encounter any issues during verification or installation, consider consulting the official PyTorch3D GitHub repository for further assistance or troubleshooting tips.