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

Adds an option to select device ID when using CUDA #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all 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
2 changes: 2 additions & 0 deletions map_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def main():
parser.add_argument('--encoding', default='utf-8', help='the character encoding for input/output (defaults to utf-8)')
parser.add_argument('--precision', choices=['fp16', 'fp32', 'fp64'], default='fp32', help='the floating-point precision (defaults to fp32)')
parser.add_argument('--cuda', action='store_true', help='use cuda (requires cupy)')
parser.add_argument('--device_id', default=0, type=int, help='device ID used for the --cuda option (defaults to 0)')
parser.add_argument('--batch_size', default=10000, type=int, help='batch size (defaults to 10000); does not affect results, larger is usually faster but uses more memory')
parser.add_argument('--seed', type=int, default=0, help='the random seed (defaults to 0)')

Expand Down Expand Up @@ -153,6 +154,7 @@ def main():
print('ERROR: Install CuPy for CUDA support', file=sys.stderr)
sys.exit(-1)
xp = get_cupy()
xp.cuda.Device(args.device_id).use()
x = xp.asarray(x)
z = xp.asarray(z)
else:
Expand Down