Initial support for Torch7 in DIGITS - #324
Conversation
|
Thanks for the comments. I have pushed a patch which will hopefully make the error message slightly less cryptic. It should show something like: Torch is particularly slow on Lenet as Lenet is using the regular cunn backend (as opposed to cudnn). One slight complexity with Torch is that the model definition is not the same depending on which backend you want to use. Originally I wanted a very simple model example where the definition does not depend on whether an Nvidia GPU is available. Besides, training in Torch is quite slow to start up as the computation of validation loss/accuracy is far from optimal (uses a single thread to load data and run the main computations). On the other hand, training is multi-threaded so we're wasting less time waiting for data. The difference between Torch and Caffe should be less dramatic on "bigger" models. Still, there are a few things I can do to improve speed. I will try. Regarding the accuracy: I still can't quite figure out how Caffe manages to be right so quickly. Possibly there are tricks in Caffe to deal with the initial learning rate/momentum in models. When I checked Caffe v.s. Torch on less trivial datasets I had a feeling that the accuracy was somewhat similar. Thanks again for the comments! |
|
And also, we need to figure out how to run Torch tests on Travis... |
That should be NBD. Just add a line here: https://github.com/NVIDIA/DIGITS/blob/v2.2.1/.travis.yml#L32 |
|
Added Torch install to Travis => code coverage almost unchanged |
c850521 to
4e2a55d
Compare
|
Yikes, that bumps the TravisCI build time up from ~8mins to ~25mins. But that's actually better than I expected. @semisight and I had a hard time getting the build time under 1 hour, so well done! |
There was a problem hiding this comment.
One bothersome thing about putting the "experimental" text in the TorchFramework class is that old torch jobs will continue to be flagged as "experimental" even when DIGITS upgrades to "full support" (whatever that means). Is there a way to put the "experimental" flagging in the template somewhere rather than here?
There was a problem hiding this comment.
The 'descriptive' name is only used in the navigation pane there on the model creation pane. The model job keeps a link to the framework through the train task and its framework_id field there - the framework ID is what's shown on the home page and in the previous networks tab. We can change the descriptive name and that will change the display on the navigation pane however the framework ID will still be 'torch'. When we want to support Torch9 we can create a new framework ID to denote the change in major version. Is that OK?
There was a problem hiding this comment.
Oh I see. This isn't a TrainTask, so it doesn't get pickled. Nevermind.
|
I tried to use AlexNet and I got this error: ... not super helpful. We need better error reporting. Can you catch Lua errors and format them as an ERROR log message so that DIGITS can catch it and display it? When I looked in the logs, the issue became clear. I don't have cuDNN in my path because I use CMake to build Caffe and it sets the Our current stance is that cuDNN is optional:
But it seems that cuDNN is required to run AlexNet with Torch. Is there any way to get out of requiring cuDNN to run AlexNet? |
You're right. Here's the results of a [very much non-rigorous] test I tried. It's one epoch on a dataset of ~40k images.
This isn't a blocking issue for merging this PR, I'm just posting some benchmarking information. |
|
I tried viewing the weights and activations for a Torch GoogLeNet model and got this error: |
e78286d to
952862d
Compare
I have fixed a bug in the Torch output capture. Now the Lua exceptions should show on the task status box. I have also added a test to verify this automatically (for Caffe and Torch) |
I will try to change the network definition so that it falls back to the legacy cunn modules if cudnn is not available and nn if no GPU is available |
Oh, actually I meant to ask if there was any way to print an ERROR log message so that the
Oh yeah, good point. We don't actually require CUDA at the moment either. Would that require writing three different version of each of the standard networks (CPU/CUDA/cuDNN)? |
I think it is possible but it would require some refactoring of the code (to call everything from a
Hopefully, changes would be fairly limited so it should look like one definition of a model with some aliases to point to the right backend (cudnn, cunn, or nn) |
|
I have updated the definitions of Alexnet/GoogLeNet so they work on CuDNN, bare CUDA and CPU. |
Verified that it's working for me. Neat! |
|
/cc @soumith @szagoruyko |
|
Hi guys, is there still a problem with torch being slower than caffe? we can try to take a look, I am actually sure that they have the same speed, sometime ago I did testing of both with the same network with https://github.com/szagoruyko/torch-caffe-binding , were giving exactly the same timings with cudnn. |
|
Hi @szagoruyko I have to spend some time studying carefully where the timing discrepancy lives between Torch in DIGITS and Caffe in DIGITS. In the Lua wrapper for Torch in DIGITS I have moved the data loading part to a dedicated thread but I have to check whether we may sometimes be waiting for data in the main thread that is running the forward/backward computations. Besides, for example the flavour of Alexnet we're using in Torch is not strictly identical to the one we're using in Caffe (the Torch one has more filters) so we're not exactly comparing apples to apples. I'll get back to you regarding timings when I have more solid information. Thanks! |
5d7bf28 to
9c76f28
Compare
|
Rebase on tip of master and squashed my commits. |
|
It seems to me like everything is working as advertised, but maybe we can advertise the shortcomings a little more clearly? What if we did something like we did for HDF5 in #226 - provide a little warning that lets people know which things they might expect to be able to do with Torch but can't currently:
|
9c76f28 to
935b935
Compare
Yes, good point, thanks! I have added a warning to tell the user what the restrictions are when a Torch model is being selected. The Travis test failed with a cryptic error: Interestingly, the same commit passed the test on my fork: https://travis-ci.org/gheinrich/DIGITS. |
Actually, it looks like another build timeout, even after merging #332. Is Travis getting slower? https://s3.amazonaws.com/archive.travis-ci.org/jobs/83012672/log.txt I restarted your build for now. |
Looks good, thanks. |
Initial support for Torch7 in DIGITS
|
Merged. Many thanks to @Sravan2j for the initial work and to @gheinrich for bringing it home! TODO:
|
|
whut whut!!!!!!!!!!!!!!!!!!!!!! |
|
Please do let us / rest of the dev community know what issues are
On Fri, Oct 2, 2015 at 10:21 PM, Soumith Chintala notifications@github.com
|
|
You might want to check Torch install/usage instructions for DIGITS there. Any feedback welcome, thanks! |
|
Probably a simple fix for this, The version of HDF5 I have installed (h5py-2.2.1) was part of the requirements for DIGITS. |
|
Did you also install package |
|
@j-wilson did that work for you? |
|
@gheinrich After installing Caffe, the luarocks install went through without issue. Starting up a devserver asks for a path to Caffe (no mention of Torch). Been a bit busy; so, I haven't had a chance to chase this further. At this point, I'd imagine that it's probably a simple issue of providing the proper paths etc. Will follow up. |
|
Thanks @j-wilson, if the I hope this is clear enough - there is an attempt at explaining this there but it's probably hidden too deep :-) |
|
Interesting. So |
|
If you were able to start the DIGITS server then all the Caffe dependencies should be OK and you should be able to use Torch to train models in DIGITS as illustrated on https://github.com/NVIDIA/DIGITS/blob/master/docs/images/torch-selection.png. You need to click on the Torch tab underneath 'Standard Networks'. Good luck! |
|
In case this needs clearing up:
|
|
I successfully installed digits with torch support. I realized that i deleted my imagenet lmdb db, so figuring out how to recreate it, after which I'll try to close the perf gaps. |
|
Thanks Soumith. Using the CUDA profiler we have established that the perf gap between Caffe and Torch in DIGITS is mainly due to the data loader we have implemented around torch.cudnn. The amount of CUDA compute is almost identical between Caffe and Torch for a given network. As Natalia Gimelshein explained to me, there is one tiny difference (which amounts to ~5% of extra compute utlization in Torch) through extra calls to convolve_dgrad_engine which according to Natalia could be avoided by setting the gradInput field of the first layer in the network to nil. It doesn't quite work for nn.MulConstant though (maybe I should set inplace=true?). |
|
I've finally got an lmdb (took long enough) and can take a look slowly. An example multi-threaded lmdb data-loader is here btw: https://github.com/facebook/eyescream/blob/master/lsun/donkey_lsun.lua |



Pull request to prepare ground for merge to master (will need rebasing/squashing and QA report before commit)