在 CentOS 上卸载 PyTorch,主要取决于你当初是用 pip 还是 conda 安装的。下面分别说明。
pip list | grep torch
通常会有类似:
torchtorchvisiontorchaudioxformers(如果有)pip uninstall torch torchvision torchaudio
如果还装了其他相关包,一并卸载:
pip uninstall torch torchvision torchaudio xformers
✅ 如果你用的是 pip3:
pip3 uninstall torch torchvision torchaudio
python -c "import torch"
如果提示 ModuleNotFoundError,说明已卸载成功。
conda list | grep torch
conda remove pytorch torchvision torchaudio
或者完整一点:
conda remove pytorch torchvision torchaudio cudatoolkit
如果你是用独立环境安装的:
conda deactivate
conda env remove -n your_env_name
pip cache purge
conda clean -a
CentOS 常同时存在:
pythonpython3pippip3建议确认:
which python
which pip
python --version
然后确保卸载的是对应版本的 PyTorch。
说明:
解决:
python -c "import torch; print(torch.__file__)"
找到位置,确认环境。
如果你愿意,可以告诉我:
我可以给你 精确到命令级别 的卸载方案。