Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: port scipy.stats.kstat #8305

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation



class TestKstat:
def test_moments_normal_distribution(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a helper decorator cupy.testing.for_all_dtypes to make a parametrized test across dtypes. Would you use it to check with other dtypes?

4*N*(N+1)*S[1]*S[3] + N*N*(N+1)*S[4]) /
(N*(N-1.0)*(N-2.0)*(N-3.0)))
else:
raise ValueError("Should not be here.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: the same message as scipy

@takagi
Copy link
Member

takagi commented Apr 24, 2024

/test mini

@Pranavchiku
Copy link
Author

Pranavchiku commented Apr 24, 2024

When I tried to test this on gpu it gave:
cc @takagi

$ python3 -m pytest tests/cupyx_tests/scipy_tests/stats_tests/test_stats.py 
=================================================== test session starts ===================================================
platform linux -- Python 3.8.10, pytest-8.1.1, pluggy-1.5.0
rootdir: /home/pranav/repos/cupy
configfile: setup.cfg
collected 0 items / 1 error                                                                                               

========================================================= ERRORS ==========================================================
________________________ ERROR collecting tests/cupyx_tests/scipy_tests/stats_tests/test_stats.py _________________________
ImportError while importing test module '/home/pranav/repos/cupy/tests/cupyx_tests/scipy_tests/stats_tests/test_stats.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
cupy/__init__.py:17: in <module>
    from cupy import _core  # NOQA
cupy/_core/__init__.py:3: in <module>
    from cupy._core import core  # NOQA
E   ImportError: cannot import name 'core' from partially initialized module 'cupy._core' (most likely due to a circular import) (/home/pranav/repos/cupy/cupy/_core/__init__.py)

The above exception was the direct cause of the following exception:
/usr/lib/python3.8/importlib/__init__.py:127: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
tests/cupyx_tests/scipy_tests/stats_tests/test_stats.py:4: in <module>
    import cupy
cupy/__init__.py:19: in <module>
    raise ImportError(f'''
E   ImportError: 
E   ================================================================
E   Failed to import CuPy.
E   
E   If you installed CuPy via wheels (cupy-cudaXXX or cupy-rocm-X-X), make sure that the package matches with the version of CUDA or ROCm installed.
E   
E   On Linux, you may need to set LD_LIBRARY_PATH environment variable depending on how you installed CUDA/ROCm.
E   On Windows, try setting CUDA_PATH environment variable.
E   
E   Check the Installation Guide for details:
E     https://docs.cupy.dev/en/latest/install.html
E   
E   Original error:
E     ImportError: cannot import name 'core' from partially initialized module 'cupy._core' (most likely due to a circular import) (/home/pranav/repos/cupy/cupy/_core/__init__.py)
E   ================================================================
================================================= short test summary info =================================================
ERROR tests/cupyx_tests/scipy_tests/stats_tests/test_stats.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
==================================================== 1 error in 0.26s ==================================================

@takagi
Copy link
Member

takagi commented Apr 25, 2024

I usually see such an error when I checked out another branch, building cupy there, and going back to the original branch. Would you try to build cupy on your local again?

Would you try to build cupy on your environment again?

$ pip install -e .

@Pranavchiku
Copy link
Author

I have remote access to gpu, which I connect via ssh
It throws me:

$ pip3 install -e .
Obtaining file:///home/pranav/repos/cupy
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/pranav/repos/cupy/setup.py'"'"'; __file__='"'"'/home/pranav/repos/cupy/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info
         cwd: /home/pranav/repos/cupy/
    Complete output (8 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/pranav/repos/cupy/setup.py", line 14, in <module>
        ctx = cupy_builder.Context(source_root)
      File "/home/pranav/repos/cupy/install/cupy_builder/_context.py", line 66, in __init__
        hasher = hashlib.sha1(usedforsecurity=False)
    TypeError: 'usedforsecurity' is an invalid keyword argument for openssl_sha1()
    Generating cache key from header files...
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

@takagi
Copy link
Member

takagi commented Apr 25, 2024

Which python version are you using?

@Pranavchiku
Copy link
Author

$ python --version
Python 2.7.18

@takagi
Copy link
Member

takagi commented Apr 25, 2024

CuPy runs on python 3.9 or higher. Would you install newer Python 3 using pyenv, then try to build CuPy on it?

@Pranavchiku
Copy link
Author

I created a conda environment, installed python 3.12, and executed:

$ pip install -e .
Obtaining file:///home/pranav/repos/cupy
  Preparing metadata (setup.py) ... done
Collecting numpy<1.29,>=1.22 (from cupy==13.0.0rc1)
  Downloading numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.0/61.0 kB 447.7 kB/s eta 0:00:00
Collecting fastrlock>=0.5 (from cupy==13.0.0rc1)
  Using cached fastrlock-0.8.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl.metadata (9.3 kB)
Using cached fastrlock-0.8.2-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_28_x86_64.whl (52 kB)
Downloading numpy-1.26.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.0 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 18.0/18.0 MB 21.7 MB/s eta 0:00:00
Installing collected packages: fastrlock, numpy, cupy
  Running setup.py develop for cupy


....

@Pranavchiku
Copy link
Author

Is it expected to take long time?

@takagi
Copy link
Member

takagi commented Apr 25, 2024

Yes. I suppose it has finished as it is one hour after your last comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants