Repository: pytorch
Issue: Segmentation fault in lazyInitCUDA -> CUDAHooks::initCUDA -> THCMagma_init -> magma_init
Labels: needs reproduction,module: cuda,triaged,module: third_party

## 🐛 Bug

I have two machines, on one the latest development version of PyTorch works as expected, on the other a very simple example program terminates with a segfault. I trained a neural network on the machine where everything works as expected, then reduced the code to a minimal program showing the problem.

## To Reproduce

compile and run:

```#include <torch/torch.h>
#include <iostream>
auto main(int argc, char ** argv) -> int {
     torch::manual_seed(1);
}
```

Backtrace:

> 
> Thread 2 (Thread 0x7fff9fa91700 (LWP 1503742)):
> #0  0x00007fffdb0eac08 in accept4 (fd=8, addr=..., addr_len=0x7fff9fa8eb38, flags=524288) at ../sysdeps/unix/sysv/linux/accept4.c:32
>         resultvar = 18446744073709551104
>         sc_cancel_oldtype = 0
>         sc_ret = <optimized out>
> #1  0x00007fff9fef991a in ?? () from /usr/lib/x86_64-linux-gnu/libcuda.so.1
> No symbol table info available.
> #2  0x00007fff9feebbbd in ?? () from /usr/lib/x86_64-linux-gnu/libcuda.so.1
> No symbol table info available.
> #3  0x00007fff9fefafe8 in ?? () from /usr/lib/x86_64-linux-gnu/libcuda.so.1
> No symbol table info available.
> #4  0x00007fffdae4bfb7 in start_thread (arg=<optimized out>) at pthread_create.c:486
>         ret = <optimized out>
>         pd = <optimized out>
>         now = <optimized out>
>         unwind_buf = {cancel_jmp_buf = {{jmp_buf = {140735872046848, -5529860711636867593, 140737488347966, 140737488347967, 140735872046848, 140735872036096, 5530072531295200759, 5529937872893044215}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
>         not_first_call = <optimized out>
> #5  0x00007fffdb0e92cf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
> No locals.
> 
> Thread 1 (Thread 0x7fffa10a4a00 (LWP 1503707)):
> #0  0x00007fffddfd2aff in magma_init () from /home/alexander/pytorch/torch/lib/libtorch_cuda.so
> No symbol table info available.
> #1  0x00007fffdbf0bc25 in THCMagma_init (state=<optimized out>) at /home/alexander/pytorch/aten/src/THC/THCTensorMathMagma.cu:24
> No locals.
> #2  0x00007fffddbb25ed in at::cuda::detail::CUDAHooks::initCUDA (this=<optimized out>) at ../aten/src/ATen/cuda/detail/CUDAHooks.cpp:51
>         logFlag1 = <optimized out>
>         thc_state = 0x5555567e9370
> #3  0x0000555555559ebf in at::Context::lazyInitCUDA()::{lambda()#1}::operator()() const (__closure=<error reading variable: Cannot access memory at address 0xffffffffffffffe8>) at /home/alexander/pytorch/torch/include/ATen/Context.h:74
>         this = <error reading variable this (Cannot access memory at address 0xffffffffffffffe8)>
> Backtrace stopped: previous frame inner to this frame (corrupt stack?)

## Expected behavior

No segmentation fault.

## Environment

Latest pytorch version from git: ecbf6f99e6a4e373105133b31534c9fb50f2acca
Build type of PyTorch is "RelWithDebInfo", build type of the example is "Debug".

PyTorch version: N/A
Is debug build: N/A
CUDA used to build PyTorch: N/A

OS: Debian GNU/Linux bullseye/sid
GCC version: (Debian 9.2.1-22) 9.2.1 20200104
CMake version: version 3.14.0

Python version: 3.6
Is CUDA available: N/A
CUDA runtime version: 10.1.168
GPU models and configuration: GPU 0: GeForce GTX 970
Nvidia driver version: 430.64
cuDNN version: Could not collect

Versions of relevant libraries:
[pip3] numpy==1.17.4
[conda] _tflow_select             2.3.0                       mkl  
[conda] blas                      1.0                         mkl  
[conda] magma-cuda92              2.4.0                         1    pytorch
[conda] mkl                       2019.4                      243  
[conda] mkl-include               2019.4                      243  
[conda] mkl-service               2.3.0            py36he904b0f_0  
[conda] mkl_fft                   1.0.10           py36ha843d7b_0  
[conda] mkl_random                1.0.2            py36hd81dba3_0  
[conda] pytorch                   1.0.1           cuda80py36ha8650f8_0  
[conda] torchvision               0.2.1                      py_2    pytorch


## Additional context

<!-- Add any other context about the problem here. -->


cc @ngimel