Question

[Solved] How can l uninstall PyTorch?

I can’t find any command to uninstall and remove all PyTorch dependencies. Even on the pytorch.org website.

I installed PyTorch with

conda install pytorch torchvision cuda80 -c soumith
Enquirer: vincent

||

Solution #1:

From the anaconda docs, you can uninstall with conda uninstall

Try

conda uninstall pytorch torchvision cuda80 -c soumith

Alternatively, the pytorch docs suggest

conda uninstall pytorch
pip uninstall torch
pip uninstall torch # run this command twice
Respondent: wpercy

Solution #2:

Here’s the correct set of commands according to CONTRIBUTING.md from the pytorch github repo:


Uninstall all existing pytorch installs

conda uninstall pytorch
pip uninstall torch
pip uninstall torch # run this command twice

Solution #3:

You can also use

conda remove torch torchvision

Please note that this will remove the specified packages (here: torch and torchvision) and any other package which depends on torch and torchvision, if there’re any.

P.S. conda uninstall is an alias to conda remove.

Respondent: kmario23

Solution #4:

You can safely delete the pytorch installation using the following conda command:

conda uninstall pytorch-cpu torchvision-cpu pytorch

Solution #5:

I recently found a good tool!

pip install pip-autoremove

This tool can delete all the tools you need to delete. For example, if you need to delete the torch, then it can delete torchvision as well!

Usage: pip-autoremove [OPTION]... [NAME]...

Options:
  --version     show program's version number and exit
  -h, --help    show this help message and exit
  -l, --list    list unused dependencies, but don't uninstall them.
  -L, --leaves  list leaves (packages which are not used by any others).
  -y, --yes     don't ask for confirmation of uninstall deletions.
Respondent: Dany

Solution #6:

Perhaps @Schütze meant with “This does not remove all the files.” that there are still files in the Anacondapkgs folder.

Mind that you can remove the tar.b2 and the folder of the now unused packages in Anacondapkgs. I uninstalled pytorch cuda version (because my display driver does not support cuda) and there were huge files there:

  • pytorch-1.5.0-py3.7_cuda102_cudnn7_0.tar.bz2
  • pytorch-1.5.0-py3.7_cuda102_cudnn7_0
  • cudatoolkit-10.2.89-h74a9793_1.conda
  • cudatoolkit-10.2.89-h74a9793_1

This makes 3 GB altogether! Either do this manually, or with a command:

to delete all unneeded packages:

    conda clean --yes --packages --dry-run

to delete all unneeded tar.bz2 / conda

    conda clean --yes --tarballs --dry-run

to delete all together

    conda clean --yes --all --dry-run

First use parameter –dry-run to see what will happen. Afterwards, run without –dry-run.
This has cleaned about 3.5 GB of the used 7 GB disk space that was used by Anacondapkgs.

References:
How to uninstall all unused packages in a conda virtual environment? and
Anaconda Python: Delete .tar.gz in pkgs

Respondent: questionto42

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy