Ubuntu 16.04系统下如何卸载Caffe及其相关依赖?
Hey there, let's get your Caffe uninstalled properly since make clean only scratches the surface. Here's a step-by-step guide tailored to Ubuntu 16.04:
Since you tried make clean, it’s likely you compiled Caffe from source. Let’s wipe all build artifacts and the source directory entirely:
- First, navigate to your Caffe source folder (replace
~/caffewith your actual path):cd ~/caffe - Run the more thorough clean command to erase all compiled files, configuration outputs, and build logs:
make distclean - Delete the entire Caffe source directory to remove every leftover file:
rm -rf ~/caffe
Caffe relies on a host of system packages. Be cautious here—some dependencies might be used by other software, so only remove packages you’re certain you don’t need anymore:
- List all installed packages related to Caffe and its core dependencies:
dpkg --get-selections | grep -E "caffe|protobuf|leveldb|snappy|opencv|hdf5|atlas|gflags|glog|lmdb" - Purge the packages you want to remove (this deletes the packages and their configuration files):
sudo apt purge libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler libatlas-base-dev libgflags-dev libgoogle-glog-dev liblmdb-dev - Clean up any unused dependencies that were installed exclusively for Caffe:
sudo apt autoremove
If you set up Caffe’s Python bindings or installed related packages via pip, let’s clean those up too:
- Uninstall the Caffe Python package directly:
pip uninstall caffe-python - If you installed packages like
numpy,scipy, ormatplotlibspecifically for Caffe, you can uninstall them withpip uninstall <package-name>—just double-check they aren’t needed for other projects first.
Finally, eliminate any leftover configuration or cache files:
- Clear the system package cache:
sudo apt clean - Remove system-wide Caffe configuration directories (if they exist):
sudo rm -rf /etc/caffe - Delete user-specific Caffe cache or config files:
rm -rf ~/.caffe
If you installed Caffe using Ubuntu’s package manager instead of compiling from source, use these simpler commands:
sudo apt purge caffe-cpu # Replace with caffe-gpu if you used the GPU version sudo apt autoremove sudo apt clean
内容的提问来源于stack exchange,提问作者Huyen

