Segmentation Fault on 8x8 or larger matrix multiplication with GPU
Description
When running the most recent version of jax and cuda on WSL2, I run into seg faults when doing matrix multiplications beyond 7x7 in both jitted and non jitted use cases. This issue doesn't occur on CPU, so this isn't completely blocking, but it is weird behavior. Seems related to #18663
Example code that produces the issue:
import jax
import jax.numpy as jnp
@jax.jit
def testFunc(test):
return jnp.matmul(test,test)
#No issues
with jax.default_device(jax.devices("cpu")[0]):
test = jnp.zeros((8,8))
print(testFunc(test))
print(jnp.matmul(test,test))
test = jnp.zeros((7,7))
print(testFunc(test)) #No issues
print(jnp.matmul(test,test)) #No issues
test = jnp.zeros((8,8))
print(testFunc(test)) #Seg faults
print(jnp.matmul(test,test)) #Also seg faults
System info (python version, jaxlib version, accelerator, etc.)
jax: 0.4.31
jaxlib: 0.4.31
numpy: 1.26.3
python: 3.12.4 | packaged by conda-forge | (main, Jun 17 2024, 10:23:07) [GCC 12.3.0]
jax.devices (1 total, 1 local): [CudaDevice(id=0)]
process_count: 1
platform: uname_result(system='Linux', node='DESKTOP-VO2OCMO', release='5.15.153.1-microsoft-standard-WSL2', version='#1 SMP Fri Mar 29 23:14:13 UTC 2024', machine='x86_64')
$ nvidia-smi
Fri Aug 30 15:58:58 2024
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 560.35.02 Driver Version: 560.94 CUDA Version: 12.6 |
|-----------------------------------------+------------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+========================+======================|
| 0 NVIDIA GeForce RTX 2060 ... On | 00000000:06:00.0 On | N/A |
| 55% 46C P2 39W / 175W | 1777MiB / 8192MiB | 4% Default |
| | | N/A |
+-----------------------------------------+------------------------+----------------------+
+-----------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=========================================================================================|
| 0 N/A N/A 115 G /Xwayland N/A |
| 0 N/A N/A 3896 C /python3.12 N/A |
+-----------------------------------------------------------------------------------------+
Testing more, I noticed importing tensorflow also gives a segfault. So this could be a broader issue with my machine or cuda set up. Reinforcing this, testing on a shared Ubuntu machine with an older version of cuda (12.2) doesn't reproduce this error. Another possibility is this is something to do with WSL2. I can test on a separate WSL2 later this week.
For the working Ubuntu machine, the system info is:
jax: 0.4.31
jaxlib: 0.4.31
numpy: 1.26.0
python: 3.11.5 (main, Sep 11 2023, 13:54:46) [GCC 11.2.0]
jax.devices (2 total, 2 local): [CudaDevice(id=0) CudaDevice(id=1)]
process_count: 1
platform: uname_result(system='Linux', node='lambda-Lambda-Vector', release='6.5.0-41-generic', version='#41~22.04.2-Ubuntu SMP PREEMPT_DYNAMIC Mon Jun 3 11:32:55 UTC 2', machine='x86_64')
$ nvidia-smi
Mon Sep 2 13:11:13 2024
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.113.01 Driver Version: 535.113.01 CUDA Version: 12.2 |
|-----------------------------------------+----------------------+----------------------+
| GPU Name Persistence-M | Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap | Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|=========================================+======================+======================|
| 0 NVIDIA RTX 6000 Ada Gene... On | 00000000:41:00.0 Off | Off |
| 30% 45C P2 25W / 300W | 555MiB / 49140MiB | 1% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
| 1 NVIDIA RTX 6000 Ada Gene... On | 00000000:61:00.0 Off | Off |
| 30% 39C P2 26W / 300W | 447MiB / 49140MiB | 1% Default |
| | | N/A |
+-----------------------------------------+----------------------+----------------------+
+---------------------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=======================================================================================|
| 0 N/A N/A 1549399 C python 426MiB |
| 0 N/A N/A 1904799 G /usr/lib/xorg/Xorg 88MiB |
| 0 N/A N/A 1905086 G /usr/bin/gnome-shell 20MiB |
| 1 N/A N/A 1549399 C python 426MiB |
| 1 N/A N/A 1904799 G /usr/lib/xorg/Xorg 4MiB |
+---------------------------------------------------------------------------------------+
Hi @treyra,
I have tested the provided minimal repro code on WSL2 having a single NVIDIA RTX 2060 GPU with JAX 0.4.31. I could not reproduce the mentioned issue. The repro code executes without any error. Please find the below screenshots for reference:
I have also tested this on WSL2 having NVIDIA RTX A5000 GPU with JAX 0.4.31 andd it executed without any error.
Could you please verify the issue once again by reinstalling JAX in a different environment, if it still exists?
Thank you.
Thank you for testing this. I installed JAX in wsl on a different machine and didn't produce the error, so this may be some other issue with my cuda install or a different package, perhaps tensor flow. We can close this for now since it seems like a local issue, and I'll probably reset my environments for a clean install.
I ran into this issue too, sadly not sure what local issue is causing this.