Skip to content

Commit

Permalink
[Release] v0.1.3
Browse files Browse the repository at this point in the history
[Release] v0.1.3
  • Loading branch information
jermainewang authored Mar 30, 2020
2 parents cf307b1 + de14753 commit cbd8ecc
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 64 deletions.
15 changes: 12 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ execute_process(
)
message(STATUS "TF_LFLAGS = ${TF_LFLAGS}")

execute_process(
COMMAND bash -c "${PYTHON_EXECUTABLE} -c 'import tensorflow as tf; print(tf.__version__)' | grep -o '[[:digit:]]\\+\\.[[:digit:]]\\+\\.[[:digit:]]\\+'"
OUTPUT_VARIABLE TF_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "TF_VERSION = ${TF_VERSION}")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 ${TF_CFLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -D_GLIBCXX_USE_CXX11_ABI=0 ${TF_CFLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3 -ggdb -D_GLIBCXX_USE_CXX11_ABI=0 ${TF_CFLAGS}")
Expand All @@ -54,8 +61,10 @@ file(GLOB SRC
src/*.cc
)

add_library(tfdlpack SHARED ${SRC})
set(LIB_NAME "tfdlpack-tf-${TF_VERSION}")

add_library(${LIB_NAME} SHARED ${SRC})

target_link_libraries(tfdlpack ${TF_LFLAGS})
target_link_libraries(${LIB_NAME} ${TF_LFLAGS})

install(TARGETS tfdlpack DESTINATION tfdlpack)
install(TARGETS ${LIB_NAME} DESTINATION tfdlpack)
16 changes: 8 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ pipeline {
agent any
stages {
stage("Lint Check") {
agent {
docker {
image "dgllib/tfdlpack-ci-gpu"
agent {
docker {
image "dgllib/tfdlpack-ci-gpu:03302020"
args "--runtime nvidia"
}
}
}
steps {
init_git()
Expand All @@ -28,11 +28,11 @@ pipeline {
}

stage("Build and Test") {
agent {
docker {
image "dgllib/tfdlpack-ci-gpu"
agent {
docker {
image "dgllib/tfdlpack-ci-gpu:03302020"
args "--runtime nvidia"
}
}
}
steps {
init_git()
Expand Down
10 changes: 9 additions & 1 deletion docker/install/ubuntu_install_conda.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,23 @@ fi
wget -O /tmp/install.sh https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
sh /tmp/install.sh -b

pushd $HOME
CONDA_PREFIX=$HOME/miniconda3/bin
export PATH=$CONDA_PREFIX:$PATH
for PY_VER in 3.5 3.6 3.7; do
echo "Create conda env for python $PY_VER"
conda create -n $PY_VER -y python=$PY_VER
source activate $PY_VER
pip install --upgrade pip
pip install $TF==2.1.0
mkdir $PY_VER
pushd $PY_VER
pip download --no-deps $TF==2.1.0
pip download --no-deps $TF==2.2.0-rc2
pip install tensorflow*2.1.0*.whl
ls -lh
popd
conda install -y pytest
conda install -y $TH -c pytorch
source deactivate
done
popd
47 changes: 6 additions & 41 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,52 +25,17 @@ def get_lib_path():
libinfo = {'__file__': libinfo_py}
exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinfo)
version = libinfo['__version__']

lib_path = libinfo['find_lib_path']()
libs = [lib_path[0]]
libs = []
optional = not ("bdist_wheel" in sys.argv or os.getenv('CONDA_BUILD'))
for libname in libinfo['LIBNAMES']:
lib_path = libinfo['find_lib_path'](libname, optional=optional)
if lib_path is not None:
libs.append(lib_path[0])

return libs, version

LIBS, VERSION = get_lib_path()

# class CMakeExtension(Extension):
# def __init__(self, name, sourcedir=''):
# Extension.__init__(self, name, sources=[])
# self.sourcedir = os.path.abspath(sourcedir)


# class CMakeBuild(build_ext):
# def run(self):
# try:
# out = subprocess.check_output(['cmake', '--version'])
# except OSError:
# raise RuntimeError("CMake must be installed to build the following extensions: " +
# ", ".join(e.name for e in self.extensions))

# if platform.system() == "Windows":
# raise RuntimeError("Windows is not currently supported")

# for ext in self.extensions:
# self.build_extension(ext)

# def build_extension(self, ext):
# extdir = os.path.abspath(os.path.dirname(
# self.get_ext_fullpath(ext.name)))
# extdir = os.path.join(extdir, "tfdlpack", "build") # Not sure whether this is fine

# cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
# '-DPYTHON_EXECUTABLE=' + sys.executable]

# cfg = 'Debug' if self.debug else 'Release'
# build_args = ['--config', cfg]
# env = os.environ.copy()
# if not os.path.exists(self.build_temp):
# os.makedirs(self.build_temp)
# subprocess.check_call(['cmake', ext.sourcedir] +
# cmake_args, cwd=self.build_temp, env=env)
# subprocess.check_call(['cmake', '--build', '.'] +
# build_args, cwd=self.build_temp)

include_libs = False
wheel_include_libs = False
if "bdist_wheel" in sys.argv or os.getenv('CONDA_BUILD'):
Expand Down
9 changes: 4 additions & 5 deletions python/tfdlpack/core.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pylint: disable=no-name-in-module, invalid-name
# pylint: disable=no-name-in-module, invalid-name, no-member
"""core functions"""

import tensorflow as tf
Expand All @@ -10,7 +10,9 @@
# version number
__version__ = libinfo.__version__

dlpack_ops = load_library.load_op_library(libinfo.find_lib_path()[0])
# find lib
libname = libinfo.get_libname(tf.__version__)
dlpack_ops = load_library.load_op_library(libinfo.find_lib_path(libname)[0])
_to_dlpack_address = dlpack_ops.to_dlpack
_from_dlpack = dlpack_ops.from_dlpack
_get_device_and_dtype = dlpack_ops.get_device_and_dtype
Expand Down Expand Up @@ -45,9 +47,7 @@ def from_dlpack(dl_capsule):
device_and_dtype = get_device_and_dtype(dl_capsule)
device = device_and_dtype[:2]
dtype = device_and_dtype[2]
# print("Dtype: {}".format(dtype))
ptr = get_capsule_address(dl_capsule, consume=True)
# tf_device_type =
if device[0] == 1:
tf_device_type = "cpu"
tf_device_id = int(device[1])
Expand All @@ -60,7 +60,6 @@ def from_dlpack(dl_capsule):
with tf.device("cpu:0"):
ad_tensor = tf.constant([ptr], dtype=tf.uint64)
with tf.device(tf_device):
# tf_tensor = _from_dlpack(ad_tensor, T=tf.float32)
tf_tensor = _from_dlpack(ad_tensor, T=tf.DType(dtype))

return tf_tensor
21 changes: 19 additions & 2 deletions python/tfdlpack/libinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from __future__ import absolute_import
import sys
import os

from distutils.version import StrictVersion
import re

def find_lib_path(name=None, search_path=None, optional=False):
"""Find dynamic library files.
Expand Down Expand Up @@ -81,9 +82,25 @@ def find_lib_path(name=None, search_path=None, optional=False):

return lib_found

# supported tensorflow versions (map from tf version to lib name)
LIBNAMES = ["libtfdlpack-tf-2.1.0.so", "libtfdlpack-tf-2.2.0.so"]

def get_libname(tfversion):
"""Get tfdlpack library name given the tensorflow version"""
version_re = re.compile(r'(?x)^((\d+)\.(\d+)\.(\d+))')
match = version_re.match(tfversion)
if match is None:
raise RuntimeError("Unsupported tensorflow version:", tfversion)
strict_ver = StrictVersion(match.groups()[0])
if strict_ver <= StrictVersion('2.1.0'):
return "libtfdlpack-tf-2.1.0.so"
elif strict_ver <= StrictVersion('2.2.0'):
return "libtfdlpack-tf-2.2.0.so"
else:
raise RuntimeError("Unsupported tensorflow version:", tfversion)

# current version
# We use the version of the incoming release for code
# that is under development.
# The following line is set by tfdlpack/python/update_version.py
__version__ = "0.1.2"
__version__ = "0.1.3"
19 changes: 15 additions & 4 deletions tests/scripts/build_in_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,25 @@ git checkout $BRANCH
CONDA_PREFIX=$HOME/miniconda3/bin
export PATH=$CONDA_PREFIX:$PATH
export PYTHONPATH=$PWD/python:$PYTHONPATH
export TFDLPACK_LIBRARY_PATH=$PWD/build
export TFDLPACK_LIBRARY_PATH=$PWD/libs
for PY_VER in 3.5 3.6 3.7; do
echo "Build for python $PY_VER"
source activate $PY_VER
# clean & build
rm -rf build
mkdir build
cd build; cmake -DUSE_CUDA=$USE_CUDA ..; make -j; cd ..
rm -rf libs
mkdir libs
for TF_VER in "2.1.0" "2.2.0rc2"; do
pip uninstall -y tensorflow
if [ $PY_VER = "3.5" ]; then
pip uninstall -y numpy
pip install numpy
fi
pip install $HOME/$PY_VER/tensorflow*${TF_VER}*.whl
rm -rf build
mkdir build
cd build; cmake -DUSE_CUDA=$USE_CUDA ..; make -j; cd ..
mv build/*.so libs
done
# test
if [ $USE_CUDA = "ON" ]; then
python -m pytest tests
Expand Down
4 changes: 4 additions & 0 deletions tests/scripts/build_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ BRANCH=$1

rm -rf *.whl

docker pull dgllib/tfdlpack-ci-cpu:03302020

docker run -it --rm -v "$PWD":/workspace \
--name tfdlpack-build-cpu dgllib/tfdlpack-ci-cpu:latest \
bash /workspace/build_in_docker.sh $BRANCH OFF

docker pull dgllib/tfdlpack-ci-gpu:03302020

docker run -it --rm -v "$PWD":/workspace \
--runtime nvidia \
--name tfdlpack-build-gpu dgllib/tfdlpack-ci-gpu:latest \
Expand Down

0 comments on commit cbd8ecc

Please sign in to comment.