28

我找不到任何命令来卸载和删除所有 PyTorch 依赖项。甚至在pytorch.org网站上。

我安装了 PyTorch

conda install pytorch torchvision cuda80 -c soumith
4

6 回答 6

37

anaconda docs,您可以卸载conda uninstall

尝试

conda uninstall pytorch torchvision cuda80 -c soumith

或者,pytorch 文档建议

conda uninstall pytorch
pip uninstall torch
pip uninstall torch # run this command twice
于 2017-04-27T17:41:19.040 回答
11

这是根据pytorch github repo中的CONTRIBUTING.md的正确命令集:


卸载所有现有的 pytorch 安装

conda uninstall pytorch
pip uninstall torch
pip uninstall torch # run this command twice
于 2018-03-27T20:08:34.770 回答
8

你也可以使用

conda remove torch torchvision

请注意,这将删除指定的包(此处为:torch 和 torchvision)以及任何其他依赖于torch 和 torchvision的包(如果有的话)。

PSconda uninstallconda remove.

于 2017-12-10T23:40:41.033 回答
2

也许@Schütze 的意思是“这不会删除所有文件”。Anaconda\pkgs 文件夹中仍有文件。

请注意,您可以删除 tar.b2 和 Anaconda\pkgs 中现在未使用的软件包的文件夹。我卸载了 pytorch cuda 版本(因为我的显示驱动程序不支持 cuda)并且那里有巨大的文件:

  • 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

这总共有 3 GB!手动执行此操作,或使用命令:

删除所有不需要的包:

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

删除所有不需要的 tar.bz2 / conda

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

一起删除

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

首先使用参数 --dry-run 看看会发生什么。之后,在没有 --dry-run 的情况下运行。这已经清理了 Anaconda\pkgs 使用的 7 GB 磁盘空间中的大约 3.5 GB。

参考: 如何在 conda 虚拟环境中卸载所有未使用的包?Anaconda Python:删除 pkgs 中的 .tar.gz

于 2020-05-04T18:38:01.653 回答
0

您可以使用以下 conda 命令安全地删除 pytorch 安装:

conda uninstall pytorch-cpu torchvision-cpu pytorch
于 2019-02-01T09:46:25.647 回答
-1

我最近发现了一个好工具!

pip install pip-autoremove

这个工具可以删除你需要删除的所有工具。例如,如果你需要删除torch,那么它也可以删除torchvision!

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.
于 2019-03-18T03:33:22.610 回答