How to compile pytorch from source without cuda default location

my cuda-8.0 is located in another place, but compiling from source the cmake always find cuda in /usr/local/cuda

and it shows
-- Found CUDA: /usr/local/cuda (found suitable version "7.5", minimum required is "7.0") .

how to change the cuda and cudnn location?

Thanks.

Try to export CUDA_HOME in your environment pointing to your location before calling setup.py.