jax icon indicating copy to clipboard operation
jax copied to clipboard

Anything using cuSolver fails jax version 0.2.5, jaxlib version 0.1.56 CUDA 10.1

Open vkramanuj opened this issue 6 years ago • 9 comments

I'm running into a bug which is preventing me from using the GPU for anything which relies on cuSolver. In particular, the following minimal example produces the error.

>> import jax.numpy as jnp
>> A = jnp.array([[0, 1], [1, 1], [1, 1], [2, 1]])
>> q, r = jnp.linalg.qr(A)

or

>> import jax.numpy as jnp
>> import jax.scipy as jsp
>> A = A = jnp.array([[9, 3, 1, 5], [3, 7, 5, 1], [1, 5, 9, 2], [5, 1, 2, 6]])
>> c, low = jsp.linalg.cho_factor(A)

The error in question is RuntimeError: cuSolver has not been initialized

I have checked that libcusolver.so is in /usr/local/cuda/lib64 and the LD library path is pointing to this file.

Relevant software versions: tensorflow-gpu 2.3.1 jax 0.2.5 jaxlib 0.1.56+101 CUDA driver 418.87.00

Any help would be greatly appreciated! This is a very blocking bug for me.

vkramanuj avatar Oct 22 '20 06:10 vkramanuj

@hawkinsp or @skye does this look familiar to you?

mattjj avatar Oct 22 '20 06:10 mattjj

Possibly related to #4677?

jakevdp avatar Oct 22 '20 16:10 jakevdp

I'm not able to repro this with jax 0.2.4 and jaxlib 0.1.56+cuda101. @vkramanuj are you sure about the versions? jax 0.2.5 hasn't been released yet, do you mean you're running from github HEAD?

EDIT: I also tried running at current github HEAD and couldn't repro.

Can you also set the env var TF_CPP_MIN_LOG_LEVEL=0, rerun the failing commands, and share the full output? Maybe we can find some more clues.

skye avatar Oct 26 '20 18:10 skye

My apologies, I meant jax 0.2.4. Let me reinstall and try again.

vkramanuj avatar Oct 28 '20 18:10 vkramanuj

Closing because there was no response. Please reopen if this is still a problem!

hawkinsp avatar Dec 02 '20 17:12 hawkinsp

hi @vkramanuj, did you resolve this problem? Could you please share how you resolved it? I run into the same problem and could not find any other discussion rather than this thread.

thanhnguyentang avatar Aug 02 '21 17:08 thanhnguyentang

What I have observed in my case is the cuSolver runtime error shows up for the first run in my notebook, but if I simply ignore it and rerun that code part (without restarting the notebook kernel), it will proceed without the error.

If not in a notebook, I put the following code block in the beginning of my program:

os.environ['TF_FORCE_UNIFIED_MEMORY'] = '1'
try:
    jnp.linalg.qr(jnp.array([[0, 1], [1, 1]]))
except RuntimeError:
    pass 

p/s1: The idea of setting TF_FORCE_UNIFIED_MEMORY comes from issue #4497 and the try-except block is by my above observation. Lacking any of these two parts retains the cuSolver runtime error in my case.

p/s2: It would be nice if someone could explain my above observation :)

thanhnguyentang avatar Aug 02 '21 23:08 thanhnguyentang

has it been solved?

shanshanhao avatar Dec 09 '21 06:12 shanshanhao

My suspicion is that this may be related to JAX grabbing too much GPU memory. https://jax.readthedocs.io/en/latest/gpu_memory_allocation.html

Try XLA_PYTHON_CLIENT_MEM_FRACTION=.8. Does it help?

What GPU do you have and how much GPU RAM does it have?

hawkinsp avatar Dec 09 '21 14:12 hawkinsp