cudaErrorIllegalAddress printing result of torch.nn.Linear(1, 1).cuda()(torch.Tensor([[0.5]]))

🐛 Bug

>>> import torch
>>> t = torch.Tensor([[0.5]])
>>> model = torch.nn.Linear(1, 1).cuda()
>>> model(t)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/private/home/tbirch/.conda/envs/torch160/lib/python3.7/site-packages/torch/", line 153, in __repr__
    return torch._tensor_str._str(self)
  File "/private/home/tbirch/.conda/envs/torch160/lib/python3.7/site-packages/torch/", line 371, in _str
    return _str_intern(self)
  File "/private/home/tbirch/.conda/envs/torch160/lib/python3.7/site-packages/torch/", line 351, in _str_intern
    tensor_str = _tensor_str(self, indent)
  File "/private/home/tbirch/.conda/envs/torch160/lib/python3.7/site-packages/torch/", line 241, in _tensor_str
    formatter = _Formatter(get_summarized_data(self) if summarize else self)
  File "/private/home/tbirch/.conda/envs/torch160/lib/python3.7/site-packages/torch/", line 89, in __init__
    nonzero_finite_vals = torch.masked_select(tensor_view, torch.isfinite(tensor_view) &
RuntimeError: copy_if failed to synchronize: cudaErrorIllegalAddress: an illegal memory access was encountered

Expected behavior

Print out the value of the tensor and not crash


Collecting environment information…
PyTorch version: 1.6.0
Is debug build: No
CUDA used to build PyTorch: 10.1

OS: Ubuntu 18.04.3 LTS
GCC version: (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
CMake version: version 3.10.2

Python version: 3.7
Is CUDA available: Yes
CUDA runtime version: 10.1.105
GPU models and configuration:
GPU 0: Quadro GP100
GPU 1: Quadro GP100

Nvidia driver version: 418.116.00
cuDNN version: Could not collect

Versions of relevant libraries:
[pip3] numpy==1.18.5
[pip3] torch==1.6.0
[pip3] torchvision==0.7.0
[conda] blas 1.0 mkl
[conda] cudatoolkit 10.1.243 h6bb024c_0
[conda] mkl 2020.1 217
[conda] mkl-service 2.3.0 py37he904b0f_0
[conda] mkl_fft 1.1.0 py37h23d657b_0
[conda] mkl_random 1.1.1 py37h0da4684_0 conda-forge
[conda] numpy 1.18.5 py37ha1c710e_0
[conda] numpy-base 1.18.5 py37hde5b4d6_0
[conda] pytorch 1.6.0 py3.7_cuda10.1.243_cudnn7.6.3_0 pytorch
[conda] torchvision 0.7.0 py37_cu101 pytorch

cc @ezyang @gchanan @zou3519 @ngimel

1 possible answer(s) on “cudaErrorIllegalAddress printing result of torch.nn.Linear(1, 1).cuda()(torch.Tensor([[0.5]]))