thekevinscott / UpscalerJS

Enhance Images with Javascript and AI. Increase resolution, retouch, denoise, and more. Open Source, Browser & Node Compatible, MIT License.
https://upscalerjs.com
MIT License
788 stars 74 forks source link

Allocation of 375652352 exceeds 10% of free system memory. #1284

Closed Livijn closed 6 months ago

Livijn commented 8 months ago

Describe the bug Whenever I run this on my DO droplet, I get an error saying Allocation of 375652352 exceeds 10% of free system memory.. I've tried upgrading the droplet to a CPU-optimized 4GB droplet but that doesn't resolve it.

Additional context

$ node upscale.js XXX.png 2024-01-15 13:34:47.182394: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 AVX512F FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. Platform node has already been set. Overwriting the platform with node. 2024-01-15 13:34:47.364820: W tensorflow/core/framework/cpu_allocator_impl.cc:82] Allocation of 375652352 exceeds 10% of free system memory. 2024-01-15 13:34:47.691049: W tensorflow/core/framework/cpu_allocator_impl.cc:82] Allocation of 375652352 exceeds 10% of free system memory. 2024-01-15 13:34:47.885839: W tensorflow/core/framework/cpu_allocator_impl.cc:82] Allocation of 375652352 exceeds 10% of free system memory. 2024-01-15 13:34:48.705335: W tensorflow/core/framework/cpu_allocator_impl.cc:82] Allocation of 375652352 exceeds 10% of free system memory. 2024-01-15 13:34:49.266533: W tensorflow/core/framework/cpu_allocator_impl.cc:82] Allocation of 399130624 exceeds 10% of free system memory. Killed

thekevinscott commented 8 months ago

What model are you using?

Livijn commented 8 months ago

I've tried basically all models. However, the images I tried upscaling were about 1.5MB (1024  ×  1792 px). When I tried a smaller one it worked on the server.

Do you have any tips on how to upscale a large file like that w/o provisioning a super expensive droplet?

Thanks!

thekevinscott commented 8 months ago

Have you tried using patch sizes? https://upscalerjs.com/documentation/guides/browser/performance/patch-sizes

If it’s still not working, it may be that the image itself is too large to load into a tensor. If you load the image into a tensor using tfjs, does it OOM?

thekevinscott commented 6 months ago

Closing this as stale - please reopen if you're having issues.

Livijn commented 6 months ago

Sorry, forgot to answer. Patch sizes solved it for me :)

thekevinscott commented 6 months ago

Awesome, glad to hear it!