talosh / flameTimewarpML

Flame Machine Learning Timewarp. based on arXiv2020-RIFE
MIT License
35 stars 9 forks source link

v0.4.3 on mac flame 2024 -- "Free RAM" is lower than expected #91

Open jarak08 opened 6 months ago

jarak08 commented 6 months ago

Hi Andriy,

When using flameTimewarpML v0.4.3 on a mac flame_2024.2.1, we noticed that the "Free RAM" reported was low (27G). This is our first time running TWML on a mac (instead of linux). We thought the available ram would be higher (no other apps running). Is this expected behavior?

The mac is an M1 Ultra with 128G of RAM running macOS 14.4.1 (sonoma).

When I logged in as another user and did a psutil.virtual_memory().available, I got ~116G. When I did the same commmand as the flame user in the conda env, I got ~29G. psutil.virtual_memory() shows the total was the same between the two, but everything else was different. However, when I did a vm_stat all numbers were relatively the same.

Also, not very familiar with conda env but I think the test is valid. I just tested in a shell (flame was not running). Please LMK if we're doing anything incorrectly.

thanks, Janice

flameTimewarpML output:

TWML output:
initializing Timewarp ML...
Trained model loaded: /Users/elk/Documents/flameTimewarpML/bundle/trained_models/default/v2.4.model
---
Free RAM: 27.1 Gb available
Image size: 4096 x 2160
Peak memory usage estimation: 17.6 Gb per CPU thread
Limiting therads to 2 CPU worker threads (of 20 available) to prevent RAM from overflow

Logged in as same user (with conda env):

(base) flame07:~ elk$ pip list | grep psutil
psutil                 5.8.0

(base) flame07:~ elk$ python3
Python 3.8.5 (default, Sep  4 2020, 02:22:02)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> import os
>>> psutil.virtual_memory()
svmem(total=137438953472, available=31214690304, percent=77.3, used=2921762816, free=26390863872, active=2316161024, inactive=3009757184, wired=605601792)
>>> 
>>> os.system('/usr/bin/vm_stat')
Mach Virtual Memory Statistics: (page size of 16384 bytes)
Pages free:                             6442438.
Pages active:                            566214.
Pages inactive:                          734806.
Pages speculative:                       442898.
Pages throttled:                              0.
Pages wired down:                        147851.
Pages purgeable:                           3726.
"Translation faults":                1242091097.
Pages copy-on-write:                   24565273.
Pages zero filled:                    774014453.
Pages reactivated:                       496959.
Pages purged:                           2599716.
File-backed pages:                      1441609.
Anonymous pages:                         302309.
Pages stored in compressor:                   0.
Pages occupied by compressor:                 0.
Decompressions:                               0.
Compressions:                                 0.
Pageins:                               16269383.
Pageouts:                                     0.
Swapins:                                      0.
Swapouts:                                     0.
0
>>>

Another user logged in:

(env) engineer@flame07 jtest % pip list | grep psutil
psutil  5.9.8

(env) engineer@flame07 jtest % python3
Python 3.12.3 (main, Apr  9 2024, 08:09:14)
[Clang 15.0.0 (clang-1500.3.9.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import psutil
>>> import os
>>> psutil.virtual_memory()
svmem(total=137438953472, available=124859547648, percent=9.2, used=11686854656, free=105564241920, active=9264644096, inactive=12039028736, wired=2422210560)
>>> 
>>> os.system('/usr/bin/vm_stat')
Mach Virtual Memory Statistics: (page size of 16384 bytes)
Pages free:                             6443054.
Pages active:                            565044.
Pages inactive:                          734804.
Pages speculative:                       442890.
Pages throttled:                              0.
Pages wired down:                        148329.
Pages purgeable:                           3379.
"Translation faults":                1242087099.
Pages copy-on-write:                   24565099.
Pages zero filled:                    774013096.
Pages reactivated:                       496959.
Pages purged:                           2599716.
File-backed pages:                      1441600.
Anonymous pages:                         301138.
Pages stored in compressor:                   0.
Pages occupied by compressor:                 0.
Decompressions:                               0.
Compressions:                                 0.
Pageins:                               16269382.
Pageouts:                                     0.
Swapins:                                      0.
Swapouts:                                     0.
0
>>>
talosh commented 6 months ago

Hi Jarak,

TWML v0.4.3 on mac is trying to run several inference processes in parallel and its trying to figure out the number of processes from the ram available. This will change in v0.4.5 as with new PyTorch it is possible to run most of the model code natively on GPU / TPU so there'll be no need in CPU processing mode.

On Wed, Apr 24, 2024 at 5:51 PM jarak08 @.***> wrote:

Hi Andriy,

When using flameTimewarpML v0.4.3 on a mac flame_2024.2.1, we noticed that the "Free RAM" reported was low (27G). This is our first time running TWML on a mac (instead of linux). We thought the available ram would be higher (no other apps running). Is this expected behavior?

The mac is an M1 Ultra with 128G of RAM running macOS 14.4.1 (sonoma).

When I logged in as another user and did a psutil.virtual_memory().available, I got ~116G. When I did the same commmand as the flame user in the conda env, I got ~29G. psutil.virtual_memory() shows the total was the same between the two, but everything else was different. However, when I did a vm_stat all numbers were relatively the same.

Also, not very familiar with conda env but I think the test is valid. I just tested in a shell (flame was not running). Please LMK if we're doing anything incorrectly.

thanks, Janice

flameTimewarpML output:

TWML output: initializing Timewarp ML... Trained model loaded: /Users/elk/Documents/flameTimewarpML/bundle/trained_models/default/v2.4.model

Free RAM: 27.1 Gb available Image size: 4096 x 2160 Peak memory usage estimation: 17.6 Gb per CPU thread Limiting therads to 2 CPU worker threads (of 20 available) to prevent RAM from overflow

Logged in as same user (with conda env):

(base) flame07:~ elk$ pip list | grep psutil psutil 5.8.0

(base) flame07:~ elk$ python3 Python 3.8.5 (default, Sep 4 2020, 02:22:02) [Clang 10.0.0 ] :: Anaconda, Inc. on darwin Type "help", "copyright", "credits" or "license" for more information.

import psutil import os psutil.virtual_memory() svmem(total=137438953472, available=31214690304, percent=77.3, used=2921762816, free=26390863872, active=2316161024, inactive=3009757184, wired=605601792)

os.system('/usr/bin/vm_stat') Mach Virtual Memory Statistics: (page size of 16384 bytes) Pages free: 6442438. Pages active: 566214. Pages inactive: 734806. Pages speculative: 442898. Pages throttled: 0. Pages wired down: 147851. Pages purgeable: 3726. "Translation faults": 1242091097. Pages copy-on-write: 24565273. Pages zero filled: 774014453. Pages reactivated: 496959. Pages purged: 2599716. File-backed pages: 1441609. Anonymous pages: 302309. Pages stored in compressor: 0. Pages occupied by compressor: 0. Decompressions: 0. Compressions: 0. Pageins: 16269383. Pageouts: 0. Swapins: 0. Swapouts: 0. 0

Another user logged in:

(env) @.*** jtest % pip list | grep psutil psutil 5.9.8

(env) @.*** jtest % python3 Python 3.12.3 (main, Apr 9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)] on darwin Type "help", "copyright", "credits" or "license" for more information.

import psutil import os psutil.virtual_memory() svmem(total=137438953472, available=124859547648, percent=9.2, used=11686854656, free=105564241920, active=9264644096, inactive=12039028736, wired=2422210560)

os.system('/usr/bin/vm_stat') Mach Virtual Memory Statistics: (page size of 16384 bytes) Pages free: 6443054. Pages active: 565044. Pages inactive: 734804. Pages speculative: 442890. Pages throttled: 0. Pages wired down: 148329. Pages purgeable: 3379. "Translation faults": 1242087099. Pages copy-on-write: 24565099. Pages zero filled: 774013096. Pages reactivated: 496959. Pages purged: 2599716. File-backed pages: 1441600. Anonymous pages: 301138. Pages stored in compressor: 0. Pages occupied by compressor: 0. Decompressions: 0. Compressions: 0. Pageins: 16269382. Pageouts: 0. Swapins: 0. Swapouts: 0. 0

— Reply to this email directly, view it on GitHub https://github.com/talosh/flameTimewarpML/issues/91, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMBGYKFHFZCDYDXAI5ZLZYDY67PKFAVCNFSM6AAAAABGXJIIHWVHI2DSMVQWIX3LMV43ASLTON2WKOZSGI3DCNZUHEZTOMQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jarak-lvly commented 6 months ago

Great to know. It kept giving us 1 thread, but when I looked at the code (and did the math) it should've been 6. It was more or less a test to see how much slower it was on the mac compared to linux. Thanks for the update! Janice