在 CentOS 上卸载 PyTorch,主要取决于你当初是用 pip 还是 conda 安装的。下面分别说明。
pip list | grep torch
一般包括:
torchtorchvisiontorchaudio执行:
pip uninstall torch torchvision torchaudio -y
pip list | grep torch
如果没有输出,说明已卸载。
conda activate your_env_name
conda uninstall pytorch torchvision torchaudio -y
conda list | grep torch
如果是 CentOS 自带 Python(如 /usr/bin/python3)安装的:
sudo pip3 uninstall torch torchvision torchaudio -y
⚠️ 注意:不建议直接动系统 Python,推荐用虚拟环境或 conda。
有时会有缓存或模型文件:
rm -rf ~/.cache/torch
import torch 还能用?可能是:
解决:
which python
which pip
python -c "import torch"
如果你能告诉我:
我可以给你更精确的命令。