Skip to content

Commit 9f4a6ea

Browse files
committed
environment config
1 parent b515934 commit 9f4a6ea

File tree

15 files changed

+267
-0
lines changed

15 files changed

+267
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import os
2+
import re
3+
import sys
4+
from typing import Any, Dict
5+
6+
VERSIONS_LUT: Dict[str, Dict[str, Any]] = {
7+
"1.4.0": dict(torchvision="0.5.0", torchtext="0.5"),
8+
"1.5.0": dict(torchvision="0.6.0", torchtext="0.6"),
9+
"1.5.1": dict(torchvision="0.6.1", torchtext="0.6"),
10+
"1.6.0": dict(torchvision="0.7.0", torchtext="0.7"),
11+
"1.7.0": dict(torchvision="0.8.1", torchtext="0.8"),
12+
"1.7.1": dict(torchvision="0.8.2", torchtext="0.8.1"),
13+
"1.8.0": dict(torchvision="0.9.0", torchtext="0.9"),
14+
"1.8.1": dict(torchvision="0.9.0", torchtext="0.9"),
15+
}
16+
17+
18+
def find_latest(ver: str, versions_all: list) -> str:
19+
# drop all except semantic version
20+
ver = re.search(r'([\.\d]+)', ver).groups()[0]
21+
# find candidates, by starting version pattern
22+
options = [v for v in versions_all if v.startswith(ver)]
23+
assert options, f"missing {ver} among {versions_all}"
24+
# take the last one...
25+
return sorted(options)[-1]
26+
27+
28+
def main(path_req: str, torch_version: str = None) -> None:
29+
with open(path_req, "r") as fp:
30+
req = fp.read()
31+
32+
if not torch_version:
33+
import torch
34+
torch_version = torch.__version__
35+
assert torch_version, f"invalid/missing Torch: {torch_version}"
36+
37+
torch_version = find_latest(torch_version, list(VERSIONS_LUT.keys()))
38+
dep_versions = VERSIONS_LUT[torch_version]
39+
dep_versions["torch"] = torch_version
40+
for lib in dep_versions:
41+
version = dep_versions[lib]
42+
replace = f"{lib}=={version}\n"
43+
req = re.sub(rf"{lib}[>=]*[\d\.]*{os.linesep}", replace, req)
44+
45+
with open(path_req, "w") as fp:
46+
fp.write(req)
47+
48+
49+
if __name__ == "__main__":
50+
main(*sys.argv[1:])
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name:
2+
lightning
3+
4+
channels:
5+
- conda-forge
6+
- pytorch
7+
- pytorch-test
8+
- pytorch-nightly
9+
10+
dependencies:
11+
- python>=3.6
12+
- pip>20.1
13+
- numpy>=1.16.4
14+
- pytorch>=1.4
15+
- future>=0.17.1
16+
- PyYAML>=5.1
17+
- tqdm>=4.41.0
18+
- fsspec[http]>=0.8.1
19+
#- tensorboard>=2.2.0 # not needed, already included in pytorch
20+
21+
# Optional
22+
#- nvidia-apex # missing for py3.8
23+
- scikit-learn>=0.20.0
24+
- matplotlib>=3.1.1
25+
- omegaconf>=2.0.0
26+
- torchtext>=0.5
27+
28+
# Examples
29+
- torchvision>=0.5
30+
31+
- pip:
32+
- test-tube>=0.7.5
33+
- mlflow>=1.0.0
34+
- comet_ml>=3.1.12
35+
- wandb>=0.8.21
36+
- neptune-client>=0.4.109
37+
- horovod>=0.21.2
38+
- onnxruntime>=1.3.0
39+
- gym>=0.17.0

python-pytorchlightning/extra.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# extended list of package dependencies to reach full functionality
2+
3+
matplotlib>3.1
4+
horovod>=0.21.2 # no need to install with [pytorch] as pytorch is already installed
5+
omegaconf>=2.0.1
6+
torchtext>=0.5
7+
# onnx>=1.7.0
8+
onnxruntime>=1.3.0
9+
hydra-core>=1.0
10+
# todo: when switch to standard package stream, drop `fairscale` from hard mocked docs libs
11+
https://github.com/PyTorchLightning/fairscale/archive/pl_1.2.0.zip
12+
jsonargparse[signatures]>=3.9.0
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
BAI_MULTINODE_CONFIG_TF=$(/opt/backend.ai/bin/python /opt/container/setup_multinode.py)
3+
if [ -z "$BAI_MULTINODE_CONFIG_TF" ];
4+
then
5+
echo "";
6+
else
7+
echo ${BAI_MULTINODE_CONFIG_TF}
8+
export TF_CONFIG="${BAI_MULTINODE_CONFIG_TF}"
9+
fi
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
import json
3+
4+
if 'BACKENDAI_CLUSTER_HOST' in os.environ: # Start mutli-instance setup.
5+
env = {}
6+
env['cluster'] = {}
7+
env['cluster']['worker'] = []
8+
for container in os.environ['BACKENDAI_CLUSTER_HOSTS'].split(","):
9+
env['cluster']['worker'].append(container + ":2220")
10+
env['task'] = {}
11+
if os.environ['BACKENDAI_CLUSTER_ROLE'] == 'main':
12+
env['task']['type'] = "worker" # Was chief. but recent TF choose first worker as chief.
13+
env['task']["index"] = str(int(os.environ['BACKENDAI_CLUSTER_IDX']) - 1) # Index starts from 0
14+
else:
15+
env['task']['type'] = "worker"
16+
env['task']["index"] = os.environ['BACKENDAI_CLUSTER_IDX']
17+
print(json.dumps(env))
18+
else:
19+
print("")
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"command": [
3+
"{runtime_path}", "-m", "digits"
4+
]
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"command": [
3+
"{runtime_path}", "-m", "IPython"
4+
]
5+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"prestart": [
3+
{
4+
"action": "write_tempfile",
5+
"args": {
6+
"body": [
7+
"c.NotebookApp.allow_root = True\n",
8+
"c.NotebookApp.ip = \"0.0.0.0\"\n",
9+
"c.NotebookApp.port = {ports[0]}\n",
10+
"c.NotebookApp.token = \"\"\n",
11+
"c.FileContentsManager.delete_to_trash = False\n"
12+
]
13+
},
14+
"ref": "jupyter_cfg"
15+
}
16+
],
17+
"command": [
18+
"{runtime_path}", "-m", "notebook", "--no-browser", "--config", "{jupyter_cfg}"
19+
]
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"prestart": [
3+
{
4+
"action": "write_tempfile",
5+
"args": {
6+
"body": [
7+
"c.NotebookApp.allow_root = True\n",
8+
"c.NotebookApp.ip = \"0.0.0.0\"\n",
9+
"c.NotebookApp.port = {ports[0]}\n",
10+
"c.NotebookApp.token = \"\"\n",
11+
"c.FileContentsManager.delete_to_trash = False\n"
12+
]
13+
},
14+
"ref": "jupyter_cfg"
15+
}
16+
],
17+
"command": [
18+
"{runtime_path}", "-m", "jupyterlab", "--no-browser", "--config", "{jupyter_cfg}"
19+
]
20+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"prestart": [],
3+
"command": [
4+
"/usr/local/bin/mlflow",
5+
"ui",
6+
"--host",
7+
"0.0.0.0"
8+
]
9+
}

0 commit comments

Comments
 (0)