iTensor Installation

Quick setup guide for installing iTensor and its dependencies

System Requirements

Minimum Requirements

  • Python 3.9 or newer
  • C/C++ compiler (gcc 9+, clang 10+, MSVC 2019+)
  • 8GB RAM
  • 2GB free disk space

Recommended

  • 16GB+ RAM
  • CUDA-compatible GPU (NVIDIA, 8GB+ VRAM)
  • CUDA Toolkit 11.2+
  • Fast SSD storage

For MHD simulations and raytracing, GPU acceleration is highly recommended. CPU-only mode works for symbolic calculations and smaller numerical problems.

Quick Install

PyPI Package (Recommended)

pip install itensorpy

From Source

git clone https://github.com/itensor-org/itensorpy.git
cd itensorpy
pip install -e .

With GPU Support

pip install itensorpy[cuda]

The itensorpy[cuda] option requires a compatible CUDA toolkit already installed on your system. This is necessary for GPU-accelerated tensor calculations and visualization.

Platform-Specific Instructions

Linux

Dependencies

# Ubuntu/Debian
sudo apt update
sudo apt install build-essential cmake liblapack-dev libblas-dev

CUDA Setup (Optional)

# Install NVIDIA drivers and CUDA toolkit
sudo apt install nvidia-driver-535 nvidia-cuda-toolkit

After installing dependencies, follow the quick install instructions above.

macOS

Dependencies

# Using Homebrew
brew install cmake openblas python@3.9
brew install llvm

macOS doesn't support CUDA, so GPU acceleration is unavailable. Use the standard install:

pip install itensorpy

Note for Apple Silicon (M1/M2): Make sure to use Python with arm64 architecture, not x86_64 under Rosetta.

Windows

Dependencies

Install the following prerequisites:

  • Visual Studio 2019+ with C++ build tools
  • CMake (add to PATH)
  • Python 3.9+ (add to PATH)

CUDA Setup (Optional)

Download and install the NVIDIA CUDA Toolkit

Install iTensor from a command prompt with administrator privileges:

pip install itensorpy

For GPU support, use pip install itensorpy[cuda]

Verification

To verify your installation, run the following Python code:

import itensorpy # Print version print(f"iTensor version: {itensorpy.__version__}") # Test symbolic engine from itensorpy import Metric m = Metric.schwarzschild() print("Schwarzschild metric initialized") # Test if CUDA is available print(f"CUDA available: {itensorpy.cuda_available()}") # Run a simple calculation einstein = m.compute_einstein_tensor() print("Computed Einstein tensor components:") print(einstein.display_components())

If the script runs without errors, your installation is working correctly.

Troubleshooting

Compilation Errors

If you encounter C++ compilation errors during installation:

  • Ensure your compiler is recent enough (gcc 9+, MSVC 2019+)
  • Install development packages (libblas-dev, liblapack-dev)
  • On Windows, verify Visual Studio C++ build tools are installed

CUDA Issues

If GPU acceleration isn't working:

  • Verify NVIDIA drivers are installed: nvidia-smi
  • Check CUDA version: nvcc --version
  • Try reinstalling with: pip install --no-cache-dir itensorpy[cuda]

Python Package Conflicts

If you encounter dependency conflicts:

  • Create a fresh virtual environment: python -m venv itensor_env
  • Activate it and install iTensor there
  • Try a minimal install first: pip install itensorpy[minimal]