Problem with OpenCL with CUDA7.5 Ubuntu14.04

I had CUDA-7.5 successfully working on Ubutu14.04 for several months.
I recently attempted to resolve a build problem that required opencl with the following line;

sudo apt-get install nvidia-opencl-dev

This broke everything. It looks like it pulled in 340.96 stuff (my working system had 352.63)
I attemped to remove it using

$ sudo apt-get --purge remove nvidia-opencl-dev

but that did not fix the problem. eg.

$ sudo dpkg --list | grep nvidia

ii  nvidia-340             340.96-0ubuntu0.14.04.1  amd64  NVIDIA binary driver - version 340.96
ii  nvidia-340-uvm         340.96-0ubuntu0.14.04.1  amd64  Transitional package for nvidia-340
rc  nvidia-352             352.63-0ubuntu0.14.04.1  amd64  NVIDIA binary driver - version 352.63
ii  nvidia-libopencl1-331  340.96-0ubuntu0.14.04.1  amd64  Transitional package for nvidia-libopencl1-340
ii  nvidia-libopencl1-340  340.96-0ubuntu0.14.04.1  amd64  NVIDIA OpenCL Driver and ICD Loader library
ii  nvidia-modprobe        352.39-0ubuntu1          amd64  Load the NVIDIA kernel driver and create device files
ii  nvidia-opencl-icd-340  340.96-0ubuntu0.14.04.1  amd64  NVIDIA OpenCL ICD
rc  nvidia-opencl-icd-352  352.63-0ubuntu0.14.04.1  amd64  NVIDIA OpenCL ICD
ii  nvidia-prime           0.6.2                    amd64  Tools to enable NVIDIA's Prime
ii  nvidia-settings        352.39-0ubuntu1          amd64  Tool for configuring the NVIDIA graphics driver

Here is some more relevant info…

$ uname -r
3.19.0-33-generic
$ cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX x86_64 Kernel Module  352.63  Sat Nov  7 21:25:42 PST 2015
GCC version:  gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04)
$ lspci -v | grep -i nvidia
02:00.0 VGA compatible controller: NVIDIA Corporation GK106GL [Quadro K4000] (rev a1) (prog-if 00 [VGA controller])
        Subsystem: NVIDIA Corporation Device 097c
        Kernel driver in use: nvidia
02:00.1 Audio device: NVIDIA Corporation GK106 HDMI Audio Controller (rev a1)
        Subsystem: NVIDIA Corporation Device 097c

What is the best way forward to correct this? Should I delete everything and start from scratch? or just the 340.96 (and how?)

The linux install guide gives general instructions for how to clean up an installation.

http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#handle-uninstallation

I would probably purge/remove nvidia* and then reinstall CUDA 7.5, but the main issue is the driver, so if you just want to try to purge/remove the 340.96 components (which will not work with CUDA 7.5) have at it.

Once CUDA 7.5 is properly installed, you have everything you need for OpenCL development as well. I build OCL codes from time to time with just the CUDA toolkit. What did you think you need or needed to add with nvidia-opencl-dev ?

Thanks txbob,

For the benefit of any newbies who might be interested, here is what I eventually did…

I first tried to just remove the 340 related drivers and packages

sudo apt-get --purge remove nvidia-340
sudo apt-get --purge remove nvidia-libopencl1-340

Things still were not working (I think some of the 352 drivers had already been removed, as indicated by the ‘rc’ flags in line 5 of the output from the “sudo dpkg --list | grep nvidia” command above).

I checked to ensure that all packages with ‘nvidia’ or ‘cuda’ in their names were related to the GPU (which they appeared to be).

apt --installed list | grep nivida
apt --installed list | grep cuda

As all these appeared to be related to the CUDA-7.5 kit and the nvidia card drivers, I was happy to remove them…(as per txbob’s suggestion)

sudo apt-get --purge remove nvidia*
sudo apt-get --purge remove cuda

I then followed the installation instructions again, and everything works happily… http://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#abstract

The machine I am using is shared amongst a number of people. In my investigation, I found a NVIDIA_*.run installation file on the machine, so the original installation may have had problems rising from different installation attempts by different people…