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

Let user decide which cupy version to use #67

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Interface for using cupy in xarray, providing convenience accessors.

## Installation

> `cupy-xarray` will use an existing cupy installation, hence cupy needs to be installed manually! Please follow cupy's install instructions at <https://docs.cupy.dev/en/stable/install.html> or use the extras install

From anaconda:

```console
Expand All @@ -34,6 +36,14 @@ The latest version from Github:
pip install git+https://github.com/xarray-contrib/cupy-xarray.git
```

Install cupy with extras:

```console
pip install cupy-xarray["source"] # will install the cupy package, which will build cupy from source
pip install cupy-xarray["cuda11"] # will install the prebuild cupy-cuda11x package
pip install cupy-xarray["cuda12"] # will install the prebuild cupy-cuda12x package
```

## Usage

```python
Expand Down
14 changes: 13 additions & 1 deletion cupy_xarray/accessors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import warnings
from typing import TYPE_CHECKING, Any

import cupy as cp
try:
import cupy as cp
except ImportError as e:
warnings.warn(
"Cupy is not installed. cupy-xarray expects cupy to be manually installed. Please install "
"cupy either by following the instructions at https://docs.cupy.dev/en/stable/install.html "
"or by isntalling cupy-xaray with extras, e.g. `pip install cupy-xarray['source']`. More "
"information can be found in the Readme or at the cupy-xarray documentation.",
ImportWarning,
stacklevel=2,
)
raise e
from xarray import (
DataArray,
Dataset,
Expand Down
10 changes: 10 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ CuPy-Xarray is a Python library that leverages [CuPy](https://cupy.dev/), a GPU

## Installation

> `cupy-xarray` will use an existing cupy installation, hence cupy needs to be installed manually! Please follow cupy's install instructions at <https://docs.cupy.dev/en/stable/install.html> or use the extras install

CuPy-Xarray can be installed using `pip` or `conda`:

From Conda Forge:
Expand All @@ -37,6 +39,14 @@ The latest version from Github:
pip install git+https://github.com/xarray-contrib/cupy-xarray.git
```

Install cupy with extras:

```console
pip install cupy-xarray["source"] # will install the cupy package, which will build cupy from source
pip install cupy-xarray["cuda11"] # will install the prebuild cupy-cuda11x package
pip install cupy-xarray["cuda12"] # will install the prebuild cupy-cuda12x package
```

## Acknowledgements

Large parts of this documentations comes from [SciPy 2023 Xarray on GPUs tutorial](https://negin513.github.io/cupy-xarray-tutorials/README.html) and [this NCAR tutorial to GPUs](https://github.com/NCAR/GPU_workshop/tree/workshop/13_CuPyAndLegate).
Expand Down
11 changes: 10 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ classifiers = [
]
dynamic = ["version"]
dependencies = [
"cupy",
"xarray>=2024.02.0",
]

Expand All @@ -24,6 +23,16 @@ test = [
"dask",
"pytest",
]
source = [
"cupy"
]
cuda12 = [
"cupy-cuda12x",
]
cuda11 = [
"cupy-cuda11x",
]


[tool.ruff]
line-length = 100 # E501 (line-too-long)
Expand Down
Loading