From a6b2e1f59d1bddcd2e37b517ceabf4970892685d Mon Sep 17 00:00:00 2001 From: Yuekai Zhang Date: Tue, 19 Dec 2023 01:24:40 +0800 Subject: [PATCH] Fix numpy.int error (#41) --- README.md | 10 +++++----- gss/bin/modes/utils.py | 9 +++++---- gss/cacgmm/utils.py | 4 +++- gss/core/stft_module.py | 2 +- gss/utils/numpy_utils.py | 4 ++-- gss/wpe/wpe.py | 2 +- recipes/chime6/env.sh | 2 +- 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 81e6b7f..beb41b6 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ conda create -n gss python=3.8 ``` Install CuPy as follows (see https://docs.cupy.dev/en/stable/install.html for the appropriate version -for your CUDA). +for your CUDA). ```bash pip install cupy-cuda102 @@ -153,15 +153,15 @@ using Snakeviz. * `--force-overwrite`: Flag to force enhanced audio files to be overwritten. ### Multi-GPU Usage -You can refer to e.g. the [AMI recipe](./recipes/ami/run.sh) for how to use this toolkit +You can refer to e.g. the [AMI recipe](./recipes/ami/run.sh) for how to use this toolkit with multiple GPUs.
-**NOTE**: your GPUs must be in Exclusive_Thread mode, otherwise this library may not work as expected and/or the inference +**NOTE**: your GPUs must be in Exclusive_Thread mode, otherwise this library may not work as expected and/or the inference time will greatly increase. **This is especially important if you are using** `run.pl`.
You can check the compute mode of GPU `X` using: ```bash nvidia-smi -i X -q | grep "Compute Mode" ``` -We also provide an automate tool to do that called `gpu_check` which takes as arguments the cmd used (e.g. run.pl) and number of jobs: +We also provide an automate tool to do that called `gpu_check` which takes as arguments the cmd used (e.g. run.pl) and number of jobs: ```bash $cmd JOB=1:$nj ${exp_dir}/${dset_name}/${dset_part}/log/enhance.JOB.log \ gss utils gpu_check $nj $cmd \& gss enhance cuts \ @@ -173,7 +173,7 @@ We also provide an automate tool to do that called `gpu_check` which takes as ar --max-batch-duration 120 \ ${affix} || exit 1 ``` -See again [AMI recipe](./recipes/ami/run.sh) or the [CHiME-7 DASR GSS code](https://github.com/espnet/espnet/blob/master/egs2/chime7_task1/asr1/local/run_gss.sh). +See again [AMI recipe](./recipes/ami/run.sh) or the [CHiME-7 DASR GSS code](https://github.com/espnet/espnet/blob/master/egs2/chime7_task1/asr1/local/run_gss.sh). ## FAQ **What happens if I set the `--max-batch-duration` too large?** diff --git a/gss/bin/modes/utils.py b/gss/bin/modes/utils.py index 028731e..659e4ca 100644 --- a/gss/bin/modes/utils.py +++ b/gss/bin/modes/utils.py @@ -1,11 +1,12 @@ +import logging +import os +import re +import subprocess from pathlib import Path import click -import subprocess -import os -import re + from gss.bin.modes.cli_base import cli -import logging logging.basicConfig( format="%(asctime)s,%(msecs)d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s", diff --git a/gss/cacgmm/utils.py b/gss/cacgmm/utils.py index e8bf5bd..6dba3f9 100644 --- a/gss/cacgmm/utils.py +++ b/gss/cacgmm/utils.py @@ -71,7 +71,9 @@ def log_pdf_to_affiliation( affiliation *= weight if source_activity_mask is not None: - assert source_activity_mask.dtype == cp.bool_, source_activity_mask.dtype # noqa + assert ( + source_activity_mask.dtype == cp.bool_ + ), source_activity_mask.dtype # noqa affiliation *= source_activity_mask denominator = cp.maximum( diff --git a/gss/core/stft_module.py b/gss/core/stft_module.py index 2be4665..5dfc1d9 100644 --- a/gss/core/stft_module.py +++ b/gss/core/stft_module.py @@ -45,7 +45,7 @@ def stft( # Pad with zeros to have enough samples for the window function to fade. assert fading in [None, True, False, "full", "half"], fading if fading not in [False, None]: - pad_width = np.zeros([ndim, 2], dtype=np.int) + pad_width = np.zeros([ndim, 2], dtype=int) if fading == "half": pad_width[axis, 0] = (window_length - shift) // 2 pad_width[axis, 1] = ceil((window_length - shift) / 2) diff --git a/gss/utils/numpy_utils.py b/gss/utils/numpy_utils.py index c244f30..f4b1923 100644 --- a/gss/utils/numpy_utils.py +++ b/gss/utils/numpy_utils.py @@ -67,13 +67,13 @@ def segment_axis( npad[axis, 1] = length - x.shape[axis] x = xp.pad(x, pad_width=npad, mode=pad_mode, **pad_kwargs) elif shift != 1 and (x.shape[axis] + shift - length) % shift != 0: - npad = np.zeros([x.ndim, 2], dtype=np.int) + npad = np.zeros([x.ndim, 2], dtype=int) npad[axis, 1] = shift - ((x.shape[axis] + shift - length) % shift) x = xp.pad(x, pad_width=npad, mode=pad_mode, **pad_kwargs) elif end == "conv_pad": assert shift == 1, shift - npad = np.zeros([x.ndim, 2], dtype=np.int) + npad = np.zeros([x.ndim, 2], dtype=int) npad[axis, :] = length - shift x = xp.pad(x, pad_width=npad, mode=pad_mode, **pad_kwargs) elif end is None: diff --git a/gss/wpe/wpe.py b/gss/wpe/wpe.py index 2925c48..dc300e9 100644 --- a/gss/wpe/wpe.py +++ b/gss/wpe/wpe.py @@ -45,7 +45,7 @@ def build_y_tilde(Y, taps, delay): T = Y.shape[-1] def pad(x, axis=-1, pad_width=taps + delay - 1): - npad = np.zeros([x.ndim, 2], dtype=np.int) + npad = np.zeros([x.ndim, 2], dtype=int) npad[axis, 0] = pad_width x = cp.pad(x, pad_width=npad, mode="constant", constant_values=0) return x diff --git a/recipes/chime6/env.sh b/recipes/chime6/env.sh index bbba092..f704702 100644 --- a/recipes/chime6/env.sh +++ b/recipes/chime6/env.sh @@ -7,4 +7,4 @@ module use /home/hltcoe/draj/modulefiles || exit 1 module load cuda || exit 1 # loads CUDA 10.2 module load cudnn || exit 1 # loads cuDNN 8.0.2 module load intel/mkl/64/2019/5.281 || exit 1 -module load nccl || exit 1 \ No newline at end of file +module load nccl || exit 1