# Knet.jl CNN Tutorial Speed

**URL:** <https://discourse.julialang.org/t/knet-jl-cnn-tutorial-speed/7500>\
**Category:** Machine Learning\
**Tags:** performance, knet\
**Created:** [December 4, 2017, 4:56pm UTC](https://discourse.julialang.org/t/knet-jl-cnn-tutorial-speed/7500 "2017-12-04T16:56:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rickhg12hs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rickhg12hs/32/5926_2.png) [@rickhg12hs](https://discourse.julialang.org/u/rickhg12hs)\
**Post date:** [December 4, 2017, 4:56pm UTC](https://discourse.julialang.org/t/knet-jl-cnn-tutorial-speed/7500/1 "2017-12-04T16:56:08Z")

</div>

Knet’s `tutorial.ipynb` trains a CNN with MNIST data. I have no GPU, but my quad-core I7 has been pegged for a day stuck on `cnnmodels = [copy(train!(wcnn, dtrn)) for epoch=1:100];`.

Is this exceptionally long training time to be expected?

---

<div class="post-metadata">

**Author:** ![denizyuret](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/denizyuret/32/568_2.png) [@denizyuret](https://discourse.julialang.org/u/denizyuret)\
**Post date:** [December 11, 2017, 7:05pm UTC](https://discourse.julialang.org/t/knet-jl-cnn-tutorial-speed/7500/2 "2017-12-11T19:05:10Z")

</div>

See [https://github.com/ilkarman/DeepLearningFrameworks](https://github.com/ilkarman/DeepLearningFrameworks) for some benchmarks. Knet CNNs were never optimized for cpus. This is not a high priority because you can’t train anything serious on a cpu. Amazon has gpus for 10-20c an hour on spot price if you want to experiment.

---

<div class="post-metadata">

**Author:** ![rickhg12hs](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rickhg12hs/32/5926_2.png) [@rickhg12hs](https://discourse.julialang.org/u/rickhg12hs)\
**Post date:** [December 12, 2017, 1:22pm UTC](https://discourse.julialang.org/t/knet-jl-cnn-tutorial-speed/7500/3 "2017-12-12T13:22:42Z")

</div>

Well, I suppose “serious” can mean different things to different people. For a student just being introduced to ML, “serious” is being able to complete simple graph ML homework on his/her laptop.

---

<div class="post-metadata">

**Author:** ![denizyuret](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/denizyuret/32/568_2.png) [@denizyuret](https://discourse.julialang.org/u/denizyuret)\
**Post date:** [December 12, 2017, 1:59pm UTC](https://discourse.julialang.org/t/knet-jl-cnn-tutorial-speed/7500/4 "2017-12-12T13:59:43Z")

</div>

I agree. I wrote the current cpu kernels for such students. All code that  
works on gpu should work on cpu in Knet (which usually takes a lot more  
effort on our part, replicating all the functionality of cudnn kernels with  
barely any documentation - just spent last two weeks trying to replicate  
cudnn rnns on cpu). However making this fast and efficient is a different  
matter. Can’t train a state of the art image recognizer or machine  
translation model on cpu even with better kernels in a reasonable amount of  
time. So not sure there is high motivation for efficient cpu kernels. That  
said if somebody writes them I’d be happy to integrate 😉
