Skip to content

Commit

Permalink
Adding packages to the environment, adding exceptions for imports
Browse files Browse the repository at this point in the history
  • Loading branch information
jordancaraballo committed Dec 15, 2021
1 parent feb2c25 commit b559caf
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
12 changes: 8 additions & 4 deletions examples/rasters/wv_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
from terragpu import engine
from terragpu.array.raster import Raster
from terragpu.indices.wv_indices import add_indices
from terragpu.engine import array_module, df_module

xp = array_module()
xf = df_module()

def main(filename, bands):

Expand Down Expand Up @@ -38,10 +41,11 @@ def main(filename, bands):
]

# Start dask cluster - dask scheduler must be started from main
engine.configure_dask(
device='gpu',
n_workers=4,
local_directory='/lscratch/jacaraba')
if xp.__name__ == 'cupy':
engine.configure_dask(
device='gpu',
n_workers=4,
local_directory='/lscratch/jacaraba')

# Execute main function and calculate indices
main(filename, bands)
1 change: 1 addition & 0 deletions requirements/environment_cpu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ dependencies:
- pdoc3
- flake8
- coverage
- numba
3 changes: 2 additions & 1 deletion requirements/environment_gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ dependencies:
- tqdm
- pdoc3
- flake8
- coverage
- coverage
- numba
10 changes: 8 additions & 2 deletions terragpu/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
import pandas as pd
import xarray as xr
from types import ModuleType
from dask_cuda import LocalCUDACluster
from dask.distributed import Client, LocalCluster

try:
from dask_cuda import LocalCUDACluster
from dask.distributed import Client, LocalCluster
HAS_GPU = True
except ModuleNotFoundError:
logging.info("Not importing Dask CUDA libraries")
HAS_GPU = False

_warn_array_module_once = False
_warn_df_module_once = False
Expand Down

0 comments on commit b559caf

Please sign in to comment.