Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Higher GPU memory usage vs Python (hkunlp/instructor-large) #397

Open
zeon256 opened this issue Jun 20, 2023 · 2 comments
Open

Higher GPU memory usage vs Python (hkunlp/instructor-large) #397

zeon256 opened this issue Jun 20, 2023 · 2 comments

Comments

@zeon256
Copy link

zeon256 commented Jun 20, 2023

Hello, I wrote a project which uses rust-bert. However, I noticed that loading the same model in python uses 1/2 of what my rust implementation uses even when I only load once. Any idea how to fix this? Any help would be appreciated. Thanks!

Extract from nvidia-smi (Python)

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A       726      G   /usr/lib/Xorg                               518MiB |
|    0   N/A  N/A      1796      G   ...,WinRetrieveSuggestionsOnlyOnDemand       75MiB |
|    0   N/A  N/A      2333      G   ...re/Steam/ubuntu12_64/steamwebhelper        7MiB |
|    0   N/A  N/A      3586      G   /usr/lib/firefox/firefox                    194MiB |
|    0   N/A  N/A      6787      G   ...sion,SpareRendererForSitePerProcess      352MiB |
|    0   N/A  N/A     15763      G   ...--disable-features=BackForwardCache       93MiB |
|    0   N/A  N/A     79356      G   alacritty                                     9MiB |
|    0   N/A  N/A     86867      C   ...envs/langchain-templates/bin/python     1448MiB |
+---------------------------------------------------------------------------------------+

Extract from nvidia-smi (Rust)

+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A       726      G   /usr/lib/Xorg                               518MiB |
|    0   N/A  N/A      1796      G   ...,WinRetrieveSuggestionsOnlyOnDemand       75MiB |
|    0   N/A  N/A      2333      G   ...re/Steam/ubuntu12_64/steamwebhelper        7MiB |
|    0   N/A  N/A      3586      G   /usr/lib/firefox/firefox                    194MiB |
|    0   N/A  N/A      6787      G   ...sion,SpareRendererForSitePerProcess      328MiB |
|    0   N/A  N/A     15763      G   ...--disable-features=BackForwardCache       93MiB |
|    0   N/A  N/A     79356      G   alacritty                                     9MiB |
|    0   N/A  N/A     86607      C   target/release/axum-t5-embeddings          2830MiB |
+---------------------------------------------------------------------------------------+
@guillaume-be
Copy link
Owner

Hello,

It is difficult without seeing the Python code side by side for comparison, but could it be that the Python model is loaded in half precision (fp16)?

@zeon256
Copy link
Author

zeon256 commented Jun 21, 2023

Hello,

It is difficult without seeing the Python code side by side for comparison, but could it be that the Python model is loaded in half precision (fp16)?

Hello,

Apologies for not being clear, this is the reference impl I use. Its calling this from the Instructor library provided by the authors of instructor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants