-
Notifications
You must be signed in to change notification settings - Fork 143
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
How to use Semantra with GPU via PyTorch #36
Comments
These are some good questions and definitely worthy of a write-up when I find the time.
|
Is it possible to add the GPU version of pytorch to the requirements installed by pipx? I have a CUDA-enabled NVIDIA GPU but it wasn't being used when I ran semantra in Windows. Would I install them with pipx so they aren't contaminating the main environment? |
I tried to follow the official instructions from https://pytorch.org/get-started/locally/ but adapted to pipx:
But it doesn't work. The command
uses CPU only, there's no GPU/CUDA usage at all. The right libraries are now installed in the environment, though?
I don't know how you managed to create a semantra.exe file from a python environment though. Does it use the python libraries from the environment or does it have them baked into an executable permanently somehow? |
|
Is this accurate? In the past I've tried downloading CUDA toolkit from the website and it was an ordeal and didn't work, so I'm hesitant to try that again. ChatGPTI understand your confusion. The Here's a brief explanation of the different components involved:
So, to use PyTorch with CUDA, you need to do two things:
Once you've done both of these things, PyTorch should be able to use CUDA to run computations on the GPU. YouI don't think this is necessary when installing pytorch with conda? ChatGPTYou're correct. When you install PyTorch with Conda using the command you provided, Conda will automatically install the correct version of the CUDA toolkit as a dependency. This is one of the advantages of using Conda: it manages dependencies for you, including non-Python dependencies like the CUDA toolkit. However, pip and pipx don't manage non-Python dependencies. When you install PyTorch with pip or pipx, you need to install the CUDA toolkit separately. This is why you're seeing the If you prefer to use Conda to manage your Python environments and dependencies, you could create a new Conda environment, install PyTorch in that environment using the command you provided, and then install semantra in the same environment. This way, semantra and PyTorch would both have access to the same CUDA toolkit installation. Here's how you can do it:
conda create --name semantra_env
conda activate semantra_env
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
pip install semantra
Now, you should be able to run semantra with GPU support in the |
You could try cloning Semantra, editing the requirements to include the GPU source you need, and then I think on the whole though I need a more plug-and-play approach. Will target for v0.2. |
I tried to use pip from within the pipx virtual environment, but it wasn't working. Then I saw "permission denied" errors and I realized it was resolving to my system pip and not one in the pipx virtual env. It only worked with below command:
After running that, semantra now uses the gpu instead of cpu. I think switching to python -m venv instead of pipx would prevent this issue in the future. In a python venv, you wouldn't have this issue of pip not resolving correctly. |
Hi, Thanks for the great work and wonderful tool, and my apologies for asking 2 different questions in one thread.
I was following the guides on how to use Semantra and got it running, but I couldn't find guide on how to utilize my GPU (RTX 3070) instead of my old CPU.
I have followed the link to get PyTorch running, but still Semantra is only utilizing my CPU.
I have also notice that it takes some disk space (~10 GB) after running quite few pdfs and text tests, and was trying to figure out if this space was taken for cache embeddings and/or for trying different models. So far I couldn't find all locations related to Semantra.
I really appreciate your help. Thanks
The text was updated successfully, but these errors were encountered: