forked from deepmodeling/deepmd-kit
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from amcadmus/api
api update from amcadmus
- Loading branch information
Showing
307 changed files
with
231,326 additions
and
10,003 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,30 @@ | ||
on: | ||
push: | ||
pull_request: | ||
name: Build C++ | ||
jobs: | ||
testpython: | ||
name: Build C++ | ||
runs-on: ubuntu-20.04 | ||
strategy: | ||
matrix: | ||
include: | ||
- float_prec: high | ||
variant: cpu | ||
- float_prec: low | ||
variant: cpu | ||
- float_prec: high | ||
variant: gpu | ||
- float_prec: low | ||
variant: gpu | ||
steps: | ||
- uses: actions/checkout@master | ||
with: | ||
submodules: true | ||
- run: sudo apt update && sudo apt install nvidia-cuda-toolkit | ||
if: matrix.variant == 'gpu' | ||
- run: source/install/build_cc.sh | ||
env: | ||
FLOAT_PREC: ${{ matrix.float_prec }} | ||
CC: gcc-7 | ||
CXX: g++-7 |
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,11 @@ | ||
on: | ||
push: | ||
pull_request: | ||
name: Test C++ | ||
jobs: | ||
testpython: | ||
name: Test C++ | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- run: source/install/test_cc.sh |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[submodule "source/op/cuda/cub"] | ||
path = source/op/cuda/cub | ||
url = git://github.com/NVlabs/cub.git | ||
[submodule "source/lib/src/cuda/cub"] | ||
path = source/lib/src/cuda/cub | ||
url = git://github.com/NVIDIA/cub.git |
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,22 @@ | ||
"""Module that reads node resources, auto detects if running local or on SLURM.""" | ||
|
||
from .local import get_resource as get_local_res | ||
from .slurm import get_resource as get_slurm_res | ||
import os | ||
from typing import List, Tuple, Optional | ||
|
||
__all__ = ["get_resource"] | ||
|
||
|
||
def get_resource() -> Tuple[str, List[str], Optional[List[int]]]: | ||
"""Get local or slurm resources: nodename, nodelist, and gpus. | ||
Returns | ||
------- | ||
Tuple[str, List[str], Optional[List[int]]] | ||
nodename, nodelist, and gpus | ||
""" | ||
if "SLURM_JOB_NODELIST" in os.environ: | ||
return get_slurm_res() | ||
else: | ||
return get_local_res() |
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,84 @@ | ||
"""MOdule to get resources on SLURM cluster. | ||
References | ||
---------- | ||
https://github.com/deepsense-ai/tensorflow_on_slurm #### | ||
""" | ||
|
||
import re | ||
import os | ||
from typing import List, Tuple, Optional, Iterable | ||
|
||
__all__ = ["get_resource"] | ||
|
||
|
||
def get_resource() -> Tuple[str, List[str], Optional[List[int]]]: | ||
"""Get SLURM resources: nodename, nodelist, and gpus. | ||
Returns | ||
------- | ||
Tuple[str, List[str], Optional[List[int]]] | ||
nodename, nodelist, and gpus | ||
Raises | ||
------ | ||
RuntimeError | ||
if number of nodes could not be retrieved | ||
ValueError | ||
list of nodes is not of the same length sa number of nodes | ||
ValueError | ||
if current nodename is not found in node list | ||
""" | ||
nodelist = _expand_nodelist(os.environ["SLURM_JOB_NODELIST"]) | ||
nodename = os.environ["SLURMD_NODENAME"] | ||
num_nodes_env = os.getenv("SLURM_JOB_NUM_NODES") | ||
if num_nodes_env: | ||
num_nodes = int(num_nodes_env) | ||
else: | ||
raise RuntimeError("Could not get SLURM number of nodes") | ||
|
||
if len(nodelist) != num_nodes: | ||
raise ValueError( | ||
f"Number of slurm nodes {len(nodelist)} not equal to {num_nodes}" | ||
) | ||
if nodename not in nodelist: | ||
raise ValueError( | ||
f"Nodename({nodename}) not in nodelist({nodelist}). This should not happen!" | ||
) | ||
gpus_env = os.getenv("CUDA_VISIBLE_DEVICES") | ||
if not gpus_env: | ||
gpus = None | ||
else: | ||
gpus = [int(gpu) for gpu in gpus_env.split(",")] | ||
return nodename, nodelist, gpus | ||
|
||
|
||
def _pad_zeros(iterable: Iterable, length: int): | ||
return (str(t).rjust(length, "0") for t in iterable) | ||
|
||
|
||
def _expand_ids(ids: str) -> List[str]: | ||
result = [] | ||
for _id in ids.split(","): | ||
if "-" in _id: | ||
str_end = _id.split("-")[1] | ||
begin, end = [int(token) for token in _id.split("-")] | ||
result.extend(_pad_zeros(range(begin, end + 1), len(str_end))) | ||
else: | ||
result.append(_id) | ||
return result | ||
|
||
|
||
def _expand_nodelist(nodelist: str) -> List[str]: | ||
result = [] | ||
interval_list = nodelist.split(",") | ||
for interval in interval_list: | ||
match = re.search(r"(.*)\[(.*)\]", interval) | ||
if match: | ||
prefix = match.group(1) | ||
ids = match.group(2) | ||
ids_list = _expand_ids(ids) | ||
result.extend([f"{prefix}{_id}" for _id in ids_list]) | ||
else: | ||
result.append(interval) | ||
return result |
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.