Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Revised M1/M2 installation instructions.
  • Loading branch information
PromtEngineer committed Jun 20, 2023
1 parent 979f912 commit 9aab283
Showing 1 changed file with 2 additions and 38 deletions.
40 changes: 2 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ Follow this [page](https://linuxconfig.org/how-to-install-the-nvidia-drivers-on-

1- Follow this [page](https://developer.apple.com/metal/pytorch/) to build up PyTorch with Metal Performance Shaders (MPS) support. PyTorch uses the new MPS backend for GPU training acceleration. It is good practice to verify mps support using a simple Python script as mentioned in the provided link.

2- By following the page, here is an example of you may initiate in your terminal
2- By following the page, here is an example of what you may initiate in your terminal

```shell
xcode-select --install
Expand All @@ -220,45 +220,9 @@ pip install pdfminer.six
pip install xformers
```

3- Create a new `verifymps.py` in the same directory (localGPT) where you have all files and environment.
3- Please keep in mind that the quantized models are not yet supported by Apple Silicon (M1/M2) by auto-gptq library that is being used for loading quantized models, [see here](https://github.com/PanQiWei/AutoGPTQ/issues/133#issuecomment-1575002893). Therefore, you will not be able to run quantized models on M1/M2.

import torch
if torch.backends.mps.is_available():
mps_device = torch.device("mps")
x = torch.ones(1, device=mps_device)
print (x)
else:
print ("MPS device not found.")

4- Find `instructor.py` and open it in VS Code to edit.

The `instructor.py` is probably embeded similar to this:

file_path = "/System/Volumes/Data/Users/USERNAME/anaconda3/envs/LocalGPT/lib/python3.10/site-packages/InstructorEmbedding/instructor.py"

You can open the `instructor.py` and then edit it using this code:

#### Open the file in VSCode

subprocess.run(["open", "-a", "Visual Studio Code", file_path])

Once you open `instructor.py` with VS Code, replace the code snippet that has `device_type` with the following codes:

if device is None:
device = self._target_device

# Replace the line: self.to(device)

if device in ['cpu', 'CPU']:
device = torch.device('cpu')

elif device in ['mps', 'MPS']:
device = torch.device('mps')

else:
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

self.to(device)

## Star History

Expand Down

0 comments on commit 9aab283

Please sign in to comment.