Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy
 

How to install torch via python pip




torch - Tensors and Dynamic neural networks in Python with strong GPU acceleration, it belongs to Classifiers:

- Development Status :: 5 - Production/Stable
- Intended Audience :: Education
- Intended Audience :: Science/Research
- License :: OSI Approved :: BSD License
- Programming Language :: C
- Programming Language :: C++
- Programming Language :: Python
- Programming Language :: Python :: 3
- Programming Language :: Python :: 3.7
- Programming Language :: Python :: 3.8
- Programming Language :: Python :: 3.9
- Topic :: Scientific/Engineering
- Topic :: Scientific/Engineering :: Artificial Intelligence
- Topic :: Scientific/Engineering :: Mathematics
- Topic :: Software Development
- Topic :: Software Development :: Libraries
- Topic :: Software Development :: Libraries :: Python Modules

When you know about this project and you want to new install torch to support your project or you get trouble as ModuleNotFoundError: No module named "torch" or ImportError: cannot import name "torch" in your project, let follow this tutorial to install torch



Installation:

Step 1: First, ensure you installed pip in your os, to check pip has been installed on your computer

In Windows (CMD):

py -m pip --version

In Unix/macOS:

python3 -m pip --version

Ensure pip, setuptools, and wheel are up to date:

In Windows (CMD):

py -m pip install --upgrade pip setuptools wheel

In Unix/macOS:

python3 -m pip install --upgrade pip setuptools wheel


Optional - If you want to install in virtual environment:

In Windows (CMD):

- Install virtualenv - if you installed it, please ignore

py -m pip install --user virtualenv

- Create a virtual environment

py -m venv test_torch_env

- Active the virtual environment

test_torch_env\Scripts\active

In Unix/macOS:

- Install virtualenv - if you installed it, please ignore

pip3 install virtualenv

- Create a virtual environment

python3 -m venv test_torch_env

- Active the virtual environment

source test_torch_env/bin/active


Step 2: OK, now, let flow below content to start the installation torch

To install torch on Windows(CMD):

py -m pip install torch

To install torch on Unix/macOs:

pip install torch


Step 3: If you want to install a specific torch version, add ==<torch version> to the end command line

Example:

pip install torch==1.0.0


Please see the version list below table:

VersionReleased dateCommand
torch 1.12.12022-08-05T17:21:05Windows:

py -m pip install torch==1.12.1

Unix/macOs:

pip install torch==1.12.1

torch 1.12.02022-06-28T16:20:35Windows:

py -m pip install torch==1.12.0

Unix/macOs:

pip install torch==1.12.0

torch 1.11.02022-03-10T16:37:26Windows:

py -m pip install torch==1.11.0

Unix/macOs:

pip install torch==1.11.0

torch 1.10.22022-01-27T19:29:53Windows:

py -m pip install torch==1.10.2

Unix/macOs:

pip install torch==1.10.2

torch 1.10.12021-12-15T21:58:45Windows:

py -m pip install torch==1.10.1

Unix/macOs:

pip install torch==1.10.1

torch 1.10.02021-10-21T14:45:53Windows:

py -m pip install torch==1.10.0

Unix/macOs:

pip install torch==1.10.0

torch 1.9.12021-09-20T22:30:00Windows:

py -m pip install torch==1.9.1

Unix/macOs:

pip install torch==1.9.1

torch 1.9.02021-06-15T15:09:35Windows:

py -m pip install torch==1.9.0

Unix/macOs:

pip install torch==1.9.0

torch 1.8.12021-03-25T15:54:32Windows:

py -m pip install torch==1.8.1

Unix/macOs:

pip install torch==1.8.1

torch 1.8.02021-03-04T17:05:59Windows:

py -m pip install torch==1.8.0

Unix/macOs:

pip install torch==1.8.0

torch 1.7.12020-12-10T16:19:45Windows:

py -m pip install torch==1.7.1

Unix/macOs:

pip install torch==1.7.1

torch 1.7.02020-10-27T15:49:06Windows:

py -m pip install torch==1.7.0

Unix/macOs:

pip install torch==1.7.0

torch 1.6.02020-07-28T15:50:50Windows:

py -m pip install torch==1.6.0

Unix/macOs:

pip install torch==1.6.0

torch 1.5.12020-06-18T16:29:35Windows:

py -m pip install torch==1.5.1

Unix/macOs:

pip install torch==1.5.1

torch 1.5.02020-04-21T16:01:10Windows:

py -m pip install torch==1.5.0

Unix/macOs:

pip install torch==1.5.0

torch 1.4.02020-01-15T23:22:37Windows:

py -m pip install torch==1.4.0

Unix/macOs:

pip install torch==1.4.0

torch 1.3.12019-11-07T17:45:55Windows:

py -m pip install torch==1.3.1

Unix/macOs:

pip install torch==1.3.1

torch 1.3.0.post22019-10-22T18:06:28Windows:

py -m pip install torch==1.3.0.post2

Unix/macOs:

pip install torch==1.3.0.post2

torch 1.3.02019-10-10T15:16:45Windows:

py -m pip install torch==1.3.0

Unix/macOs:

pip install torch==1.3.0

torch 1.2.02019-08-08T16:01:26Windows:

py -m pip install torch==1.2.0

Unix/macOs:

pip install torch==1.2.0

torch 1.1.0.post22019-06-21T21:47:40Windows:

py -m pip install torch==1.1.0.post2

Unix/macOs:

pip install torch==1.1.0.post2

torch 1.1.02019-04-30T23:21:02Windows:

py -m pip install torch==1.1.0

Unix/macOs:

pip install torch==1.1.0

torch 1.0.1.post22019-02-08T19:05:01Windows:

py -m pip install torch==1.0.1.post2

Unix/macOs:

pip install torch==1.0.1.post2

torch 1.0.12019-02-05T00:38:13Windows:

py -m pip install torch==1.0.1

Unix/macOs:

pip install torch==1.0.1

torch 1.0.02018-12-07T18:56:01Windows:

py -m pip install torch==1.0.0

Unix/macOs:

pip install torch==1.0.0


Step 4: Otherwise, you can install torch from local archives:

Download the distribution file from torch-1.12.1-cp310-none-macosx_11_0_arm64.whl or the specific torch version in the below list of distribution

After that, install by command:

On Windows(CMD):

py -m pip install <path_to_torch_downloaded_file>

On Unix/macOs:

pip install <path_to_torch_downloaded_file>


List distribution:


Project link:

- Homepage
- Download