polish install from source

This commit is contained in:
Dun Liang 2021-10-11 20:03:20 +08:00
parent ca2b4f20d0
commit e0d046f449
8 changed files with 186 additions and 2 deletions

View File

@ -17,6 +17,8 @@ Jittor前端语言为Python。前端使用了模块化和动态图执行的设
* [Jittor模型库](https://cg.cs.tsinghua.edu.cn/jittor/resources/)
* [Jittor文档](https://cg.cs.tsinghua.edu.cn/jittor/assets/docs/index.html)
* [Github](https://github.com/jittor/jittor) [Gitee](https://gitee.com/jittor/jittor)
* [Jittor 论坛](https://discuss.jittor.org/)
* 即时通信: QQ Group(761222083)

View File

@ -17,6 +17,8 @@ Related Links:
* [Jittor Models](https://cg.cs.tsinghua.edu.cn/jittor/resources/)
* [Jittor Documents](https://cg.cs.tsinghua.edu.cn/jittor/assets/docs/index.html)
* [Github](https://github.com/jittor/jittor), [Gitee](https://gitee.com/jittor/jittor)
* [Jittor Forum](https://discuss.jittor.org/)
* IM: QQ Group(761222083)

View File

@ -21,6 +21,8 @@ Related Links:
* [Jittor Models](https://cg.cs.tsinghua.edu.cn/jittor/resources/)
* [Jittor Documents](https://cg.cs.tsinghua.edu.cn/jittor/assets/docs/index.html)
* [Github](https://github.com/jittor/jittor), [Gitee](https://gitee.com/jittor/jittor)
* [Jittor Forum](https://discuss.jittor.org/)
* IM: QQ Group(761222083)
相关链接:
* [Jittor官网](https://cg.cs.tsinghua.edu.cn/jittor/)
@ -28,6 +30,8 @@ Related Links:
* [Jittor模型库](https://cg.cs.tsinghua.edu.cn/jittor/resources/)
* [Jittor文档](https://cg.cs.tsinghua.edu.cn/jittor/assets/docs/index.html)
* [Github](https://github.com/jittor/jittor) [Gitee](https://gitee.com/jittor/jittor)
* [Jittor 论坛](https://discuss.jittor.org/)
* 即时通信: QQ Group(761222083)
The following example shows how to model a two-layer neural network step by step and train from scratch In a few lines of Python code.

View File

@ -9,7 +9,7 @@
# file 'LICENSE.txt', which is part of this source code package.
# ***************************************************************
__version__ = '1.3.0.11'
__version__ = '1.3.0.12'
from jittor_utils import lock
with lock.lock_scope():
ori_int = int

View File

@ -0,0 +1,20 @@
★★★★★★★★★★★★★★★★★★★★★
Welcome to use Jittor
Please put the file under /root directory
★★★★★★★★★★★★★★★★★★★★★
欢迎使用Jittor
请将文件放置在/root目录下
本docker已经安装好cuda环境
相关链接:
* [Jittor官网](https://cg.cs.tsinghua.edu.cn/jittor/)
* [Jittor教程](https://cg.cs.tsinghua.edu.cn/jittor/tutorial/)
* [Jittor模型库](https://cg.cs.tsinghua.edu.cn/jittor/resources/)
* [Jittor文档](https://cg.cs.tsinghua.edu.cn/jittor/assets/docs/index.html)
* [Github](https://github.com/jittor/jittor) [Gitee](https://gitee.com/jittor/jittor)
* [Jittor 论坛](https://discuss.jittor.org/)
* 即时通信: QQ Group(761222083)
欢迎大家starfork并在QQ群或者论坛向我们提出宝贵的意见和建议。
注意:请不要开启无密码保护的jupyter notebook或vscode server
★★★★★★★★★★★★★★★★★★★★★

View File

@ -0,0 +1,16 @@
import sys
import os
command = sys.argv[1]
if (command == 'ssh'):
port = sys.argv[2]
data = open("/etc/ssh/sshd_config", "r").readlines()
data[12] = 'Port ' + port + '\nPermitRootLogin yes\n'
f = open("/etc/ssh/sshd_config", "w")
f.writelines(data)
f.close()
os.system("service ssh restart")
elif (command == 'passwd'):
passwd = sys.argv[2]
os.system("echo root:"+passwd+" | chpasswd")
else:
print('command error')

View File

@ -0,0 +1,137 @@
# ***************************************************************
# Copyright (c) 2021 Jittor. All Rights Reserved.
# Maintainers:
# Guoye Yang <498731903@qq.com>
# Dun Liang <randonlang@gmail.com>.
#
#
# This file is subject to the terms and conditions defined in
# file 'LICENSE.txt', which is part of this source code package.
# ***************************************************************
'''
example:
export class_home=/mnt/disk/cjld/class_nn
mkdir -p $class_home
docker pull jittor/jittor-cuda
python3.7 -m jittor_utils.class.setup_env setup 4
python3.7 -m jittor_utils.class.setup_env start 4
python3.7 -m jittor_utils.class.setup_env report
python3.7 -m jittor_utils.class.setup_env restart 4
python3.7 -m jittor_utils.class.setup_env stop
'''
# export class_home
# setup [n] // setup for n users. including build user paths, user_info.txt and docker imgs. !!!WILL RESET SUDENT_FILES!!!
# start [n_gpu] // run n docker CONTAINERs with n_gpu GPUs.
# stop // stop n docker CONTAINERs
# restart [n_gpu] // restart n docker CONTAINERs with n_gpu GPUs.
import sys
import os
import json as js
import random
class_home = os.environ["class_home"]
student_files_dir = class_home + "/student_files"
student_files_bk_dir = class_home + "/student_files_bak"
cwd = os.path.dirname(__file__)
def run_cmd(cmd):
print("[CMD]:", cmd)
ret = os.system(cmd)
if ret:
print("[CMD] return", ret)
return ret
def generate_random_str(randomlength):
random_str = ''
base_str = 'ABCDEFGHIGKLMNOPQRSTUVWXYZabcdefghigklmnopqrstuvwxyz0123456789'
length = len(base_str) - 1
for i in range(randomlength):
random_str += base_str[random.randint(0, length)]
return random_str
def setup(n):
if os.path.exists(student_files_dir):
if os.path.exists(student_files_bk_dir):
run_cmd(f"rm -rf {student_files_bk_dir}")
run_cmd(f"mv {student_files_dir} {student_files_bk_dir}")
os.makedirs(student_files_dir)
user_info = []
for i in range(n): # 0 for root
port = 20000 + i
passwd = generate_random_str(8)
name = 'stu_'+str(i)
path = os.path.abspath(os.path.join(student_files_dir, name))
info = {'port': port,
'passwd': passwd,
'name': name,
'path': path}
user_info.append(info)
student_files_src = class_home + "/student_files_src"
if os.path.isdir(student_files_src):
run_cmd(f"cp -r {student_files_src} {path}")
else:
run_cmd('mkdir -p ' + path)
js.dump(user_info, open(student_files_dir+"/user_info.json", "w"))
def start(n):
assert os.path.exists(student_files_dir+'/user_info.json')
user_info = js.load(open(student_files_dir+'/user_info.json', 'r'))
for i in range(len(user_info)):
id = i % n
u = user_info[i]
print('START', i, '/', len(user_info))
assert 0 == run_cmd(f'docker run -itd --shm-size=8g --network host --name {u["name"]} -v {u["path"]}:/root --gpus "device={id}" jittor/jittor-cuda bash')
# assert 0 == run_cmd(f'docker exec -it {u["name"]} bash -c \'apt update && apt install openssh-server -y\'')
assert 0 == run_cmd(f'docker cp {cwd}/setup.py {u["name"]}:/etc/ssh/setup.py')
assert 0 == run_cmd(f'docker cp {cwd}/motd {u["name"]}:/etc/motd')
assert 0 == run_cmd(f'docker exec -it {u["name"]} python3.7 /etc/ssh/setup.py passwd {u["passwd"]}')
assert 0 == run_cmd(f'docker exec -it {u["name"]} python3.7 /etc/ssh/setup.py ssh {u["port"]}')
assert 0 == run_cmd(f'docker exec -it {u["name"]} python3.7 -m pip install jittor -U')
assert 0 == run_cmd(f'docker exec -it {u["name"]} python3.7 -m jittor.test.test_core')
def stop():
assert os.path.exists(student_files_dir+'/user_info.json')
user_info = js.load(open(student_files_dir+'/user_info.json', 'r'))
for i in range(len(user_info)):
u = user_info[i]
print('STOP', i, '/', len(user_info))
run_cmd(f'docker rm -f {u["name"]}')
def report():
assert os.path.exists(student_files_dir+'/user_info.json')
user_info = js.load(open(student_files_dir+'/user_info.json', 'r'))
hostname = open("/etc/hostname", 'r').read().strip() + ".randonl.me"
for i in range(len(user_info)):
u = user_info[i]
print(f"ssh -p {u['port']} root@{hostname} # passwd: {u['passwd']}")
def restart(n):
stop()
start(n)
args = sys.argv[1:]
if (args[0] == 'setup'):
assert(len(args) == 2)
assert(type(eval(args[1])) == int)
n = int(args[1])
assert(n < 999)
setup(n)
elif (args[0] == 'start'):
assert(len(args) == 2)
assert(type(eval(args[1])) == int)
n = int(args[1])
start(n)
elif (args[0] == 'stop'):
stop()
elif (args[0] == 'restart'):
assert(len(args) == 2)
assert(type(eval(args[1])) == int)
n = int(args[1])
restart(n)
elif (args[0] == 'report'):
report()
else:
assert(False)

View File

@ -16,6 +16,9 @@ Reference:
from warnings import warn
import os
import platform
import site
import sys
site.ENABLE_USER_SITE = "--user" in sys.argv[1:]
if not platform.system() in ['Linux', 'Darwin']:
assert os.environ.get("FORCE_INSTALL", '0') != '1', error_msg
@ -58,7 +61,7 @@ setuptools.setup(
python_requires='>=3.7',
packages=["jittor", "jittor.test", "jittor.models", "jittor.utils", "jittor_utils"],
package_dir={'': os.path.join(path, 'python')},
package_dir={'': 'python'},
package_data={'': ['*', '*/*', '*/*/*','*/*/*/*','*/*/*/*/*','*/*/*/*/*/*']},
# include_package_data=True,
install_requires=[