Comments (9)
This was discussed in #38, #24
@colesbury writes: Load the model, run clearState(), and save the model:
model = torch.load('model.t7')
model:clearState()
torch.save('model_small.t7', model)
Unfortunately, this doesn't save RAM while training, but it can save disk space.
from fb.resnet.torch.
You can add model:clearState()
here:
https://github.com/facebook/fb.resnet.torch/blob/master/checkpoints.lua#L29
However, this breaks the sharing gradInput
, so you should not run with -shareGradInput
. This is why I haven't added it to checkpointing code yet.
from fb.resnet.torch.
So these numbers are for GPU with 12 GB of memory each (e.g. K40, Titan X) with batch size 256. You can use a smaller batch size, but then your on your own when it comes to the LR schedule:
ResNet-101 fits on 4 GPUs and requires ~10.5 GB per GPU
ResNet-152 fits on 8 GPUs and requires ~7 GB per GPU
ResNet-200 fits on 8 GPUS and requires ~9 GB per GPU
(You can also have a larger effective batch size by accumulating the gradients from multiple mini-batches before updating parameters)
from fb.resnet.torch.
Thanks for your help. So far I have only been using the command-line level training. Where exactly do I have to insert those lines of code?
from fb.resnet.torch.
Thanks. I guess at this point I care more about -shareGradInput
than the size of model files, so I think I'll stick with the existing code after all.
Any idea how much GPU memory is required for retraining 101, 152 and 200 resnets?
from fb.resnet.torch.
Yeah, as I don't see getting 4 - 8 12 GB any time soon, I think I'll stick with lower capacity models for now. :) Thanks for all your great help and insights!
from fb.resnet.torch.
Is it possible, during initialization, to create a dummy model that will only share with the original training model variables that are useful during testing and then save this dummy model instead?
For example, inside main.lua
:
-- Create model
local model, criterion = models.setup(opt, checkpoint)
-- Create dummy model just for saving
local dummymodel = model:clone()
dummymodel:share(model, 'bias')
dummymodel:share(model, 'weight')
dummymodel:share(model, 'running_mean') -- For BatchNorm
dummymodel:share(model, 'running_var') -- For BatchNorm
--- Enter for cycle that trains for an epoch ...
...
-- At the end of for loop epoch
checkpoints.save(epoch, dummymodel, trainer.optimState, bestModel)
end
Could this help with the gradInput
sharing?
from fb.resnet.torch.
@pedropgusmao, yeah that might be the best option for now
from fb.resnet.torch.
Fixed in f54d7c8
from fb.resnet.torch.
Related Issues (20)
- dataset.lua,dataset-gen.lua HOT 1
- Random luajit errors
- How Can I Plot the Train Curve ? HOT 2
- running time of ResNets HOT 5
- DataSampler.lua:230: bad argument #3 to 'narrow'
- Missing batch norm in ResNet-18 weights HOT 1
- Retrain with different input size
- Can I use video or webcam to classify ? (I have a fine-tuned model with my own data.) HOT 1
- it's my code but i don't why it's show me this error...
- What are the settings of pretrained ResNet-101 and ResNet-152 model files? HOT 2
- How to extract the lower level feature with pretrained model?
- INIT.LUA not found
- How to control the CPU kernels that are used during training.
- Can not reach the validation error rate for Resnet-50 (single-crop 224*224) HOT 1
- TestOnly on different machines give different results HOT 1
- Using cifar-100 with 15 classes HOT 7
- nn
- CMake error while running install.sh HOT 7
- running lua in Pytorch HOT 1
- I want to retrain a resnext_101_32*4d.Is it possible?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fb.resnet.torch.