Trouble with python import of CUDA

I have installed CUDA 8.0.61 and I run python on Ubuntu 16.04.3.
The code is available on-line so that it should not be wrong.
However, I got the error message below:

RuntimeError: ‘nvcc’ command returns non-zero exit status.
command: [‘nvcc’, ‘–cubin’, ‘-arch’, ‘sm_61’, ‘/tmp/tmpsiw3X0/kern.cu’]
return-code: 1
stdout/stderr:
nvcc fatal : Value ‘sm_61’ is not defined for option ‘gpu-architecture’

Can anyone help me to solve this problem?
Thanks.

P.-T Chen

I suspect you have an older version of CUDA installed on your machine somewhere, and python is picking up that older version.

Find all instances of nvcc on your machine:

sudo find / -name nvcc

Make sure you have set the PATH variable correctly for your CUDA 8.0.61 install. (Compare the path to your 8.0.61 nvcc from the output above, with echo $PATH)

Hi txbob,
Thanks for your advice.
There are cuda-7.0, cuda-7.5 and cuda-8.0 in my machine.

/usr/local/cuda-7.0/bin/nvcc
/usr/local/cuda-8.0/bin/nvcc
/usr/local/cuda-7.5/bin/nvcc
/usr/bin/nvcc
/usr/lib/nvidia-cuda-toolkit/bin/nvcc

Do I have to uninstall the older version?
I’m new to linux.
Can you teach me how to make sure the PATH variable? Thank you very much.

Read

/usr/local/cuda-8.0/doc/pdf/CUDA_Installation_Guide_Linux.pdf

that is installed on your machine

especially the section titled “Post Installation Actions”

and the nvcc here:

/usr/bin/nvcc

may be troublesome. You’ll need to make sure that the path to /usr/local/cuda-8.0/bin appears before that path in your PATH variable.

Thanks! It works nicely!