This repository has been archived by the owner on Dec 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into vision
- Loading branch information
Showing
62 changed files
with
1,380 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Issues Bot | ||
|
||
on: | ||
# Uncomment this PR trigger for testing. | ||
# pull_request: | ||
# branches: | ||
# - master | ||
schedule: | ||
- cron: '5 16 * * 1,2,3,4,5' # runs at 16:05 UTC Monday - Friday | ||
|
||
jobs: | ||
close_stale_issues: | ||
name: Close Stale Issues | ||
if: github.repository == 'allenai/allennlp' | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.7 | ||
|
||
- name: Install requirements | ||
run: | | ||
pip install PyGithub | ||
- name: Close stale issues | ||
run: | | ||
python scripts/close_stale_issues.py | ||
ping_assignees: | ||
name: Ping Inactive Assignees | ||
if: github.repository == 'allenai/allennlp' | ||
runs-on: ubuntu-latest | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Setup Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.7 | ||
|
||
- name: Install requirements | ||
run: | | ||
pip install PyGithub | ||
- name: Ping inactive assignees | ||
run: | | ||
python scripts/ping_issue_assignees.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import datetime | ||
from typing import List, Dict, Any, Tuple, Callable | ||
import torch | ||
import torch.distributed as dist | ||
import torch.multiprocessing as mp | ||
|
||
from allennlp.common.checks import check_for_gpu | ||
|
||
|
||
def init_process( | ||
process_rank: int, | ||
distributed_device_ids: List[int] = None, | ||
world_size: int = 1, | ||
func: Callable = None, | ||
func_args: Tuple = None, | ||
func_kwargs: Dict[str, Any] = None, | ||
master_addr: str = "127.0.0.1", | ||
master_port: int = 29500, | ||
): | ||
assert world_size > 1 | ||
|
||
global_rank = process_rank | ||
|
||
gpu_id = distributed_device_ids[process_rank] # type: ignore | ||
|
||
if gpu_id >= 0: | ||
torch.cuda.set_device(int(gpu_id)) | ||
dist.init_process_group( | ||
backend="nccl", | ||
init_method=f"tcp://{master_addr}:{master_port}", | ||
world_size=world_size, | ||
rank=global_rank, | ||
) | ||
else: | ||
dist.init_process_group( | ||
backend="gloo", | ||
init_method=f"tcp://{master_addr}:{master_port}", | ||
world_size=world_size, | ||
rank=global_rank, | ||
timeout=datetime.timedelta(seconds=120), | ||
) | ||
|
||
func(global_rank, world_size, gpu_id, *func_args, **func_kwargs) | ||
|
||
dist.barrier() | ||
|
||
|
||
def run_distributed_test( | ||
device_ids: List[int] = [-1, -1], func: Callable = None, *args, **kwargs, | ||
): | ||
""" | ||
This runs the `func` in a simulated distributed environment. | ||
# Parameters | ||
device_ids: `List[int]` | ||
List of devices. There need to be at least 2 devices. Default is [-1, -1]. | ||
func: `Callable` | ||
`func` needs to be global for spawning the processes, so that it can be pickled. | ||
""" | ||
|
||
check_for_gpu(device_ids) | ||
nprocs = world_size = len(device_ids) | ||
mp.start_processes( | ||
init_process, | ||
args=(device_ids, world_size, func, args, kwargs), | ||
nprocs=nprocs, | ||
start_method="fork", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.