#๐ Having trouble installing cupy
92 messages ยท Page 1 of 1 (latest)
@reef snow
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Greetings there,
Hope all are well. I am having some trouble installing cupy in my venv.
Here's the error I get.
So, it seems it's not able to access the cuda folder and I think I may be able to resolve the issue by adding the path of cuda to the paths (you can see this in the traceback I sent above).
I'm not sure how I can do this in vs code.
This is the address of my cuda folder.
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5
The files it's looking for (cublas_v2.h and cuda_runtime_api.h) are all inside this folder.
Hmm, is there a reason you must build it from source, instead of using the binary package?
I don't know what else to try to be honest. I tried pip install cupy-cuda12x but I still can't import cupy. It does install sth, and successfully finish, but still can't import cupy.
pip install cupy-cuda12x
Yeah, that sounds right.
It's just not seeing the folder apparently.
still can't import cupy
What do you mean by can't import?
When I type in import cupy as cp, cupy is underlined as not recognized.
aka the package is not installed.
Did you install it into the venv? You said earlier you were installing into a venv, but the log you posted looks like the venv's not activated and you're instead installing it globally.
If you have an NVIDIA GPU you can try it and see if the error is present on your side as well.
I installed it into the venv, I'm sure.
That means you have the venv chosen in vscode, sure, but did you have the venv activated in your terminal when you were installing it?
When I try to install it with pip install cupy it gives the error I sent above.
Yeah, it's activated in the terminal.
It even shows a pop up saying the venv is opened in terminal.
You see (venv) in your terminal prompt?
Hmm, alright. What does pip install cupy-cuda12x output?
I see venv only when I use WSL, never seen it explicitly on Windows.
Umm, one moment...
PS C:\Users\A.C.EA\Documents\GitHub\FPI-Research> pip install cupy-cuda12x
Requirement already satisfied: cupy-cuda12x in c:\users\a.c.ea\documents\github\fpi-research\.venv\lib\site-packages (13.2.0)
Requirement already satisfied: numpy<2.3,>=1.22 in c:\users\a.c.ea\documents\github\fpi-research\.venv\lib\site-packages (from cupy-cuda12x) (1.26.4)
Requirement already satisfied: fastrlock>=0.5 in c:\users\a.c.ea\documents\github\fpi-research\.venv\lib\site-packages (from cupy-cuda12x) (0.8.2)
Aha, okay, that's definitely installed and in the venv. What happens if you do python -c "import cupy"?
One moment...
And if you pip uninstall cupy-cuda110 -y and try again?
One moment...
PS C:\Users\A.C.EA\Documents\GitHub\FPI-Research> pip uninstall cupy-cuda110 -y
Found existing installation: cupy-cuda110 12.3.0
Uninstalling cupy-cuda110-12.3.0:
Successfully uninstalled cupy-cuda110-12.3.0
PS C:\Users\A.C.EA\Documents\GitHub\FPI-Research> python -c "import cupy"
PS C:\Users\A.C.EA\Documents\GitHub\FPI-Research> python -c "import cupy"
PS C:\Users\A.C.EA\Documents\GitHub\FPI-Research>
Nothing?
That looks like it works, then.
It uninstalled the 12.3.0 version.
Probably just a weird version name - you still have the -cuda12x one (it imports, after all).
That's probably a fluke (as in, if you run the file, it should import correctly despite what pylance thinks, since it does when you run it from terminal). Try restarting VSCode, maybe pylance will figure it out.
Hmm, must be that something's not right with the venvs... try python -c "import sys; print([x for x in sys.path if 'site-packages' in x])" in the terminal and import sys; print([x for x in sys.path if 'site-packages' in x]) in your notebook.
['C:\\Users\\A.C.EA\\Documents\\GitHub\\FPI-Research\\.venv\\Lib\\site-packages']```
['C:\\Users\\A.C.EA\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python311\\site-packages', 'C:\\Users\\A.C.EA\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python311\\site-packages\\win32', 'C:\\Users\\A.C.EA\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python311\\site-packages\\win32\\lib', 'C:\\Users\\A.C.EA\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python311\\site-packages\\Pythonwin', 'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\\Lib\\site-packages']
Ah, there we go. Your notebook isn't running in your venv.
For jupyter notebooks the kernel is selected in the top-right corner, make sure it says something like venv (Python 3.11.9)
I'm remaking the venv, I'll see if the issue persists.
Yeah, I thought it was correct.
Maybe not? I think it just said 3.11.9. I didn't pay attention to it not having venv prefix like when I have in WSL remote window.
Still remaking the venv.
I think it's fixed now? I'm gonna try a code from their documentation quick start page.
And now I'm getting
Failed to start the Kernel. Bad file descriptor (C:\Users\runneradmin\AppData\Local\Temp\tmpw8fxpxar\build\_deps\bundled_libzmq-src\src\epoll.cpp:73). View Jupyter log for further details.
Gotta love jupyter sometimes.
That's a fun error (especially the mention of epoll, which is linux-specific). What does the jupyter log (in Output) say?
One moment...
(my first thought is "maybe ipykernel isn't installed?" but that should produce a fancy popup, not just an obscure error)
I'm on windows though, I didn't launch from WSL.
Yup, that's why it's fun.
I'll check.
You and I have different definitions of fun HEHEHE.
It seems it's installed.
How did you remake the venv, by the way?
Umm, like the usual? Just clicked on the version button, Create environment -> venv -> python 3.11.9
This happens quite frequently on windows side.
Much less on WSL side.
And only recently.
I've actually never used vscode's support for this, but this should be fine. (I was hoping you'd say something like "i copypasted the venv from my WSL" and that'd explain why you have weird errors like this, but instead I have no idea).
I am stupid, but fortunately not that stupid.
But truth be told I did do that once in my earlier days *cough HEHEHE.
Like dude, why!?
https://stackoverflow.com/questions/72162637/failed-to-start-the-kernel-cannot-run-jupyter-notebook-in-vs-code-for-windows
Apparently it can be solved by downgrading pyzmq
I was really bad in the beginning.
I think I've seen this.
Apparently this issue also only occurs for specifically the MS Store build of Python: https://github.com/zeromq/pyzmq/issues/1981
(and not for the normal python.org one)
I do believe I installed it properly from python.org, but I could be wrong. Thanks for the reminder!
I have to check that.
No, since your pythonpath says:
'C:\Users\A.C.EA\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages'
Ohh nice.
Yep, again.
Failed to start the Kernel. Bad file descriptor (C:\Users\runneradmin\AppData\Local\Temp\tmpw8fxpxar\build\_deps\bundled_libzmq-src\src\epoll.cpp:73). View Jupyter log for further details.
I'm gonna do it on WSL side.
Sure, you can try that. I think that'd mean installing cuda again this time into WSL, though.
Yeah, hopefully it won't be a new headache.
It wasn't like this before though, I was really fine on Windows.
One day it started happening, and boom, now it's almost perpetual.
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.