-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix linking (#361) * add flag * remove implicit init * add setup script for mindspore * add if linux for flag * add check for KUNGFU_NO_AUTO_INIT * init :: -watch-mode reload * merge * revert Co-authored-by: Marcel Wagenländer <[email protected]>
- Loading branch information
Showing
20 changed files
with
488 additions
and
17 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,11 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
# go install -v ./... | ||
|
||
PYTHON=$(which python3) | ||
echo "Using $PYTHON" | ||
|
||
$PYTHON -m pip install --no-index -U . | ||
|
||
echo "done $0" |
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,28 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
PYTHON=$(which python3) | ||
echo "Using $PYTHON" | ||
|
||
runner_flags() { | ||
echo -logdir logs | ||
echo -q | ||
|
||
echo -w | ||
echo -elastic-mode reload | ||
echo -builtin-config-port 9100 | ||
echo -config-server http://127.0.0.1:9100/config | ||
} | ||
|
||
elastic_run_n() { | ||
local init_np=$1 | ||
shift | ||
$PYTHON -m kungfu.cmd $(runner_flags) -np $init_np $@ | ||
} | ||
|
||
app() { | ||
echo python3 tests/python/integration/test_elastic_reload.py | ||
echo --max-step 100 | ||
} | ||
|
||
elastic_run_n 1 $(app) |
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,111 @@ | ||
import multiprocessing | ||
import os | ||
import subprocess | ||
import sys | ||
import sysconfig | ||
|
||
from setuptools import Extension, find_packages, setup | ||
from setuptools.command.build_ext import build_ext | ||
|
||
|
||
class CMakeExtension(Extension): | ||
def __init__(self, sourcedir): | ||
Extension.__init__(self, '', sources=[]) | ||
self.sourcedir = os.path.abspath(sourcedir) | ||
|
||
|
||
def ensure_absent(filepath): | ||
if os.path.isfile(filepath): | ||
os.remove(filepath) | ||
|
||
|
||
def cmake_flag(k, v): | ||
return '-D%s=%s' % (k, str(v)) | ||
|
||
|
||
def pass_env(keys): | ||
for key in keys: | ||
val = os.getenv(key) | ||
if val: | ||
print('Using %s=%s from env' % (key, val)) | ||
yield cmake_flag(key, val) | ||
|
||
|
||
class CMakeBuild(build_ext): | ||
def build_extension(self, ext): | ||
if not os.path.exists(self.build_temp): | ||
os.makedirs(self.build_temp) | ||
|
||
extdir = self.get_ext_fullpath(ext.name) | ||
if not os.path.exists(extdir): | ||
os.makedirs(extdir) | ||
|
||
install_prefix = os.path.abspath(os.path.dirname(extdir)) | ||
executable_dir = os.path.abspath(os.path.dirname(sys.executable)) | ||
|
||
# FIXME: do it in a more standard way | ||
if '--user' in sys.argv: | ||
executable_dir = os.path.join(os.getenv('HOME'), '.local/bin') | ||
|
||
cmake_args = [ | ||
# FIXME: use CMAKE_LIBRARY_OUTPUT_DIRECTORY | ||
cmake_flag('LIBRARY_OUTPUT_PATH', | ||
os.path.join(install_prefix, 'kungfu')), | ||
cmake_flag('KUNGFU_BUILD_TF_OPS', 0), | ||
cmake_flag('CMAKE_RUNTIME_OUTPUT_DIRECTORY', executable_dir), | ||
cmake_flag('PYTHON', sys.executable), | ||
] + list( | ||
pass_env([ | ||
'KUNGFU_ENABLE_TRACE', | ||
'CMAKE_VERBOSE_MAKEFILE', | ||
'CMAKE_EXPORT_COMPILE_COMMANDS', | ||
])) | ||
|
||
if sys.platform == 'linux': | ||
cmake_args.append(cmake_flag('KUNGFU_ENABLE_AFFINITY', 1)) | ||
cmake_args.extend(pass_env(['KUNGFU_ENABLE_HWLOC'])) | ||
|
||
use_nccl = os.getenv('KUNGFU_ENABLE_NCCL') | ||
if use_nccl: | ||
cmake_args.append(cmake_flag('KUNGFU_ENABLE_NCCL', use_nccl)) | ||
nccl_home = os.getenv('NCCL_HOME') | ||
if nccl_home: | ||
cmake_args.append(cmake_flag('NCCL_HOME', nccl_home)) | ||
|
||
ensure_absent(os.path.join(ext.sourcedir, 'CMakeCache.txt')) | ||
|
||
subprocess.check_call( | ||
['cmake', ext.sourcedir] + cmake_args, | ||
cwd=self.build_temp, | ||
) | ||
if (os.getenv('CMAKE_BUILD_PARALLEL_LEVEL') is None | ||
and os.getenv('READTHEDOCS') is None): | ||
os.environ['CMAKE_BUILD_PARALLEL_LEVEL'] = str( | ||
multiprocessing.cpu_count()) | ||
subprocess.check_call( | ||
['cmake', '--build', '.'], | ||
cwd=self.build_temp, | ||
) | ||
|
||
|
||
package_dir = './srcs/python' | ||
|
||
setup( | ||
name='kungfu', | ||
version='0.2.2', | ||
package_dir={'': package_dir}, | ||
packages=find_packages(package_dir), | ||
description='KungFu distributed machine learning framework', | ||
url='https://github.com/lsds/KungFu', | ||
ext_modules=[ | ||
CMakeExtension('.'), | ||
], | ||
cmdclass=dict(build_ext=CMakeBuild), | ||
setup_requires=[], | ||
install_requires=[], | ||
entry_points={ | ||
'console_scripts': [ | ||
'kungfu-run = kungfu.cmd:run', | ||
], | ||
}, | ||
) |
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
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.