Error when installing spacy with cupy #10920
-
Hi, This is a bug report concerning using GPU with spaCy and Anaconda.
when I opened Python in this environment, I saw:
and then I tried to use GPU by typing
|
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 7 replies
-
I noticed this when installing, if this helps:
|
Beta Was this translation helpful? Give feedback.
-
I think I got it. Apparently both CuPy and PyTorch come with an abridged CUDA Toolkit, but they are not enough for spaCy to use. One must install the standalone CUDA Toolkit on NVIDIA website. |
Beta Was this translation helpful? Give feedback.
-
I installed CUDA Toolkit and it didn't work. Guess I'll have to install it first before installing CuPy... |
Beta Was this translation helpful? Give feedback.
-
This time with CUDA I found that without |
Beta Was this translation helpful? Give feedback.
-
The first issue is understandable: spaCy and CuPy uses the smaller CUDA Toolkit and creates a "sandbox" so as to isolate their runtime from the global CUDA. However, the second issue is not clear for me: it seems that I can't use |
Beta Was this translation helpful? Give feedback.
-
Sorry you're having trouble with this. It looks like since you installed Torch without CUDA, it may have used a CPU-only version, and ended up caching that in conda somewhere. For example this issue seems to be the same. I would suggest you create a new conda environment and try reinstalling everything. If that doesn't work check what version of pytorch you have installed - it shouldn't have |
Beta Was this translation helpful? Give feedback.
-
I have the same issue, and I installed all packages by order. It doesn't matter if I install trf or sm, the same issue persists. Solution: update pytorch after everything else. |
Beta Was this translation helpful? Give feedback.
-
As mentioned, I did that from the start. It brings a series of problems - 1. overrides some python scripts that lead to a total jupyter meltdown (the kernel fails to start). |
Beta Was this translation helpful? Give feedback.
-
@Premshay @sunhaozhepy If you can keep your issues in fewer relevant threads, that will help us in responding since we're able to review more information in context. I've just recreated a virtual environment with spaCy running using a GPU from scratch to see what the stumbling blocks were. If you can replicate the process I outline below, I think you'll be able to get spaCy working with a GPU. Note that I'm not using conda installs because it's not clear to me how conda handles extras and the specific cuda versions. That shouldn't really matter for your case though, there's no reason that you should need to use conda and not pip here. One more caveat before I share these steps is that I notice you're on Windows. This means the results you see from using the spaCy install widget or the pytorch install widget might be different, so don't just copy the commands that I have here without using those widgets yourself. Here we go! Check your installed cuda version: nvcc --version You should see something like
I'm at 11.6. That means I want anything I install that uses CUDA to be version <=11.6. Use the widget here to figure out the install command you should run. For me, it was the following: pip install -U 'spacy[cuda116,transformers,lookups]' But when I tried that, I got a warning:
I can see how this would be confusing - personally I think this should fail more loudly than it does and not install anything, but that's more of a pip thing. So if I rerun with the pip install -U 'spacy[cuda115,transformers,lookups]' Now I install the transformers model: python -m spacy download en_core_web_trf No issues. I start up a python REPL: import spacy
nlp = spacy.load('en_core_web_trf')
doc = nlp("This is a doc") Yay, it works! Now, I personally get a warning with
Even though things are working, I'm going to try and fix this warning. I go to the pytorch site and use their installer widget, which tells me I should use this command:
But I already have
Now, running |
Beta Was this translation helpful? Give feedback.
@Premshay @sunhaozhepy If you can keep your issues in fewer relevant threads, that will help us in responding since we're able to review more information in context.
I've just recreated a virtual environment with spaCy running using a GPU from scratch to see what the stumbling blocks were. If you can replicate the process I outline below, I think you'll be able to get spaCy working with a GPU. Note that I'm not using conda installs because it's not clear to me how conda handles extras and the specific cuda versions. That shouldn't really matter for your case though, there's no reason that you should need to use conda and not pip here.
One more caveat before I share these steps is that I n…