Pytorch is an open-source machine-learning library. It is a framework that has been built upon the torch library. Using PyTorch you can build a computer vision and Natural Processing Language ( NLP ) application. If you have already installed pytorch in your system and want to uninstall it from your system then this post is for you. In this entire tutorial, you will learn how to uninstall PyTorch on different terminals.
How to uninstall PyTorch with Anaconda?
If you have installed Pytorch on Anaconda and want to uninstall it then you can use the conda command for that. Open your Anaconda terminal and type the following conda command.
conda uninstall pytorch
It will successfully uninstall the Pytorch from the anaconda packages.
Uninstall PyTorch using pip
There is also another way to remove Pytorch from the Python packages. To do you have to use the pip command. Pip is a Python module that is already installed with the Python module.
Before using the pip command you have to check the version of python. If your system has Python 3. xx installed then you will use the pip3 command. And if your system has python 2. xx then you will use the pip command.
To check the version of the python you have to run the below command.
My system has python 3. xx installed, so I will use the pip3 command to uninstall PyTorch. If your system has python 2.xx then use the pip unistall torch command.
Run the below command to uninstall the PyTorch using pip.
pip3 uninstall torch
Uninstall PyTorch from Pycharm
If you have installed PyTorch in Pycharm, then you can easily uninstall PyTorch. Follow the below steps to uninstall PyTorch from Pycharm.
Step 1: Go to File and click Settings.
Step 2: Go to the project Interpreter.
Here you will find all the packages installed in your PyTorch environment.
Step 3: Search for the torch package.
Step 4: Select on torch package and click on the ” – “ sign to uninstall the torch package.
Uninstall using easy_install
You can also uninstall Pytorch if you have installed the module using the easy_install. To do so you have to easy_install -m command. Open your terminal and type the below command to uninstall the Pytorch from the system.
easy_install -m pytorch
It will uninstall Pytorch from your system.
Uninstall from the source
If you installed PyTorch from the source you can uninstall it by removing the Pytorch folder from your system. As its all dependencies are in the folder they will automatically be removed when you remove that folder.
How to uninstall pytorch in Ubuntu
pip uninstall torch
conda uninstall torchvision -c pytorch
After the uninstallation, you can verify whether Pytorch is installed or not using the below command.
Pytorch is a popular machine-learning library for OpenCV and NLP applications. This framework is managed by open-source community and built by Facebook. If you want to uninstall Pytroch from your system then the above methods will work for you. I hope you have liked this tutorial. If you have any queries then you can contact us for more help.
Frequently Asked Questions
1. How to install Pytorch?
You can install PyTorch using the pip command. But before that check the version of Python. If your Python version is 3. xx then use the pip3 command and if it is 2. xx then use the pip command.
For python 3. xx
pip3 install torch
For python 2. xx
pip install torch
If you want to install Pytorch in Pycharm ide then you can read how to install Pytorch in Pycharm. There you will know the various ways to install the Pytorch module in the IDE.
2. How to check the Version of Pytorch?
Once you have installed Pytorch in your system you can easily check the version of it using the below methods.
1. Using import
The first way to check is the use of the import statement. Here you will first import the torch library and then find its version. Use the below lines of code to find its version.
import torch torch.__version__
2. Using pip
The second method to check the version of Pytorch is the use of the pip command. Here you will use pip list with the grep command to find the details of the pytorch.
pip list | grep torch
Join our list
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.