YouTip LogoYouTip

Pytorch Install

PyTorch is a popular deep learning framework that supports CPU and GPU computation. ### Supported Operating Systems * **Windows**: Windows 10 or later (64-bit) * **macOS**: macOS 10.15 (Catalina) or later * **Linux**: Major distributions (Ubuntu 18.04+, CentOS 7+, RHEL 7+, etc.) ### Python Version Requirements * **Recommended version**: Python 3.8 - 3.11 * **Minimum requirement**: Python 3.7 * **Note**: Python 3.12+ support may be limited, it is recommended to use stable versions ### Hardware Requirements * **CPU**: x86_64 processor with SSE4.2 instruction set support * **Memory**: At least 4GB RAM (8GB+ recommended) * **Storage**: At least 3GB available space * **GPU** (optional): NVIDIA GPU with CUDA Compute Capability 3.5+ ### CUDA Compatibility (GPU Version) | PyTorch Version | Supported CUDA Versions | Recommended CUDA Version | | --- | --- | --- | | 2.1.x | 11.8, 12.1 | 12.1 | | 2.0.x | 11.7, 11.8 | 11.8 | | 1.13.x | 11.6, 11.7 | 11.7 | * * * ## Pre-Installation Preparation ### Checking System Information **Windows:** # Check Windows version winver # Check Python version python --version # Check if NVIDIA GPU exists nvidia-smi **macOS** # Check macOS version sw_vers # Check Python version python3 --version # Check if compatible GPU exists (Apple Silicon) system_profiler SPDisplaysDataType **Linux** # Check distribution information cat /etc/os-release # Check Python version python3 --version # Check NVIDIA GPU nvidia-smi # Check CUDA version (if installed) nvcc --version ### Python Environment Management **Using Anaconda/Miniconda:** # Download and install Miniconda # Windows: https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe # macOS: https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh # Linux: https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh # Create dedicated environment conda create -n pytorch_env python=3.10 conda activate pytorch_env ### Using venv (Built-in Python) # Create virtual environment python -m venv pytorch_env # Activate environment # Windows pytorch_envScriptsactivate # macOS/Linux source pytorch_env/bin/activate * * * ## Installing PyTorch PyTorch officially provides several installation methods, which can be installed via pip or conda. ### CPU Version Installation **Using pip to install pytorch:** # Latest stable version pip install torch torchvision torchaudio # Specify version pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 # CPU only version (smaller installation package) pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu **Using conda to install:** If you use Anaconda or Miniconda to manage your Python environment, using conda to install PyTorch may be simpler and more efficient. # Install from conda-forge conda install pytorch torchvision torchaudio cpuonly -c pytorch # Or from conda-forge channel conda install pytorch torchvision torchaudio -c conda-forge If you are not familiar with Anaconda, please refer to: (#) ### Install via PyTorch Official Website Visit PyTorch's official website [https://pytorch.org/get-started/locally/](https://pytorch.org/get-started/locally/), the website provides a convenient tool that can recommend installation commands based on your system configuration (operating system, package manager, Python version, and CUDA version). !(#) ### Install from Source Code If you need to install PyTorch from source code, or want to try the latest development version, you can use the following commands: git clone --recursive https://github.com/pytorch/pytorch cd pytorch python setup.py install This will clone PyTorch's source code from GitHub and install it using setup.py. ### GPU Version Installation (CUDA) **Install CUDA (if needed):** # Ubuntu/Deb
← Pytorch Neural NetworkPytorch Tutorial β†’