最近我尝试在我的 ubuntu 发行版上安装 gcc 和 g++6,但出现问题,gcc 和 g++ 5.3 与 cuda 一起被卸载。我使用 aptitude 安装 cuda 修复了这个问题,并恢复了 g++ 和 gcc 以及一些库
现在每次我尝试运行,apt-get update
我apt-get dist-upgrade
都会得到这个
The following packages were automatically installed and are no longer required:
cuda-cublas-9-0 cuda-cublas-dev-9-0 cuda-cudart-9-0 cuda-cudart-dev-9-0
cuda-cufft-9-0 cuda-cufft-dev-9-0 cuda-curand-9-0 cuda-curand-dev-9-0
cuda-cusolver-9-0 cuda-cusolver-dev-9-0 cuda-cusparse-9-0
cuda-cusparse-dev-9-0 cuda-driver-dev-9-0 cuda-libraries-9-0
cuda-libraries-dev-9-0 cuda-license-9-0 cuda-misc-headers-9-0 cuda-npp-9-0
cuda-npp-dev-9-0 cuda-nvgraph-9-0 cuda-nvgraph-dev-9-0 cuda-nvml-dev-9-0
cuda-nvrtc-9-0 cuda-nvrtc-dev-9-0 freeglut3 freeglut3-dev libdrm-dev
libgl1-mesa-dev libglu1-mesa-dev libx11-xcb-dev libxcb-dri2-0-dev
libxcb-dri3-dev libxcb-glx0-dev libxcb-present-dev libxcb-randr0-dev
libxcb-render0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev
libxdamage-dev libxext-dev libxfixes-dev libxi-dev libxmu-dev libxmu-headers
libxshmfence-dev libxxf86vm-dev mesa-common-dev nvidia-modprobe
x11proto-damage-dev x11proto-dri2-dev x11proto-fixes-dev x11proto-gl-dev
x11proto-xext-dev x11proto-xf86vidmode-dev
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
bbswitch-dkms build-essential cuda cuda-9-0 cuda-command-line-tools-9-0
cuda-core-9-0 cuda-demo-suite-9-0 cuda-documentation-9-0 cuda-drivers
cuda-runtime-9-0 cuda-samples-9-0 cuda-toolkit-9-0 cuda-visual-tools-9-0
dkms g++ g++-5 gcc gcc-5 libcuda1-384 nvidia-384 nvidia-384-dev
nvidia-opencl-icd-384 nvidia-prime
The following packages will be upgraded:
albert code cpp-5 gcc-5-base libasan2 libdrm-amdgpu1 libdrm-amdgpu1:i386
libdrm-common libdrm-dev libdrm-intel1 libdrm-intel1:i386 libdrm-nouveau2
libdrm-nouveau2:i386 libdrm-radeon1 libdrm-radeon1:i386 libdrm2 libdrm2:i386
libegl1-mesa libgbm1 libgcc-5-dev libgl1-mesa-dev libgl1-mesa-dri
libgl1-mesa-dri:i386 libgl1-mesa-glx libgl1-mesa-glx:i386 libglapi-mesa
libglapi-mesa:i386 libmpx0 libobjc-5-dev libstdc++-5-dev
libwayland-egl1-mesa libxatracker2 mesa-common-dev slack-desktop
34 upgraded, 0 newly installed, 23 to remove and 0 not upgraded.
Need to get 122 MB of archives.
After this operation, 1,411 MB disk space will be freed.
看起来 cuda、gcc 和 g++ 又要被删除了。我该如何解决这个问题?
编辑:
这是破坏 gcc 和 g++ 的命令
sudo apt-get update && \\nsudo apt-get install build-essential software-properties-common -y && \\nsudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \\nsudo apt-get update && \\nsudo apt-get install gcc-snapshot -y && \\nsudo apt-get update && \\nsudo apt-get install gcc-6 g++-6 -y && \\nsudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 && \\nsudo apt-get install gcc-4.8 g++-4.8 -y && \\nsudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
答案1
Apt 使用名为恰当标记。
Apt 只会尝试自动删除依赖项。这很重要。Apt 不会自动删除您明确地说您想要安装,直到您明确表示想要卸载它。
就这么简单。
有几种方法可以告诉 apt 你想要什么。这些命令都可以改变 apt 标记:
sudo apt install packagename (also installs the package, if not already installed)
sudo apt-mark manual packagename (changes the marking only)
例如:如果您想保留cuda
和gcc
包并防止自动删除:sudo apt install cuda gcc
有关详细信息,请参阅man apt-mark