pdfGPT icon indicating copy to clipboard operation
pdfGPT copied to clipboard

M1 Mac Tensorflow

Open kpatdev opened this issue 2 years ago • 18 comments

Anyone able to get this to work on MacOS? I am trying to get this working in a virtual environment with Python 3.10 and have to use tensorflow-macos and tensorflow-metal.

Unsure what to change in requirements but I keep getting errors when trying to install all the dependencies.

On mobile right now but will update with full errors when I get back to my laptop.

kpatdev avatar Apr 15 '23 03:04 kpatdev

I'm having the same problem the same problem. Hopefully someone can come up with a fix for Apple M1 users.

WizKid1968 avatar Apr 16 '23 08:04 WizKid1968

I had the same issue, you have to downgrade your version to python 3.9. Create the 3.9 version in your environment. instead.

GitNinja42 avatar Apr 16 '23 13:04 GitNinja42

Just an update, even though I no longer got the Tensorflow error, I got an illegal hardware error on my Mac M1 as well. I don't think his script works with M1's, since GPT-4 diagnosed the issue as a hardware incompatibility with Tensorflow.

GitNinja42 avatar Apr 16 '23 13:04 GitNinja42

The code was written to work on Huggingface, not localhost (win/mac).

bhaskatripathi avatar Apr 16 '23 14:04 bhaskatripathi

The code was written to work on Huggingface, not localhost (win/mac).

Any plans to have it work on localhost (win/mac) or web server?

WizKid1968 avatar Apr 16 '23 15:04 WizKid1968

I will release a code working on Windows localhost. I am sorry, I do not have a Mac to test it.

bhaskatripathi avatar Apr 16 '23 15:04 bhaskatripathi

Would be happy to have someone contribute the mac version of running code.

bhaskatripathi avatar Apr 16 '23 15:04 bhaskatripathi

You can run this on localhost using docker:

docker run -it -p 7860:7860 --platform=linux/amd64 registry.hf.space/bhaskartripathi-pdfchatter:latest python app.py

Here is an example: https://gradio.app/sharing-your-app/#embedding-hosted-spaces

bhaskatripathi avatar Apr 16 '23 16:04 bhaskatripathi

Hey thanks so much for responding! I wasn't meaning to complain about it - I just shared a fix to the Tensorflow problem, but it created new ones and I suspected it was a Mac issue.

I wanted a local version cause I wanted to try to add a bunch of features to it, like multiple PDF support, and some prompt processing before it gets embedded into a vector. I'm not familiar with docker but I am sure I can figure it out.

How is this embedding free whereas OpenAI's embedding and Pinecone cost money? Who's processing and storing the vectors for free?

GitNinja42 avatar Apr 16 '23 18:04 GitNinja42

This embedding uses Google's universal sentence encoder which is free. Huggingface has hosted it for free but local might be faster as HF infra is free but little slow. You can download the embedding model on local and then try. My GPU is way too outdated for it to run on local. However, if you have Rtx 3070 or above, it should work smoothly on local.

bhaskatripathi avatar Apr 16 '23 23:04 bhaskatripathi

I can try and help with getting this running on a Mac. Also, I'm not quite understanding. What parts of the code would need changes/updates to get this to work on localhost (Mac, Linux or Windows - I have access to all and could help test)? Is the local model needed or can I just work with the hosted model but run the actual program locally?

kpatdev avatar Apr 18 '23 23:04 kpatdev

I had the same issue, you have to downgrade your version to python 3.9. Create the 3.9 version in your environment. instead.

Odd, I tried that and I still was unable to install tensorflow.

Screenshot 2023-04-18 at 8 24 54 PM

Edit: Disregard that, using tensorflow-macos and tensorflow-metal I'm able to get a bit further. But running into multiple other errors as you mentioned.

I'll try and replicate this project from scratch on M1 and see how far I can get to try and get this working locally. Really wanna get this working as a webapp locally.

kpatdev avatar Apr 19 '23 00:04 kpatdev

Really sorry to hear that, not sure why.

I am also willing to try helping on a Mac too, I can give him access to it if that helps, but I am not sure how to convert his script into a Mac.

For what it's worth, dezerving, I wrote a separate script that uses Langchain + OpenAI embeddings + Chroma (to store the vectors) to achieve the same function - can share if you are interested. The only problem is that OpenAI embeddings are kinda expensive, which defeats the whole purpose of trying to run bhaskaripathi's script.

GitNinja42 avatar Apr 19 '23 17:04 GitNinja42

Really sorry to hear that, not sure why.

I am also willing to try helping on a Mac too, I can give him access to it if that helps, but I am not sure how to convert his script into a Mac.

For what it's worth, dezerving, I wrote a separate script that uses Langchain + OpenAI embeddings + Chroma (to store the vectors) to achieve the same function - can share if you are interested. The only problem is that OpenAI embeddings are kinda expensive, which defeats the whole purpose of trying to run bhaskaripathi's script.

Would love to take a look, thanks! Can we not just swap OpenAI embeddings for Universal Sentence Encoder? I'll admit I need to do a bit more research.

kpatdev avatar Apr 20 '23 04:04 kpatdev

I got it to work on an apple silicone.
(my python version 3.10) You need to pip3 install tensorflow-macos pip3 install sklearn pip3 install -U scikit-learn scipy matplotlib

m3kwong avatar Apr 22 '23 14:04 m3kwong

I got it to work on an apple silicone. (my python version 3.10) You need to pip3 install tensorflow-macos pip3 install sklearn pip3 install -U scikit-learn scipy matplotlib

Thanks for this. This worked, along with using pipreqs and pinning versions (pip took over 30m otherwise to try and install from requirements.txt).

This was the result from that:

gradio==3.27.0
numpy==1.23.5
openai==0.27.4
PyMuPDF==1.22.1
scikit_learn==1.2.2
tensorflow_hub==0.13.0

kpatdev avatar Apr 24 '23 14:04 kpatdev

With the very helpful info found the above, I successfully installed in my macbook air (M2)!

  1. Clone this repo
  2. In this repo, edit the requirements.txt found below
  3. pip3 install -r requirements.txt
  4. Run the app python3 app.py
  5. Access to http://localhost:7860
gradio==3.27.0
numpy==1.23.5
openai==0.27.4
PyMuPDF==1.22.1
matplotlib==3.7.1
scikit_learn==1.2.2
scipy==1.10.1
tensorflow-macos==2.12.0
tensorflow_hub==0.13.0

naru-T avatar Apr 24 '23 15:04 naru-T

With the very helpful info found the above, I successfully installed in my macbook air (M2)!

  1. Clone this repo
  2. In this repo, edit the requirements.txt found below
  3. pip3 install -r requirements.txt
  4. Run the app python3 app.py
  5. Access to http://localhost:7860

It works with Macbook Air M1!!!! Thanks Mate!

WizKid1968 avatar Apr 25 '23 09:04 WizKid1968

thanks for resolving this issue

bhaskatripathi avatar Apr 26 '23 09:04 bhaskatripathi