Skip to content

Latest commit

Β 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 

Repository files navigation

PyTorch 2.3.0 for Jetson Orin Nano

Custom-built PyTorch with CUDA 12.6 and cuDNN 9.3 support, specifically compiled for NVIDIA Jetson Orin Nano devices running JetPack 6.2.

Platform JetPack Python CUDA cuDNN


🚨 Why This Custom Build?

TL;DR: NVIDIA's official PyTorch wheels for Jetson are built with cuDNN 8, but JetPack 6.2 ships with cuDNN 9.3. This incompatibility causes the official wheels to fail on JetPack 6.2 systems.

The Problem

  • JetPack 6.2 includes cuDNN 9.3.0 (modern version)
  • NVIDIA's official Jetson PyTorch wheels are compiled against cuDNN 8.x (older version)

The Solution

This repository provides a custom-built PyTorch 2.3.0 compiled specifically for JetPack 6.2 with:

  • βœ… CUDA 12.6 support (matches JetPack 6.2)
  • βœ… cuDNN 9.3.0 support (matches JetPack 6.2)
  • βœ… Optimized for Jetson Orin architecture (SM 8.7)
  • βœ… Full PyTorch functionality verified

Compatibility Matrix

Component JetPack 6.2 NVIDIA Official Wheels This Custom Build
CUDA 12.6 12.x βœ… 12.6
cuDNN 9.3.0 8.x ❌ βœ… 9.3.0
Python 3.10 3.8-3.10 βœ… 3.10
Architecture ARM64 ARM64 βœ… ARM64 (Orin optimized)

🎯 Quick Install

Prerequisites

  • Hardware: NVIDIA Jetson Orin Nano (or Orin NX/AGX)
  • OS: Ubuntu 22.04
  • JetPack: 6.2 (R36.4.4 or later)
  • Python: 3.10.x
  • Storage: 2GB+ free disk space

Installation (3 steps)

# 1. Download the latest release
wget https://github.com/YeQiao/pytorch-jetson-orin-nano/releases/download/v2.3.0-jetson/pytorch-2.3.0-jetson-orin-nano.tar.gz

# 2. Extract
tar -xzf pytorch-2.3.0-jetson-orin-nano.tar.gz
cd pytorch-jetson-dist

# 3. Run automated installer
./install_pytorch.sh

The installer will:

  • βœ… Check system requirements
  • βœ… Install Python dependencies
  • βœ… Fix library compatibility issues
  • βœ… Install PyTorch wheel
  • βœ… Verify the installation
  • βœ… Run tests (optional)

Verify Installation

python3 -c "import torch; print(f'PyTorch {torch.__version__}'); print(f'CUDA available: {torch.cuda.is_available()}')"

Expected output:

PyTorch 2.3.0a0+git97ff6cf
CUDA available: True

πŸ“¦ What's Included

The distribution package contains:

pytorch-jetson-dist/
β”œβ”€β”€ torch-2.3.0a0+git97ff6cf-cp310-cp310-linux_aarch64.whl  # PyTorch wheel (195 MB)
β”œβ”€β”€ install_pytorch.sh                # Automated installer
β”œβ”€β”€ test_pytorch.py                   # Comprehensive test suite (8 tests)
β”œβ”€β”€ requirements.txt                  # Python dependencies
β”œβ”€β”€ README.md                         # Complete documentation
β”œβ”€β”€ QUICKSTART.md                     # Quick installation guide
└── DISTRIBUTION_GUIDE.md             # Deployment options

πŸ”§ Build Information

This wheel was built from PyTorch source with the following configuration:

Build Environment

  • Base System: Jetson Orin Nano with JetPack 6.2
  • CUDA: 12.6 (/usr/local/cuda-12.6)
  • cuDNN: 9.3.0 (/usr/lib/aarch64-linux-gnu)
  • Python: 3.10
  • Compiler: GCC 11.2.0

Build Flags

USE_CUDA=1                      # Enable CUDA support
USE_CUDNN=1                     # Enable cuDNN acceleration
USE_NCCL=0                      # NCCL not available on Jetson
USE_DISTRIBUTED=0               # Distributed training disabled
TORCH_CUDA_ARCH_LIST="8.7"      # Orin GPU architecture
MAX_JOBS=2                      # Prevent OOM during compilation

Version Information

  • PyTorch: 2.3.0a0+git97ff6cf
  • CUDA Runtime: 12.6
  • cuDNN: 9.3.0
  • Python: 3.10
  • Platform: Linux ARM64 (aarch64)
  • Build Date: October 2025

πŸ“‹ System Requirements

Minimum Requirements

  • Jetson Orin Nano (4GB or 8GB)
  • JetPack 6.2 (R36.4.4)
  • Python 3.10
  • 2GB free disk space
  • 1GB free RAM (for installation)

Recommended Requirements

  • Jetson Orin Nano 8GB
  • Active cooling
  • Swap space enabled (4GB+)
  • Fast storage (NVMe SSD preferred)

Compatible Devices

  • βœ… Jetson Orin Nano (4GB/8GB)
  • βœ… Jetson Orin NX (8GB/16GB)
  • βœ… Jetson AGX Orin (32GB/64GB)

Note: All must be running JetPack 6.2 with cuDNN 9.3


πŸ› Troubleshooting

Common Issues

Issue 1: GLIBCXX_3.4.30 not found

Error:

ImportError: /lib/libstdc++.so.6: version 'GLIBCXX_3.4.30' not found

Solution:

cd $CONDA_PREFIX/lib  # or your Python lib directory
mv libstdc++.so.6 libstdc++.so.6.backup
ln -sf /usr/lib/aarch64-linux-gnu/libstdc++.so.6 libstdc++.so.6

Note: The automated installer handles this automatically.

Issue 2: CUDA Not Available

Error: torch.cuda.is_available() returns False

Solution:

# Verify CUDA installation
ls -la /usr/local/cuda-12.6

# Check environment variables
export CUDA_HOME=/usr/local/cuda-12.6
export LD_LIBRARY_PATH=/usr/local/cuda-12.6/lib64:$LD_LIBRARY_PATH
export PATH=/usr/local/cuda-12.6/bin:$PATH

# Verify cuDNN
ldconfig -p | grep cudnn

Issue 3: Import Error - Symbol Not Found

Error: Symbol cuDNNGetXXX not found

Cause: You're trying to use an official wheel built for cuDNN 8

Solution: Use this custom build instead (built for cuDNN 9.3)

Issue 4: Python Version Mismatch

Error: Wheel is not compatible

Cause: This wheel requires Python 3.10

Solution:

# Check Python version
python3 --version  # Should show 3.10.x

# If using conda
conda create -n pytorch python=3.10
conda activate pytorch

Issue 5: Out of Memory During Installation

Solution:

# Enable swap
sudo fallocate -l 4G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

πŸ“– Usage Examples

Basic Example

import torch

# Create tensors
x = torch.randn(3, 3)
y = torch.randn(3, 3)

# Move to GPU
x = x.cuda()
y = y.cuda()

# Perform operations
z = torch.mm(x, y)
print(z)

Neural Network Example

import torch
import torch.nn as nn
import torch.optim as optim

# Define model
class SimpleNet(nn.Module):
    def __init__(self):
        super().__init__()
        self.fc1 = nn.Linear(784, 128)
        self.fc2 = nn.Linear(128, 10)
    
    def forward(self, x):
        x = torch.relu(self.fc1(x))
        x = self.fc2(x)
        return x

# Create model and move to GPU
model = SimpleNet().cuda()

# Loss and optimizer
criterion = nn.CrossEntropyLoss()
optimizer = optim.Adam(model.parameters(), lr=0.001)

# Training loop
for epoch in range(10):
    # Your training code here
    outputs = model(inputs)
    loss = criterion(outputs, labels)
    
    optimizer.zero_grad()
    loss.backward()
    optimizer.step()

Computer Vision Example

import torch
import torch.nn as nn

# Download and use pre-trained model
# First install torchvision: pip install torchvision
from torchvision import models, transforms
from PIL import Image

# Load pre-trained ResNet
model = models.resnet18(pretrained=True).cuda()
model.eval()

# Prepare image
transform = transforms.Compose([
    transforms.Resize(256),
    transforms.CenterCrop(224),
    transforms.ToTensor(),
    transforms.Normalize(mean=[0.485, 0.456, 0.406],
                       std=[0.229, 0.224, 0.225])
])

# Inference
img = Image.open('image.jpg')
img_tensor = transform(img).unsqueeze(0).cuda()

with torch.no_grad():
    output = model(img_tensor)
    pred = output.argmax(dim=1)

πŸ§ͺ Testing

Run the included test suite to verify all functionality:

cd pytorch-jetson-dist
python3 test_pytorch.py

Test Coverage:

  1. βœ… PyTorch Import
  2. βœ… Version Information
  3. βœ… CUDA Support Detection
  4. βœ… Basic Tensor Operations
  5. βœ… CUDA Tensor Operations
  6. βœ… Neural Network Forward/Backward
  7. βœ… Autograd Functionality
  8. βœ… Training Loop

πŸ“š Additional Resources

Official Documentation

Community

Related Projects


🀝 Contributing

Reporting Issues

Found a problem? Please open an issue with:

  • Your JetPack version (cat /etc/nv_tegra_release)
  • Python version (python3 --version)
  • Error message and stack trace
  • Steps to reproduce

Requesting Features

Have a suggestion? Open an issue describing:

  • The feature you'd like
  • Why it would be useful
  • Example use case

πŸ“„ License

This wheel is built from PyTorch source code, which is licensed under BSD-3-Clause.

Disclaimer

This is an unofficial build created for compatibility with JetPack 6.2. For official NVIDIA Jetson PyTorch support, see:


πŸ™ Acknowledgments

  • PyTorch Team - For the incredible deep learning framework
  • NVIDIA - For Jetson platform and development tools
  • Jetson Community - For feedback and testing
  • Open Source Community - For making this possible

πŸ“Š Performance Notes

Expected Performance

On Jetson Orin Nano 8GB:

  • ResNet-18 Inference: ~30-40 FPS (224x224 images)
  • MobileNetV2 Inference: ~60-80 FPS (224x224 images)
  • Training Small Models: Feasible with batch size 8-16
  • Memory Usage: ~500MB base + model size

Optimization Tips

  1. Use Mixed Precision: torch.cuda.amp for faster training
  2. Optimize Batch Size: Start small and increase gradually
  3. Enable CUDA Graphs: For repetitive operations
  4. Use TensorRT: Convert models for production inference
  5. Monitor Temperature: Use active cooling for sustained workloads

πŸ”„ Updates

Current Version: v2.3.0-jetson

  • Release Date: October 2025
  • PyTorch Version: 2.3.0a0+git97ff6cf
  • Status: Stable, production-ready

Planned Updates

  • PyTorch 2.4+ when available
  • TorchVision pre-built wheel
  • TorchAudio support
  • Performance benchmarks
  • Docker container

Stay Updated

Watch this repository for new releases and updates.


πŸ’‘ FAQ

Q: Why not use NVIDIA's official wheels? A: NVIDIA's wheels are built for cuDNN 8, but JetPack 6.2 includes cuDNN 9.3, causing incompatibility.

Q: Is this stable for production? A: Yes, all core features have been tested. However, test thoroughly for your specific use case.

Q: Can I use this with TorchVision? A: Yes! Install with pip install torchvision after installing this PyTorch build.

Q: Will this work on Jetson Xavier or Nano? A: No, this is specifically for Orin devices with JetPack 6.2. Xavier/Nano use different architectures.

Q: How do I upgrade? A: Download the new release and run the installer again. It will upgrade automatically.

Q: Can I build this myself? A: Yes! See the build configuration section. Build time is ~6-8 hours on Orin Nano.


Built with ❀️ for the Jetson Community

Download Latest Release β€’ Report Bug β€’ Request Feature

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors