RuntimeError: cublas runtime error : library not initialized at /opt/conda/conda-bld/pytorch_1565272279342/work/aten/src/THC/THCGeneral.cpp:216

netD = Discriminator()

netD.zero_grad()

train with real

D_real = netD(real_data_v)

Traceback (most recent call last):
File “/tmp/pycharm_project_314/wgan-gp/gan_toy.py”, line 274, in
D_real = netD(real_data_v)
File “/public/home/yanjianhua/anaconda3/envs/Pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 547, in call
result = self.forward(*input, **kwargs)
File “/tmp/pycharm_project_314/wgan-gp/gan_toy.py”, line 82, in forward
output = self.main(inputs)
File “/public/home/yanjianhua/anaconda3/envs/Pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 547, in call
result = self.forward(*input, **kwargs)
File “/public/home/yanjianhua/anaconda3/envs/Pytorch/lib/python3.6/site-packages/torch/nn/modules/container.py”, line 92, in forward
input = module(input)
File “/public/home/yanjianhua/anaconda3/envs/Pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 547, in call
result = self.forward(*input, **kwargs)
File “/public/home/yanjianhua/anaconda3/envs/Pytorch/lib/python3.6/site-packages/torch/nn/modules/linear.py”, line 87, in forward
return F.linear(input, self.weight, self.bias)
File “/public/home/yanjianhua/anaconda3/envs/Pytorch/lib/python3.6/site-packages/torch/nn/functional.py”, line 1369, in linear
ret = torch.addmm(bias, input, weight.t())
RuntimeError: cublas runtime error : library not initialized at /opt/conda/conda-bld/pytorch_1565272279342/work/aten/src/THC/THCGeneral.cpp:216

Could you check, if you might be running out of memory?
Sometimes these library issues are raised even though you are in fact running out of memory.
If that’s the case, I would recommend to reduce the batch size.