Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Commit

Permalink
feat: install nccl deps in bagua core and add generated __version__ v…
Browse files Browse the repository at this point in the history
…ariable
  • Loading branch information
NOBLES5E committed Jun 10, 2021
1 parent cc3f15f commit 57b90ed
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 5 deletions.
Empty file removed bagua-core-py/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion bagua-core-py/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ impl BaguaBucketPy {
}

#[pymodule]
fn bagua_core_py(_py: Python, m: &PyModule) -> PyResult<()> {
fn bagua_core(_py: Python, m: &PyModule) -> PyResult<()> {
tracing_subscriber::fmt()
.with_env_filter(tracing_subscriber::EnvFilter::from_env("LOG_LEVEL"))
.init();
Expand Down
1 change: 1 addition & 0 deletions bagua-core-py/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.1.dev1"
2 changes: 1 addition & 1 deletion bagua_install_library/install_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def install_lib(cuda, prefix, library):
)
)
if prefix is None:
prefix = os.path.expanduser("~/.bagua/cuda_lib")
prefix = os.path.expanduser("~/.bagua_core/cuda_lib")
destination = calculate_destination(prefix, cuda, library, record[library])

if os.path.exists(destination):
Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ requires = ["setuptools", "wheel", "setuptools-rust", "colorama", "tqdm", "setup

[tool.setuptools_scm]
local_scheme = "no-local-version"
write_to = "bagua-core-py/version.py"
write_to_template = "__version__ = \"{version}\""
4 changes: 4 additions & 0 deletions python/bagua_core/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from . import _environment
_environment._preload_libraries()
from .version import __version__
from .bagua_core import *
8 changes: 8 additions & 0 deletions python/bagua_core/_environment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import ctypes
import os


def _preload_libraries():
cwd = os.path.dirname(os.path.abspath(__file__))
libnccl_path = os.path.join(cwd, ".data", "lib", "libnccl.so")
ctypes.CDLL(libnccl_path)
9 changes: 6 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def install_dependency_library():
"--cuda",
nvcc_version,
"--prefix",
os.path.join(cwd, "bagua"),
os.path.join(cwd, "python/bagua_core"),
]
install_library.main(args)

Expand All @@ -63,16 +63,19 @@ def install_dependency_library():
url="https://github.com/BaguaSys/bagua-core",
python_requires=">=3.6",
description="Core communication lib for Bagua.",
package_dir={"": "python/"},
packages=find_packages("python/"),
package_data={"": [".data/lib/libnccl.so"]},
rust_extensions=[
RustExtension(
"bagua_core_py",
"bagua_core.bagua_core",
path="bagua-core-py/Cargo.toml",
binding=Binding.PyO3,
native=True,
)
],
author="Kuaishou AI Platform & DS3 Lab",
author_email="admin@mail.xrlian.com",
package_data={"": [".data/lib/libnccl.so"]},
install_requires=[],
zip_safe=False,
)

0 comments on commit 57b90ed

Please sign in to comment.