Python 如何卸载 PyTorch?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43664444/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can l uninstall PyTorch?
提问by vincent
I can't find any command to uninstall and remove all PyTorch dependencies. Even on the pytorch.orgwebsite.
我找不到任何卸载和删除所有 PyTorch 依赖项的命令。甚至在pytorch.org网站上。
I installed PyTorch with
我安装了 PyTorch
conda install pytorch torchvision cuda80 -c soumith
回答by wpercy
From the anaconda docs, you can uninstall with conda uninstall
从anaconda docs,您可以卸载conda uninstall
Try
尝试
conda uninstall pytorch torchvision cuda80 -c soumith
Alternatively, the pytorch docssuggest
或者,pytorch 文档建议
conda uninstall pytorch
pip uninstall torch
pip uninstall torch # run this command twice
回答by kmario23
You can also use
你也可以使用
conda remove torch torchvision
Please note that this will removethe specified packages (here: torch and torchvision) and any other package which depends on torch and torchvision, if there're any.
请注意,这将删除指定的包(此处:torch 和 torchvision)以及任何其他依赖于torch 和 torchvision 的包(如果有)。
P.S. conda uninstall
is an alias to conda remove
.
PSconda uninstall
是conda remove
.
回答by 190290000 Ruble Man
Here's the correct set of commands according to CONTRIBUTING.mdfrom the pytorch github repo:
根据来自 pytorch github repo 的CONTRIBUTING.md,这是正确的命令集:
Uninstall all existing pytorch installs
卸载所有现有的 pytorch 安装
conda uninstall pytorch
pip uninstall torch
pip uninstall torch # run this command twice
回答by srilekha palepu - Intel
You can safely delete the pytorch installation using the following conda command:
您可以使用以下 conda 命令安全地删除 pytorch 安装:
conda uninstall pytorch-cpu torchvision-cpu pytorch
回答by Dany
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!
这个工具可以删除所有你需要删除的工具。例如,如果您需要删除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.
回答by Lorenz
Perhaps @Schütze meant with "This does not remove all the files." that there are still files in the Anaconda\pkgs folder.
也许@Schütze 的意思是“这不会删除所有文件”。Anaconda\pkgs 文件夹中仍有文件。
Mind that you can remove the tar.b2 and the folder of the now unused packages in Anaconda\pkgs. I uninstalled pytorch cuda version (because my display driver does not support cuda) and there were huge files there:
请注意,您可以删除 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
- 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:
这总共有 3 GB!手动执行此操作,或使用命令执行此操作:
to delete all unneeded packages:
删除所有不需要的包:
conda clean --yes --packages --dry-run
to delete all unneeded tar.bz2 / conda
删除所有不需要的 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 Anaconda\pkgs.
首先使用参数 --dry-run 看看会发生什么。之后,在没有 --dry-run 的情况下运行。这已经清除了 Anaconda\pkgs 使用的 7 GB 磁盘空间中的大约 3.5 GB。
References: How to uninstall all unused packages in a conda virtual environment?and Anaconda Python: Delete .tar.gz in pkgs
参考: 如何在 conda 虚拟环境中卸载所有未使用的包?和 Anaconda Python:删除 pkgs 中的 .tar.gz