#๐Ÿ”’ Having trouble installing cupy

92 messages ยท Page 1 of 1 (latest)

brittle latchBOT
#

@reef snow

Python help channel opened

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.

reef snow
#

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.

wet hound
reef snow
wet hound
#

pip install cupy-cuda12x
Yeah, that sounds right.

reef snow
#

It's just not seeing the folder apparently.

wet hound
#

still can't import cupy
What do you mean by can't import?

reef snow
#

aka the package is not installed.

wet hound
#

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.

reef snow
#

If you have an NVIDIA GPU you can try it and see if the error is present on your side as well.

reef snow
wet hound
#

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?

reef snow
#

When I try to install it with pip install cupy it gives the error I sent above.

reef snow
#

It even shows a pop up saying the venv is opened in terminal.

wet hound
#

You see (venv) in your terminal prompt?

reef snow
#

I take this as activated.

wet hound
#

Hmm, alright. What does pip install cupy-cuda12x output?

reef snow
#

I see venv only when I use WSL, never seen it explicitly on Windows.

reef snow
#
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)
wet hound
#

Aha, okay, that's definitely installed and in the venv. What happens if you do python -c "import cupy"?

wet hound
#

And if you pip uninstall cupy-cuda110 -y and try again?

reef snow
#
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?

wet hound
#

That looks like it works, then.

reef snow
#

It uninstalled the 12.3.0 version.

wet hound
reef snow
#

Still the same.

wet hound
#

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.

reef snow
#

One moment...

#

Restarted vs code, and ran the cell.

wet hound
#

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.

reef snow
#
['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']
wet hound
#

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)

reef snow
#

I'm remaking the venv, I'll see if the issue persists.

reef snow
#

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.

wet hound
#

That's a fun error (especially the mention of epoll, which is linux-specific). What does the jupyter log (in Output) say?

wet hound
#

(my first thought is "maybe ipykernel isn't installed?" but that should produce a fancy popup, not just an obscure error)

reef snow
wet hound
#

Yup, that's why it's fun.

reef snow
#

You and I have different definitions of fun HEHEHE.

#

It seems it's installed.

wet hound
#

How did you remake the venv, by the way?

reef snow
#

This happens quite frequently on windows side.

#

Much less on WSL side.

#

And only recently.

wet hound
#

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).

reef snow
#

But truth be told I did do that once in my earlier days *cough HEHEHE.

#

Like dude, why!?

wet hound
reef snow
#

I was really bad in the beginning.

wet hound
reef snow
#

I have to check that.

wet hound
reef snow
#

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.

wet hound
#

Sure, you can try that. I think that'd mean installing cuda again this time into WSL, though.

reef snow
#

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.

brittle latchBOT
#
Python help channel closed

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.