How to Uninstall PyTorch Using Pip and Conda

How to Uninstall PyTorch Using Pip and Conda

PyTorch is a popular deep-learning framework known for its flexibility and dynamic computation graph.

Its extensive ecosystem and community support make it an attractive choice for many AI and machine learning practitioners.

Uninstalling PyTorch can be necessary when transitioning to a different framework that better suits your project requirements, freeing up space, or wanting to install a different version

Let us go through how to uninstall PyTorch using Pip and Conda.

Uninstall Pytorch Using Pip

if you installed PyTorch within a virtual environment, you should activate that virtual environment first before running uninstalling PyTorch to make sure you are uninstalling it from the correct environment.

To activate a pip virtual environment on Windows, you can use this command:1

myenv\Scripts\activate

And for Mac and Linux:

source myenv/bin/activate

To uninstall PyTorch using pip, you can simply use the following command in your command prompt or terminal:

pip uninstall torch

If you also want to uninstall torchvision package, you can use:

pip uninstall torchvision

This will remove PyTorch and torchvision from your Python environment.

Uninstall Pytorch Using Conda

If you are using a conda environment, make sure you activate it before uninstalling PyTorch and torchvision. You can activate your conda environment using a command such as:2

conda activate myenv

To uninstall PyTorch using conda, run the following command in your command prompt or terminal:

conda uninstall pytorch

You may also want to remove torchvision using this command:

conda uninstall torchvision

After running these commands, PyTorch and torchvision will be uninstalled from your conda environment.

References

  1. Sukesh. (2023, October 2). How to Uninstall Pytorch ( conda, pip ,Pycharm ). Data Science Learner. https://www.datasciencelearner.com/pytorch/how-to-uninstall-pytorch-conda-pip-pycharm/ ↩︎
  2. Azam, B. S. (n.d.). How to uninstall PyTorch. https://linuxhint.com/uninstall-pytorch/ ↩︎
Published