The problem encountered is weird.
on one hand,the code is OK for ubuntu16.04+cuda8.0+Titan X+Pytorch0.3.1.
However,it’s not the same thing with Pytorch0.4.1
when excecuted with Pytorch 0.4.1,it shows something wrong like below:
THCudaCheck FAIL file=/pytorch/aten/src/THC/generated/…/generic/THCTensorMathReduce.cu line=18 error=8 : invalid device function
Traceback (most recent call last):
File “/home/zzqiuzz/Work/XNOR-Net-PyTorch-master/MNIST/main.py”, line 190, in 
train(epoch)
File “/home/zzqiuzz/Work/XNOR-Net-PyTorch-master/MNIST/main.py”, line 37, in train
bin_op.binarization()
File “/home/zzqiuzz/Work/XNOR-Net-PyTorch-master/MNIST/util.py”, line 33, in binarization
self.meancenterConvParams()
File “/home/zzqiuzz/Work/XNOR-Net-PyTorch-master/MNIST/util.py”, line 42, in meancenterConvParams
negMean = self.target_modules[index].data.mean(1, keepdim=True).
RuntimeError: cuda runtime error (8) : invalid device function at /pytorch/aten/src/THC/generated/…/generic/THCTensorMathReduce.cu:18
And I’m newbee for Pytorch with few days learning.
THanks for helping!