Skip to content

Issues with cupy dependencies - cut a release #83

@ncclementi

Description

@ncclementi

In the current version of cupy-xarray, there is a dependency on cupy.

SInce cupy 14, we can now install cupy as a wheel that will bring a ctk as "cupy-cuda12x[ctk]" which is very helpful for envs taht do not have a system cuda-toolkit.

However, when I tried to install via uv pip "cupy-cuda12x[ctk]" and then cupy-xarray I get this error that you can reproduce with a pyroject.toml like

  [project]                                                                                                           
  name = "xarray-uv-example"                                                                                          
  version = "0.1.0"                                                                                                   
  requires-python = "==3.13.*"                                                                                        
  dependencies = [                                                                                                    
      "xarray",                                                                                                   
      "netCDF4",                                                                                                  
      "bottleneck",                                                                                               
      "numpy",                                                                                                    
      "cupy-cuda12x[ctk]",                                                                                        
      "cupy-xarray",                                                                                              
      "jupyterlab-nvdashboard",                                                                                   
      "ipykernel",                                                                                                
                                                                                                                  
  ]                                                                                                                                                                                  

and doing uv sync

  Using CPython 3.13.12                                                                                           
  Removed virtual environment at: .venv                                                                           
  Creating virtual environment at: .venv                                                                          
  Resolved 117 packages in 715ms                                                                                  
    × Failed to build `cupy==14.0.1`                                                                              
    ├─▶ The build backend returned an error                                                                       
    ╰─▶ Call to `setuptools.build_meta.build_wheel` failed (exit status: 1)                                       
                                                                                                                  
        [stdout]                                                                                                  
        Generating CUPY_CACHE_KEY from header files...                                                            
        CUPY_CACHE_KEY (2006 files matching                                                                       
  /ephemeral/cache/uv/sdists-v9/pypi/cupy/14.0.1/Vn6dXZBXUzYnKgja7Fe3-/src/cupy/_core/include/**):                
        bb0abd009e32cb3266dc9bbd435ee72bc24f9575                                                                  
                                                                                                                  
        -------- Configuring Module: cuda --------                                                                
        command '/usr/bin/c++' failed with exit code 1                                                            
        **************************************************                                                        
        *** WARNING: Cannot check compute capability                                                              
        command '/usr/bin/c++' failed with exit code 1                                                            
        **************************************************                                                        
                                                                                                                  
        ************************************************************                                              
        * CuPy Configuration Summary                               *                                              
        ************************************************************                                              
                                                                                                                  
        Build Environment:                                                                                        
          Include directories: ['/ephemeral/cache/uv/sdists-v9/pypi/cupy/14.0.1/Vn6dXZBXUzYnKgja7Fe3-/src/cupy/_c 
  ore/include/cupy/_cccl/libcudacxx',                                                                             
        '/ephemeral/cache/uv/sdists-v9/pypi/cupy/14.0.1/Vn6dXZBXUzYnKgja7Fe3-/src/cupy/_core/include/cupy/_cccl/t 
  hrust',                                                                                                         
                                                                                                                  
  '/ephemeral/cache/uv/sdists-v9/pypi/cupy/14.0.1/Vn6dXZBXUzYnKgja7Fe3-/src/cupy/_core/include/cupy/_cccl/cub',   
        '/ephemeral/cache/uv/sdists-v9/pypi/cupy/14.0.1/Vn6dXZBXUzYnKgja7Fe3-/src/cupy/_core/include',            
        '/home/ubuntu/.cache/uv/builds-v0/.tmp1RF3D8/lib/python3.13/site-packages/numpy/_core/include']           
          Library directories: []                                                                                 
          nvcc command       : (not found)                                                                        
          hipcc command      : (not found)                                                                        
                                                                                                                  
        Environment Variables:                                                                                    
          CFLAGS          : (none)                                                                                
          LDFLAGS         : (none)                                                                                
          LIBRARY_PATH    : (none)                                                                                
          CUDA_PATH       : (none)                                                                                
          NVCC            : (none)                                                                                
          HIPCC           : (none)                                                                                
          ROCM_HOME       : (none)                                                                                
                                                                                                                  
        Modules:                                                                                                  
          cuda      : No                                                                                          
            -> Include files not found: ['cublas_v2.h', 'cuda.h', 'cuda_profiler_api.h', 'cuda_runtime.h',        
  'cufft.h', 'curand.h', 'cusparse.h']                                                                            
            -> Check your CFLAGS environment variable.                                                            
                                                                                                                  
        ERROR: CUDA could not be found on your system.                                                            
                                                                                                                  
        HINT: You are trying to build CuPy from source, which is NOT recommended for general use.                 
              Please consider using binary packages instead.                                                      
                                                                                                                  
        Please refer to the Installation Guide for details:                                                       
        https://docs.cupy.dev/en/stable/install.html                                                              
                                                                                                                  
        ************************************************************                                              
                                                                                                                  
                                                                                                                  
        [stderr]                                                                                                  
        /tmp/tmpv5_2378z/a.cpp:1:10: fatal error: cublas_v2.h: No such file or directory                          
            1 | #include <cublas_v2.h>                                                                            
              |          ^~~~~~~~~~~~~                                                                            
        compilation terminated.                                                                                   
        /tmp/tmph5zfrr4x/a.cpp:2:18: fatal error: cuda_runtime_api.h: No such file or directory                   
            2 |         #include <cuda_runtime_api.h>                                                             
              |                  ^~~~~~~~~~~~~~~~~~~~                                                             
        compilation terminated.                                                                                   
        Traceback (most recent call last):                                                                        
          File "<string>", line 14, in <module>                                                                   
            requires = get_requires_for_build({})                                                                 
          File                                                                                                    
  "/home/ubuntu/.cache/uv/builds-v0/.tmp1RF3D8/lib/python3.13/site-packages/setuptools/build_meta.py", line 333,  
  in get_requires_for_build_wheel                                                                                 
            return self._get_build_requires(config_settings, requirements=[])                                     
                   ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                     
          File                                                                                                    
  "/home/ubuntu/.cache/uv/builds-v0/.tmp1RF3D8/lib/python3.13/site-packages/setuptools/build_meta.py", line 301,  
  in _get_build_requires                                                                                          
            self.run_setup()                                                                                      
            ~~~~~~~~~~~~~~^^                                                                                      
          File                                                                                                    
  "/home/ubuntu/.cache/uv/builds-v0/.tmp1RF3D8/lib/python3.13/site-packages/setuptools/build_meta.py", line 317,  
  in run_setup                                                                                                    
            exec(code, locals())                                                                                  
            ~~~~^^^^^^^^^^^^^^^^                                                                                  
          File "<string>", line 56, in <module>                                                                   
          File "/ephemeral/cache/uv/sdists-v9/pypi/cupy/14.0.1/Vn6dXZBXUzYnKgja7Fe3-/src/install/cupy_builder/cup 
  y_setup_build.py", line 560, in get_ext_modules                                                                 
            extensions = make_extensions(ctx, compiler, use_cython)                                               
          File "/ephemeral/cache/uv/sdists-v9/pypi/cupy/14.0.1/Vn6dXZBXUzYnKgja7Fe3-/src/install/cupy_builder/cup 
  y_setup_build.py", line 412, in make_extensions                                                                 
            raise Exception('Your CUDA environment is invalid. '                                                  
                            'Please check above error log.')                                                      
        Exception: Your CUDA environment is invalid. Please check above error log.                                
                                                                                                                  
        hint: This usually indicates a problem with the package or the build environment.                         
    help: `cupy` (v14.0.1) was included because `xarray-uv-example` (v0.1.0) depends on `cupy-xarray` (v0.1.4)    
  which depends on `cupy`                                              

I think it's because uv has no way of knowing that cupy-cuda12x already satisfies the cupy import.

I noticed that currently on main, there is no cupy dependency, this was removed on this commit 3f84de0

Which is months after the later release. I tried installing from main, and this seem to work. So this would probably solve with a release cut.

NOTE:

  • I wonder if cupy should be made a dependency again, given that you can't use it without cupy.
  • Not sure how, but if there is a way to make sure that when installed with pip it depends on "cupy-cuda12x[ctk]" or "cupy-cuda13x[ctk]" depending on the cuda version. This will bring a ctk, similarly on how it happens in conda

cc: @jacobtomlinson @jayavenkatesh19

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions