opencvcudacaffe

How to change CUDA version


I met this error when compiling a modified caffe version.

OpenCV static library was compiled with CUDA 7.5 support. Please, use the same version or rebuild OpenCV with CUDA 8.0

I have some old code may not compatible with CUDA8.0, so I want to change my cuda version for this error.

I modified my ~/.bash_profile like this

# export PYTHONPATH=$PYTHONPATH:/usr/local/cuda-8.0/lib64/
# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-8.0/lib64
export PYTHONPATH=$PYTHONPATH:/usr/local/cuda-7.5/targets/x86_64-linux/lib/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-7.5/targets/x86_64-linux/lib/

But it did't work. Still the same error. What should I do?


Solution

  • Change your CUDA soft link to point on your desired CUDA version. For example:

    ll /usr/local/cuda lrwxrwxrwx 1 root root 19 Sep 06 2017 /usr/local/cuda -> /usr/local/cuda-8.0/

    Simply relink it with

    Update: If the symlink already exists, use this other command:

    [jalal@goku ~]$ ls /usr/local/cuda
    lrwxrwxrwx. 1 root root 20 Sep 14 08:03 /usr/local/cuda -> /usr/local/cuda-10.2
    
    [jalal@goku ~]$ sudo ln -sfT /usr/local/cuda/cuda-11.1/ /usr/local/cuda
    [jalal@goku ~]$ ls /usr/local/cuda
    lrwxrwxrwx. 1 root root 26 Sep 14 13:25 /usr/local/cuda -> /usr/local/cuda/cuda-11.1/
    

    ln -s /usr/local/cuda-7.5 /usr/local/cuda

    (With the proper installation location)