DmitryUlyanov / deep-image-prior

Image restoration with neural networks but without learning.
https://dmitryulyanov.github.io/deep_image_prior
Other
7.9k stars 1.43k forks source link

Breaks with new pytorch 0.3.0 #18

Closed xerebz closed 6 years ago

xerebz commented 6 years ago

Denoising demo just hangs on Setup step

DmitryUlyanov commented 6 years ago

Hi! Cannot reproduce, works for me. Can you please give more details about your system and try to find the exact point where it breaks?

xerebz commented 6 years ago

New install -> Cuda 9.0 -> CUDNN 7.0.5 -> Miniconda3 -> Pytorch 0.3.0


RuntimeError Traceback (most recent call last)

in () 22 need_sigmoid=True, need_bias=True, pad=pad, act_fun='LeakyReLU') 23 ---> 24 net = net.type(dtype) 25 26 elif fname == 'data/denoising/F16_GT.png': ~/.pyenv/versions/miniconda3-latest/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py in type(self, dst_type) 233 Module: self 234 """ --> 235 return self._apply(lambda t: t.type(dst_type)) 236 237 def float(self): ~/.pyenv/versions/miniconda3-latest/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py in _apply(self, fn) 144 def _apply(self, fn): 145 for module in self.children(): --> 146 module._apply(fn) 147 148 for param in self._parameters.values(): ~/.pyenv/versions/miniconda3-latest/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py in _apply(self, fn) 144 def _apply(self, fn): 145 for module in self.children(): --> 146 module._apply(fn) 147 148 for param in self._parameters.values(): ~/.pyenv/versions/miniconda3-latest/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py in _apply(self, fn) 144 def _apply(self, fn): 145 for module in self.children(): --> 146 module._apply(fn) 147 148 for param in self._parameters.values(): ~/.pyenv/versions/miniconda3-latest/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py in _apply(self, fn) 150 # Variables stored in modules are graph leaves, and we don't 151 # want to create copy nodes, so we have to unpack the data. --> 152 param.data = fn(param.data) 153 if param._grad is not None: 154 param._grad.data = fn(param._grad.data) ~/.pyenv/versions/miniconda3-latest/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py in (t) 233 Module: self 234 """ --> 235 return self._apply(lambda t: t.type(dst_type)) 236 237 def float(self): ~/.pyenv/versions/miniconda3-latest/envs/pytorch/lib/python3.6/site-packages/torch/_utils.py in _type(self, new_type, async) 36 if new_type.is_sparse: 37 raise RuntimeError("Cannot cast dense tensor to sparse tensor") ---> 38 return new_type(self.size()).copy_(self, async) 39 40 ~/.pyenv/versions/miniconda3-latest/envs/pytorch/lib/python3.6/site-packages/torch/cuda/__init__.py in _lazy_new(cls, *args, **kwargs) 356 @staticmethod 357 def _lazy_new(cls, *args, **kwargs): --> 358 _lazy_init() 359 # We need this method only for lazy init, so we can remove it 360 del _CudaBase.__new__ ~/.pyenv/versions/miniconda3-latest/envs/pytorch/lib/python3.6/site-packages/torch/cuda/__init__.py in _lazy_init() 119 "Cannot re-initialize CUDA in forked subprocess. " + msg) 120 _check_driver() --> 121 torch._C._cuda_init() 122 torch._C._cuda_sparse_init() 123 _cudart = _load_cudart() RuntimeError: cuda runtime error (30) : unknown error at /opt/conda/conda-bld/pytorch_1512387374934/work/torch/lib/THC/THCGeneral.c:70
DmitryUlyanov commented 6 years ago

Unfortunately, I have no idea how to solve unknown errors...

sbrugman commented 6 years ago

When running the code on my machine another error is provided for the same piece of code, which might help you to track down the source of the error.

TypeError                                 Traceback (most recent call last)
<ipython-input-4-86a46ec7bdd9> in <module>()
     20                 num_channels_skip = [0, 0, 0, 4, 4],
     21                 upsample_mode='bilinear',
---> 22                 need_sigmoid=True, need_bias=True, pad=pad, act_fun='LeakyReLU')
     23 
     24     net = net.type(dtype)

/mnt/3E6227E362279F21/scriptie/deep-image-prior/models/skip.py in skip(num_input_channels, num_output_channels, num_channels_down, num_channels_up, num_channels_skip, filter_size_down, filter_size_up, filter_skip_size, need_sigmoid, need_bias, pad, upsample_mode, downsample_mode, act_fun, need1x1_up)
     51             model_tmp.add(Concat(1, skip, deeper))
     52         else:
---> 53             model_tmp.add(deeper)
     54 
     55         model_tmp.add(bn(num_channels_skip[i] + (num_channels_up[i + 1] if i < last_scale else num_channels_down[i])))

/mnt/3E6227E362279F21/scriptie/deep-image-prior/models/common.py in add_module(self, module)
      4 
      5 def add_module(self, module):
----> 6     self.add_module(str(len(self) + 1), module)
      7 
      8 torch.nn.Module.add = add_module

TypeError: object of type 'Sequential' has no len()
sbrugman commented 6 years ago

Problem was solved by changing the kernel of the jupyter notebook to python 3...

Sudo-Biao commented 6 years ago

Just the same problem as "TypeError: object of type 'Sequential' has no len()". Why is it useless for me when I change the kernel of jupyter to python3