# A implementation of ResNet-18 uses lot of GPU memory

**URL:** <https://discourse.julialang.org/t/a-implementation-of-resnet-18-uses-lot-of-gpu-memory/36389>\
**Category:** Machine Learning\
**Tags:** question, flux\
**Created:** [March 23, 2020, 12:08pm UTC](https://discourse.julialang.org/t/a-implementation-of-resnet-18-uses-lot-of-gpu-memory/36389 "2020-03-23T12:08:50Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Iulian.Cioarca](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/iulian.cioarca/32/30166_2.png) [@Iulian.Cioarca](https://discourse.julialang.org/u/Iulian.Cioarca)\
**Post date:** [March 24, 2020, 10:04am UTC](https://discourse.julialang.org/t/a-implementation-of-resnet-18-uses-lot-of-gpu-memory/36389/2 "2020-03-24T10:04:38Z")

</div>

Hello and welcome!  
You can customize the memory allocator for CuArrays. Please check:  
[https://juliagpu.gitlab.io/CUDA.jl/usage/memory/](https://juliagpu.gitlab.io/CUDA.jl/usage/memory/)

Example (add these lines before ‘using’ anything, at the start of your session):

```julia
ENV["JULIA_CUDA_VERBOSE"] = true
ENV["CUARRAYS_MEMORY_POOL"] = "split"
ENV["CUARRAYS_MEMORY_LIMIT"] = 8000_000_000

using CuArrays

```

You can also try to use larger batch sizes during training.

I also had similar issues with some custom networks and playing with the ENVs above helped a lot.  
I never did a comparison with Tensorflow or other frameworks, though…

I see you do some `float.` conversions. This by default converts to Float64. It’s better to use Float32 data all over your code.

As a side note, please format your code example using [backticks](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757), it’s much easier for others to read and understand.

---

_[View the full topic](https://discourse.julialang.org/t/a-implementation-of-resnet-18-uses-lot-of-gpu-memory/36389)._
