chainer-fast-neuralstyle icon indicating copy to clipboard operation
chainer-fast-neuralstyle copied to clipboard

volatile argument is not supported anymore. Use chainer.using_config

Open ChoclateRain opened this issue 7 years ago • 10 comments

I am running into this error when trying to train, and i have no idea why

python train.py -s Beanslitter/DoubleRainbow.png -d dataset/train2014 -g 0

num traning images: 82783 82783 iterations, 2 epochs Traceback (most recent call last): File "train.py", line 100, in feature_s = vgg(Variable(style_b, volatile=True)) File "/home/poop/anaconda2/lib/python2.7/site-packages/chainer/variable.py", line 307, in init kwargs, volatile='volatile argument is not supported anymore. ' File "/home/poop/anaconda2/lib/python2.7/site-packages/chainer/utils/argument.py", line 4, in check_unexpected_kwargs raise ValueError(message) ValueError: volatile argument is not supported anymore. Use chainer.using_config python train.py -s Beanslitter/DoubleRainbow.png -d dataset/train2014 -g 0

ChoclateRain avatar Jun 24 '17 22:06 ChoclateRain

  • Temporarily fixed it by removing all "volatile" lines in train.py Was also getting an error about "test=" in generate.py Solved that by removing all "test" entries in generate.py

Not sure what the function of them being there was Works perfectly without them

ChoclateRain avatar Jun 25 '17 00:06 ChoclateRain

same issue @ChoclateRain how you remove volatile & test entries? you remove all the line? it doensnt work for me, thx alot

mrbluematrix avatar Sep 18 '17 14:09 mrbluematrix

Also had this issue, fixed it by downgrading chainer version pip install chainer==1.17.0

sebastianandreasson avatar Sep 29 '17 19:09 sebastianandreasson

This problem was caused by the version update of chainer. The offical explains are:

In Chainer v2, the concept of training mode is added. It is represented by a thread-local flag chainer.config.train, which is a part of the unified configuration. When chainer.config.train is True, functions of Chainer run in the training mode, and otherwise they run in the test mode. For example, BatchNormalization and dropout() behave differently in each mode.

In Chainer v1, such a behavior was configured by the train or test argument of each function. This train/test argument has been removed in Chainer v2. If your code is using the train or test argument, you have to update it. In most cases, what you have to do is just removing the train / test argument from any function calls.

Also you can find examples here: https://docs.chainer.org/en/stable/upgrade.html#global-configurations

pengjingg avatar Nov 17 '17 05:11 pengjingg

what is your vision of cuda and cudnn?@sebastianandreasson

HuiXu529731723 avatar Mar 26 '18 14:03 HuiXu529731723

Removing "volatile" from .py file (I removed volatile as a parameter of a chainer function) did not help me to resolve the issue. Has anyone else fixed this issue?

chainer.Variable(np.asarray(x_test[perm[j:j + batchsize]]))

dianaow avatar May 22 '18 06:05 dianaow

@dianaow did you found any solution ?

jaysinghr avatar Feb 18 '19 13:02 jaysinghr

Solution is written here I guess: https://docs.chainer.org/en/stable/reference/generated/chainer.Variable.html https://docs.chainer.org/en/stable/reference/generated/chainer.no_backprop_mode.html#chainer.no_backprop_mode


"volatile argument is not supported anymore since v2. Instead, use chainer.no_backprop_mode()."

x = chainer.Variable(np.array([1,], np.float32))
  with chainer.no_backprop_mode():
    y = x + 1
y.backward()
x.grad is None  #True

Hence your computation were your variables created with : chainer.Variable( ... , volatile=True) move in the with statement. As said in the doc, this operation "has the benefit of reducing memory consumption"

marc-moreaux avatar Feb 20 '19 19:02 marc-moreaux

Could you please send an example code. my code looks like this: style_mats = [get_matrix(y) for y in nn.forward(Variable(img_style, volatile=True))] I don#t understand where to replace the img_style so that I can replace Variable(img_style, volatile=True with x My understanding was: style_mats = chainer.Variable(np.array([1,], np.float32)) with chainer.no_backprop_mode(): y = style_mats + 1 y.backward() style_mats.grad is None

DerOzean avatar May 20 '19 19:05 DerOzean

I found a solution, I just deleted the code Now I am using: style_mats = [get_matrix(y) for y in nn.forward(Variable(img_style))]

DerOzean avatar May 20 '19 21:05 DerOzean