finalf0 commited on
Commit
cecfa59
·
verified ·
1 Parent(s): ad5013b

Update usage on Mac and GPUs do not support BF16

Browse files
Files changed (1) hide show
  1. README.md +14 -6
README.md CHANGED
@@ -112,23 +112,31 @@ Currently MiniCPM-V (i.e., OmniLMM-3B) can be deployed on mobile phones with And
112
 
113
 
114
  ## Usage
115
- Requirements: tested on python 3.10
116
  ```
117
  Pillow==10.1.0
118
  timm==0.9.10
119
- torch==2.0.1
120
- torchvision==0.15.2
121
  transformers==4.36.0
122
  sentencepiece==0.1.99
123
  ```
124
 
125
  ```python
 
126
  import torch
127
  from PIL import Image
128
  from transformers import AutoModel, AutoTokenizer
129
 
130
- model = AutoModel.from_pretrained('openbmb/MiniCPM-V', trust_remote_code=True)
131
- model = model.to(dtype=torch.bfloat16)
 
 
 
 
 
 
 
132
  tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-V', trust_remote_code=True)
133
  model.eval().cuda()
134
 
@@ -158,5 +166,5 @@ Please look at [GitHub](https://github.com/OpenBMB/OmniLMM) for more detail abou
158
  * Please contact [email protected] to obtain a written authorization for commercial uses. Free commercial use is also allowed after registration.
159
 
160
  #### Statement
161
- * As an LLM, MiniCPM-V generates contents by learning a large mount of texts, but it cannot comprehend, express personal opinions or make value judgement. Anything generated by MiniCPM-V does not represent the views and positions of the model developers
162
  * We will not be liable for any problems arising from the use of the MinCPM-V open Source model, including but not limited to data security issues, risk of public opinion, or any risks and problems arising from the misdirection, misuse, dissemination or misuse of the model.
 
112
 
113
 
114
  ## Usage
115
+ Inference using Huggingface transformers on Nivdia GPUs or Mac with MPS (Apple silicon or AMD GPUs). Requirements tested on python 3.10
116
  ```
117
  Pillow==10.1.0
118
  timm==0.9.10
119
+ torch==2.1.2
120
+ torchvision==0.16.2
121
  transformers==4.36.0
122
  sentencepiece==0.1.99
123
  ```
124
 
125
  ```python
126
+ # test.py
127
  import torch
128
  from PIL import Image
129
  from transformers import AutoModel, AutoTokenizer
130
 
131
+ model = AutoModel.from_pretrained('openbmb/MiniCPM-V', trust_remote_code=True, torch_dtype=torch.bfloat16)
132
+ # For Nvidia GPUs support BF16 (like A100, H100, RTX3090)
133
+ model = model.to(device='cuda', dtype=torch.bfloat16)
134
+ # For Nvidia GPUs do NOT support BF16 (like V100, T4, RTX2080)
135
+ #model = model.to(device='cuda', dtype=torch.float16)
136
+ # For Mac with MPS (Apple silicon or AMD GPUs).
137
+ # Run with `PYTORCH_ENABLE_MPS_FALLBACK=1 python test.py`
138
+ #model = model.to(device='mps', dtype=torch.float16)
139
+
140
  tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-V', trust_remote_code=True)
141
  model.eval().cuda()
142
 
 
166
  * Please contact [email protected] to obtain a written authorization for commercial uses. Free commercial use is also allowed after registration.
167
 
168
  #### Statement
169
+ * As a LLM, MiniCPM-V generates contents by learning a large mount of texts, but it cannot comprehend, express personal opinions or make value judgement. Anything generated by MiniCPM-V does not represent the views and positions of the model developers
170
  * We will not be liable for any problems arising from the use of the MinCPM-V open Source model, including but not limited to data security issues, risk of public opinion, or any risks and problems arising from the misdirection, misuse, dissemination or misuse of the model.