在 Ubuntu 上卸载 PyTorch,通常取决于你是用 pip 还是 conda 安装的。下面分别说明:
pip list | grep torch
pip uninstall torch torchvision torchaudio
(如果还装了其他如 torchtext,一并卸载)
python -c "import torch"
如果提示 ModuleNotFoundError,说明已卸载成功。
conda activate your_env_name
conda uninstall pytorch torchvision torchaudio
conda clean -pt
如果你不确定之前怎么装的,可以都试一遍:
pip uninstall torch torchvision torchaudio
conda uninstall pytorch torchvision torchaudio
如果你是用 runfile 安装的系统级 CUDA,而不是 conda 的:
sudo /usr/local/cuda-X.Y/bin/uninstall_cuda_X.Y.pl
sudo rm -rf /usr/local/cuda*
⚠️ 一般不建议随意删系统 CUDA,除非你确定不用了。
如果你愿意,可以告诉我:
python -c "import torch; print(torch.__version__)" 的结果我可以给你更精确的卸载命令。