Hi, I met some error when using torch.zeros
function and finally found solutions to it.
However, I think there may be something wrong with the implementation itself. Can anyone help me with the root reason? Thanks.
Bug
Program gets a Segmentation fault
when the parameter setting of torch.zeros
function is very large and the second parameter being a tensor
instead of an integer
.
To Reproduce
Steps to reproduce the behavior:
seq_length = torch.LongTensor(range(895))
torch.zeros((69137, seq_length.max(), 13))
Segmentation Fault
Expected behavior
If I do the following
import torch
torch.zeros((69137, torch.LongTensor([895]).max(), 13))
An error of TypeError: an integer is required
will be shown, indicating we should change torch.LongTensor([895])
to torch.LongTensor([895]).item()
.
If I do the following
torch.zeros((69137, torch.LongTensor([1]).max(), 13))
No error will be produced.
Environment
Please copy and paste the output from our
environment collection script
(or fill out the checklist below manually).
-
PyTorch version: 0.4.1.post2
-
Is debug build: No
-
CUDA used to build PyTorch: 9.0.176
-
OS: Debian GNU/Linux 9.4 (stretch)
-
GCC version: (Debian 4.9.2-10+deb8u1) 4.9.2
-
CMake version: version 3.9.4
Python version: 2.7
-
Is CUDA available: Yes
-
CUDA runtime version: Could not collect
-
GPU models and configuration:
-
GPU 0: GeForce GTX 1080 Ti
-
GPU 1: GeForce GTX 1080 Ti
-
Nvidia driver version: 387.26
-
cuDNN version: Probably one of the following:
-
/usr/local/cuda-8.0/lib64/libcudnn.so.6
-
/usr/local/cuda-9.0/lib64/libcudnn.so
-
/usr/local/cuda-9.0/lib64/libcudnn.so.7
-
/usr/local/cuda-9.0/lib64/libcudnn.so.7.0.5
-
/usr/local/cuda-9.0/lib64/libcudnn.so.7.1.2
-
/usr/local/cuda-9.0/lib64/libcudnn_static.a
-
/usr/local/cuda-9.1/lib64/libcudnn.so
-
/usr/local/cuda-9.1/lib64/libcudnn.so.7
-
/usr/local/cuda-9.1/lib64/libcudnn.so.7.1.2
-
/usr/local/cuda-9.1/lib64/libcudnn_static.a
Versions of relevant libraries:
- [pip] Could not collect
- [conda] magma-cuda90 2.3.0 1 pytorch
- [conda] pytorch 0.4.1 py27__9.0.176_7.1.2_2 pytorch
- [conda] torch 0.4.0a0+964707e
- [conda] torch 0.4.0a0+92a0f78
- [conda] torchfile 0.1.0
- [conda] torchnet 0.0.2
- [conda] torchvision 0.2.0
- [conda] torchvision 0.2.1 py27_1 pytorch