SourceChangeWarning

#1

When I export, and use the pkl file in another computer, I got this:

/opt/conda/lib/python3.6/site-packages/torch/serialization.py:454: SourceChangeWarning: source code of class 'torch.nn.modules.loss.CrossEntropyLoss' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
/opt/conda/lib/python3.6/site-packages/torch/serialization.py:454: SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
/opt/conda/lib/python3.6/site-packages/torch/serialization.py:454: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.BatchNorm2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
/opt/conda/lib/python3.6/site-packages/torch/serialization.py:454: SourceChangeWarning: source code of class 'torch.nn.modules.activation.ReLU' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
/opt/conda/lib/python3.6/site-packages/torch/serialization.py:454: SourceChangeWarning: source code of class 'torchvision.models.densenet._DenseBlock' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
/opt/conda/lib/python3.6/site-packages/torch/serialization.py:454: SourceChangeWarning: source code of class 'torchvision.models.densenet._DenseLayer' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
/opt/conda/lib/python3.6/site-packages/torch/serialization.py:454: SourceChangeWarning: source code of class 'torch.nn.modules.pooling.AdaptiveAvgPool2d' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
/opt/conda/lib/python3.6/site-packages/torch/serialization.py:454: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.BatchNorm1d' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
/opt/conda/lib/python3.6/site-packages/torch/serialization.py:454: SourceChangeWarning: source code of class 'torch.nn.modules.dropout.Dropout' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)
/opt/conda/lib/python3.6/site-packages/torch/serialization.py:454: SourceChangeWarning: source code of class 'torch.nn.modules.linear.Linear' has changed. you can retrieve the original source code by accessing the object's source attribute or set `torch.nn.Module.dump_patches = True` and use the patch tool to revert the changes.
  warnings.warn(msg, SourceChangeWarning)

More details:

I use python 3.7 to train my model(I use to_fp16), export it, and copy it to another computer, which is python 3.6, and I got that warning. What should I do?

And I test same python version and no to_fp16, still the same!

0 Likes

#3

Hi Cugtyt hope you are having a jolly day!

I have had this problem numerous times as I train on Google Colab and my local is machine is a Macbook pro (No GPU).

When I train a model on Colab I then have to use that model in an App for myself or a client.

I have tried four solutions to this problem

  1. set up a VM that is identical to the other computer.
  2. Train the model on the other computer (sometimes difficult as an epoch on my mac can take 2hrs and Colab 5 minutes)
  3. Try and debug the differences between using python 3.6 and 3.7 and possible differences in versions of fastai and other libraries and dependencies. (have tried - not always possible, time consuming and difficult).
  4. Use Docker.

My recent research seems to indicate your problem is one of the reasons Docker was created.

I am currently trying To configure Docker instead of Anaconda VM as often there are small changes to libraries which are dependent on other libraries and the documentation hasn’t been updated. Anaconda is always a 1 or 2 versions of certain libraries, behind in their distribution of Fastai compared to Google Colab. So I have had to manually add libraries via pip install to make it work.

I am hoping Docker will put a speedy end to problems transferring models between myself, Google Colab and customer systems.

I am open to any other suggestions, if you find a quick and easy way to resolve your problem.

Cheers.

mrafabulous1 :smiley::smiley:
oops just saw the date of this post (you have probably solved it by now! )

0 Likes