Change:
There's quite a few user-reports of installing the CUDA 7.5 binary of pytorch and then running on GTX 1080 / 1070, and there will be reports of installing 7.5 / 8.0 binaries and running on V100. Raising a user-warning in such situations and letting them know will fix the problem.
The version of CUDA used to compile the binary should be available thanks to this PR:
I think is a more robust way of getting the CUDA used to compile PyTorch, as currently if there are multiple CUDA installed in the machine, the heuristics used in might not match those used by CMake FindCUDA. I think that we should modify the to return the cuda version used during compilation. I have the impression that it will not require changing much because doesn't require cuda to execute. What do you think?

Discussion:
END_HANDLE_TH_ERRORS } <ins> PyObject * THCPModule_getDeviceCapability_wrap(PyObject *self, PyObject *arg) { HANDLE_TH_ERRORS THPUtils_assert(THPUtils_checkLong(arg), "invalid argument to getDeviceCapability"); long device = THPUtils_unpackLong(arg); cudaDeviceProp prop; THCudaCheck(cudaGetDeviceProperties(&prop, device)); return Py_BuildValue("(ii)", prop.major, prop.minor); END_HANDLE_TH_ERRORS } </ins> PyObject * THCPModule_getCurrentStream_wrap(PyObject *self) { HANDLE_TH_ERRORS

return PyLong_FromLong((int64_t) driverVersion); } <ins> PyObject * THCPModule_getCompiledVersion(PyObject *self) { return PyLong_FromLong((long) CUDA_VERSION); } </ins> PyObject * THCPModule_getRNGState(PyObject *_unused) { HANDLE_TH_ERRORS

{"_cuda_getDevice",   (PyCFunction)THCPModule_getDevice_wrap,   METH_NOARGS,  NULL}, {"_cuda_getDeviceCount", (PyCFunction)THCPModule_getDeviceCount_wrap, METH_NOARGS, NULL}, {"_cuda_getDeviceName", (PyCFunction)THCPModule_getDeviceName_wrap, METH_O,   NULL}, <ins> {"_cuda_getDeviceCapability", (PyCFunction)THCPModule_getDeviceCapability_wrap, METH_O,   NULL}, </ins> {"_cuda_getCurrentStream", (PyCFunction)THCPModule_getCurrentStream_wrap, METH_NOARGS, NULL}, {"_cuda_getCurrentBlasHandle", (PyCFunction)THCPModule_getCurrentBlasHandle_wrap, METH_NOARGS, NULL}, {"_cuda_setStream",    (PyCFunction)THCPModule_setStream_wrap,  METH_O, NULL}, {"_cuda_isDriverSufficient", (PyCFunction)THCPModule_isDriverSufficient, METH_NOARGS, NULL}, {"_cuda_getDriverVersion", (PyCFunction)THCPModule_getDriverVersion, METH_NOARGS, NULL}, <ins> {"_cuda_getCompiledVersion", (PyCFunction)THCPModule_getCompiledVersion, METH_NOARGS, NULL}, </ins> {"_cuda_getRNGState", (PyCFunction)THCPModule_getRNGState,      METH_NOARGS,  NULL}, {"_cuda_setRNGState", (PyCFunction)THCPModule_setRNGState,      METH_O,       NULL}, {"_cuda_emptyCache", (PyCFunction) THCPModule_emptyCache,       METH_NOARGS,  NULL},

import os import torch import traceback <ins> import warnings </ins> from torch._six import raise_from from subprocess import Popen, PIPE from multiprocessing.util import register_after_fork as _register_after_fork

The NVIDIA driver on your system is too old (found version {}). Please update your GPU driver by downloading and installing a new version from the URL: http://www.nvidia.com/Download/index.aspx <del> Alternatively, go to: https://pytorch.org/binaries to install </del> <ins> Alternatively, go to: http://pytorch.org to install </ins> a PyTorch version that has been compiled with your version of the CUDA driver.""".format(str(torch._C._cuda_getDriverVersion()))) <ins> def _check_capability(): error_str = """ Found GPU%d %s which requires CUDA_VERSION >= %d for optimal performance and fast startup time, but your PyTorch was compiled with CUDA_VERSION %d. Please install the correct PyTorch binary using instructions from http://pytorch.org """ CUDA_VERSION = torch._C._cuda_getCompiledVersion() for d in range(device_count()): major = get_device_capability(d)[0] name = get_device_name(d) if CUDA_VERSION < 8000 and major >= 6: warnings.warn(error_str % (d, name, 8000, CUDA_VERSION)) elif CUDA_VERSION < 9000 and major >= 7: warnings.warn(error_str % (d, name, 8000, CUDA_VERSION)) </ins> def _lazy_call(callable): if _initialized: callable()

# Don't store the actual traceback to avoid memory cycle _queued_calls.append((callable, traceback.format_stack())) <ins> _lazy_call(_check_capability) </ins> class DeferredCudaCallError(Exception): pass

return torch._C._cuda_getDeviceName(device) <ins> def get_device_capability(device): """Gets the cuda capability of a device. Arguments: device (int): device for which to return the name. This function is a no-op if this argument is negative. Returns: tuple(int, int): the major and minor cuda capability of the device """ if device >= 0: return torch._C._cuda_getDeviceCapability(device) </ins> @contextlib.contextmanager def stream(stream): """Context-manager that selects a given stream.