Unable to run Pytorch with Cuda 11.1

Collecting environment information…
PyTorch version: 1.8.1+cu111
Is debug build: False
CUDA used to build PyTorch: 11.1
ROCM used to build PyTorch: N/A

OS: Microsoft Windows Server 2019 Standard
GCC version: Could not collect
Clang version: Could not collect
CMake version: version 3.20.1

Python version: 3.7 (64-bit runtime)
Is CUDA available: True
CUDA runtime version: 11.1.105
GPU models and configuration: Could not collect
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] numpy==1.20.2
[pip3] numpydoc==1.1.0
[pip3] torch==1.8.1+cu111
[pip3] torchaudio==0.8.1
[pip3] torchvision==0.9.1+cu111
[conda] blas 1.0 mkl
[conda] mkl 2021.2.0 haa95532_296
[conda] mkl-include 2021.2.0 haa95532_296
[conda] mkl-service 2.3.0 py37h2bbff1b_1
[conda] mkl_fft 1.3.0 py37h277e83a_2
[conda] mkl_random 1.2.1 py37hf11a4ad_2
[conda] numpy 1.20.2 pypi_0 pypi
[conda] numpy-base 1.20.1 py37haf7ebc8_0
[conda] numpydoc 1.1.0 pyhd3eb1b0_1
[conda] torch 1.8.1+cu111 pypi_0 pypi
[conda] torchaudio 0.8.1 pypi_0 pypi
[conda] torchvision 0.9.1+cu111 pypi_0 pypi

Fri Apr 23 20:12:41 2021
±----------------------------------------------------------------------------+
| NVIDIA-SMI 456.81 Driver Version: 456.81 CUDA Version: 11.1 |
|-------------------------------±---------------------±---------------------+
| GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 Tesla K20c TCC | 00000000:82:00.0 Off | 0 |
| 30% 27C P8 16W / 225W | 9MiB / 4737MiB | 0% Default |
| | | N/A |
±------------------------------±---------------------±---------------------+

±----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
±----------------------------------------------------------------------------+

Simple code:

import torch
print(‘F’, torch.tensor([1.0, 2.0]).cuda())

Error:

F Traceback (most recent call last):
File “G:\Python_projects\OCR_new\1.py”, line 12, in
print(‘F’, torch.tensor([1.0, 2.0]).cuda())
File “C:\Users\mgoliyad_admin\AppData\Local\Continuum\anaconda3\envs\cuda_11\lib\site-packages\torch\tensor.py”, line 193, in repr
return torch._tensor_str._str(self)
File “C:\Users\mgoliyad_admin\AppData\Local\Continuum\anaconda3\envs\cuda_11\lib\site-packages\torch_tensor_str.py”, line 383, in _str
return _str_intern(self)
File “C:\Users\mgoliyad_admin\AppData\Local\Continuum\anaconda3\envs\cuda_11\lib\site-packages\torch_tensor_str.py”, line 358, in _str_intern
tensor_str = _tensor_str(self, indent)
File “C:\Users\mgoliyad_admin\AppData\Local\Continuum\anaconda3\envs\cuda_11\lib\site-packages\torch_tensor_str.py”, line 242, in _tensor_str
formatter = _Formatter(get_summarized_data(self) if summarize else self)
File “C:\Users\mgoliyad_admin\AppData\Local\Continuum\anaconda3\envs\cuda_11\lib\site-packages\torch_tensor_str.py”, line 90, in init
nonzero_finite_vals = torch.masked_select(tensor_view, torch.isfinite(tensor_view) & tensor_view.ne(0))
RuntimeError: CUDA error: no kernel image is available for execution on the device

(cuda_11) G:\Python_projects\OCR_new>

The K20 uses a compute capability of 3.5, which is not shipped in the binaries (min. compute capability is 3.7), so you could build PyTorch from source as described here.

Thanks for the answer! No luck with building from source either:
[4582/5621] Building NVCC (Device) object caffe2/CMakeFile…HC/generated/torch_cuda_generated_THCTensorTopKLong.cu.obj
THCTensorTopKLong.cu
THCTensorTopKLong.cu
[4583/5621] Building NVCC (Device) object caffe2/CMakeFile…ATen/native/cuda/torch_cuda_generated_Distributions.cu.obj
Distributions.cu
Distributions.cu
ninja: build stopped: subcommand failed.
(cuda_11) PS C:\Users\mgoliyad_admin\pytorch>

Can I try binaries for older version for K20?

Yes, you could try to use an older version, but I’m currently unsure when 3.5 was dropped.
The error message from the source build isn’t shown, so you would have to check the messages printed a bit earlier in the log.

EDIT: you might also want to check this issue where some users were building the binaries with sm_35.

Thanks for your answer; here is more data from log:[4563/5621] Building NVCC (Device) object caffe2/CMakeFile…C/generated/torch_cuda_generated_THCTensorSortFloat.cu.obj
THCTensorSortFloat.cu
THCTensorSortFloat.cu
[4564/5621] Building NVCC (Device) object caffe2/CMakeFile…/generated/torch_cuda_generated_THCTensorSortDouble.cu.obj
THCTensorSortDouble.cu
THCTensorSortDouble.cu
[4565/5621] Building NVCC (Device) object caffe2/CMakeFile…THC/generated/torch_cuda_generated_THCTensorSortInt.cu.obj
THCTensorSortInt.cu
THCTensorSortInt.cu
[4566/5621] Building NVCC (Device) object caffe2/CMakeFile…HC/generated/torch_cuda_generated_THCTensorTopKChar.cu.obj
THCTensorTopKChar.cu
THCTensorTopKChar.cu
[4567/5621] Building NVCC (Device) object caffe2/CMakeFile…HC/generated/torch_cuda_generated_THCTensorSortHalf.cu.obj
THCTensorSortHalf.cu
THCTensorSortHalf.cu
[4568/5621] Building NVCC (Device) object caffe2/CMakeFile…e/cuda/torch_cuda_generated_EmbeddingBackwardKernel.cu.obj
EmbeddingBackwardKernel.cu
EmbeddingBackwardKernel.cu
[4569/5621] Building NVCC (Device) object caffe2/CMakeFile…n/src/ATen/native/cuda/torch_cuda_generated_Dropout.cu.obj
Dropout.cu
Dropout.cu
[4570/5621] Building NVCC (Device) object caffe2/CMakeFile…enerated/torch_cuda_generated_THCTensorSortBFloat16.cu.obj
THCTensorSortBFloat16.cu
THCTensorSortBFloat16.cu
[4571/5621] Building NVCC (Device) object caffe2/CMakeFile…HC/generated/torch_cuda_generated_THCTensorTopKHalf.cu.obj
THCTensorTopKHalf.cu
THCTensorTopKHalf.cu
[4572/5621] Building NVCC (Device) object caffe2/CMakeFile…HC/generated/torch_cuda_generated_THCTensorSortByte.cu.obj
THCTensorSortByte.cu
THCTensorSortByte.cu
[4573/5621] Building NVCC (Device) object caffe2/CMakeFile…HC/generated/torch_cuda_generated_THCTensorSortChar.cu.obj
THCTensorSortChar.cu
THCTensorSortChar.cu
[4574/5621] Building NVCC (Device) object caffe2/CMakeFile…C/generated/torch_cuda_generated_THCTensorSortShort.cu.obj
THCTensorSortShort.cu
THCTensorSortShort.cu
[4575/5621] Building NVCC (Device) object caffe2/CMakeFile…THC/generated/torch_cuda_generated_THCTensorTopKInt.cu.obj
THCTensorTopKInt.cu
THCTensorTopKInt.cu
[4576/5621] Building NVCC (Device) object caffe2/CMakeFile…C/generated/torch_cuda_generated_THCTensorTopKFloat.cu.obj
THCTensorTopKFloat.cu
THCTensorTopKFloat.cu
[4577/5621] Building NVCC (Device) object caffe2/CMakeFile…HC/generated/torch_cuda_generated_THCTensorSortLong.cu.obj
THCTensorSortLong.cu
THCTensorSortLong.cu
[4578/5621] Building NVCC (Device) object caffe2/CMakeFile…/cuda/torch_cuda_generated_DistributionRandomKernel.cu.obj
DistributionRandomKernel.cu
DistributionRandomKernel.cu
[4579/5621] Building NVCC (Device) object caffe2/CMakeFile…src/ATen/native/cuda/torch_cuda_generated_Embedding.cu.obj
Embedding.cu
Embedding.cu
[4580/5621] Building NVCC (Device) object caffe2/CMakeFile…HC/generated/torch_cuda_generated_THCTensorTopKLong.cu.obj
THCTensorTopKLong.cu
THCTensorTopKLong.cu
[4581/5621] Building NVCC (Device) object caffe2/CMakeFile…/generated/torch_cuda_generated_THCTensorTopKDouble.cu.obj
THCTensorTopKDouble.cu
THCTensorTopKDouble.cu
[4582/5621] Building NVCC (Device) object caffe2/CMakeFile…ATen/native/cuda/torch_cuda_generated_Distributions.cu.obj
Distributions.cu
Distributions.cu
ninja: build stopped: subcommand failed.
(py_self) PS C:\Users\mgoliyad_admin\pytorch>

Unfortunately, the error message is still not shown. The log should contain a line containing the error keyword with a description why the build is failing.

After downgrading VS to 16.7 I was able to build from source. Thanks!