Upgrade or uninstall cuda to allow apt-get to work

Whenever I am trying to install something, I get the following error:

The following packages have unmet dependencies:

cuda-samples-8.0 : Depends: cuda-cufft-dev-8-0 but it is not going to be installed

cuda-toolkit-8.0 : Depends: cuda-cufft-dev-8-0 but it is not going to be installed

cuda-visual-tools-8.0 : Depends: cuda-cufft-dev-8-0 but it is not going to be installed

I try sudo apt-get -f install and it says:

The following packages were automatically installed and are no longer required:
[lots of cuda 7.5 packages and some other linux ones like linux-image-4.2.0-27-generic]
The following extra packages will be installed:
cuda-cufft-dev-8-0
The following NEW packages will be installed:
cuda-cufft-dev-8-0

Do you want to continue?

I tell it to continue and I get this error:

(Reading database ... 731426 files and directories currently installed.)
Preparing to unpack .../cuda-cufft-dev-8-0_8.0.61-1_amd64.deb ...
Unpacking cuda-cufft-dev-8-0 (8.0.61-1) ...
dpkg-deb (subprocess): decompressing archive member: internal gzip read error: '<fd:4>: incorrect data check'
dpkg-deb: error: subprocess <decompress> returned error exit status 2
dpkg: error processing archive /var/cache/apt/archives/cuda-cufft-dev-8-0_8.0.61-1_amd64.deb (--unpack):
 cannot copy extracted data for './usr/local/cuda-8.0/targets/x86_64-linux/lib/libcufft_static.a' to '/usr/local/cuda-8.0/targets/x86_64-linux/lib/libcufft_static.a.dpkg-new': unexpected end of file or stream
Errors were encountered while processing:
 /var/cache/apt/archives/cuda-cufft-dev-8-0_8.0.61-1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

I tried to fix this for a while but couldn't so eventually I just started trying to uninstall cuda. In /usr/local/ I see cuda, cuda-7.5, and cuda-8.0 (which probably isn't good). I go to all the directories looking for unstalling files (/usr/local/cuda-6.5/bin/uninstall_cuda_7.5.pl) but I don't see any.

I would prefer to upgrade to the latest but at this point I'd be happy with uninstalling it too. What should I try next?

When I run sudo dpkg --configure -a I get:

dpkg: dependency problems prevent configuration of cuda-toolkit-8-0:
 cuda-toolkit-8-0 depends on cuda-cufft-dev-8-0 (>= 8.0.61); however:
  Package cuda-cufft-dev-8-0 is not installed.

dpkg: error processing package cuda-toolkit-8-0 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of cuda-visual-tools-8-0:
 cuda-visual-tools-8-0 depends on cuda-cufft-dev-8-0; however:
  Package cuda-cufft-dev-8-0 is not installed.

dpkg: error processing package cuda-visual-tools-8-0 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of cuda-samples-8-0:
 cuda-samples-8-0 depends on cuda-cufft-dev-8-0; however:
  Package cuda-cufft-dev-8-0 is not installed.

dpkg: error processing package cuda-samples-8-0 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of cuda-8-0:
 cuda-8-0 depends on cuda-toolkit-8-0 (>= 8.0.61); however:
  Package cuda-toolkit-8-0 is not configured yet.

dpkg: error processing package cuda-8-0 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of cuda-documentation-8-0:
 cuda-documentation-8-0 depends on cuda-samples-8-0; however:
  Package cuda-samples-8-0 is not configured yet.

dpkg: error processing package cuda-documentation-8-0 (--configure):
 dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of cuda:
 cuda depends on cuda-8-0 (>= 8.0.61); however:
  Package cuda-8-0 is not configured yet.

dpkg: error processing package cuda (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 cuda-toolkit-8-0
 cuda-visual-tools-8-0
 cuda-samples-8-0
 cuda-8-0
 cuda-documentation-8-0
 cuda

Solution 1:

After Cleaning cache, you can try these,

dpkg -l | grep cuda- | awk '{print $2}' | xargs -n1 sudo dpkg --purge
df -h
sudo apt-get purge nvidia*
sudo apt-get -f install
sudo apt autoremove

Hope, this might help you. Cheers

Solution 2:

I just needed to clean my cache. This is what ended up working:

sudo dpkg --configure -a

sudo apt-get clean