在 CentOS 上卸载 PyTorch,主要取决于你当初是用 pip 还是 conda 安装的。下面分情况说明。
pip list | grep torch
或
pip3 list | grep torch
pip uninstall torch torchvision torchaudio
如果有其他相关包(如 torchtext),也一起卸载:
pip uninstall torchtext
python -c "import torch"
如果提示 ModuleNotFoundError,说明已卸载成功。
conda activate your_env_name
conda uninstall pytorch torchvision torchaudio
conda clean -pt
如果是 pip 安装且担心残留:
pip cache purge
如果是系统级安装(不推荐,但有过):
sudo pip uninstall torch
确认你用的是哪个 Python:
which python
which pip
如果你在 venv 或 conda 环境中,一定要先激活环境再卸载。
如果你能告诉我:
我可以给你更精确的命令。