@albanD
Good news ! With the night build 1.5.0.dev20200129 I have no crash neither on CPU nor on GPU, and both for your code and my longer one 
So the problem has been solved ! May be you can investigate when the bug has been solved by itself…
Thanks a lot.
PS: notice that the first time I have performed an import torch it happens
    import torch
  File "/sps/lsst/users/campagne/anaconda3/lib/python3.7/site-packages/torch/__init__.py", line 125, in <module>
    from torch._C import *
ImportError: .../anaconda3/lib/python3.7/site-packages/torch/lib/libtorch_python.so: undefined symbol: _ZN5torch4cuda4nccl6detail16throw_nccl_errorE12ncclResult_t