Skip to content

Commit

Permalink
[Backend] Turn to official dlpack for Tensorflow (dmlc#1511)
Browse files Browse the repository at this point in the history
* Turn to official dlpack

* fix

* fix
  • Loading branch information
VoVAllen authored May 11, 2020
1 parent 0285021 commit 6d04885
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
12 changes: 11 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ pipeline {
agent {
docker {
label "linux-c52x-node"
image "dgllib/dgl-ci-lint"
image "dgllib/dgl-ci-lint"
alwaysPull true
}
}
steps {
Expand All @@ -121,6 +122,7 @@ pipeline {
docker {
label "linux-c52x-node"
image "dgllib/dgl-ci-cpu:conda"
alwaysPull true
}
}
steps {
Expand All @@ -138,6 +140,7 @@ pipeline {
label "linux-c52x-node"
image "dgllib/dgl-ci-gpu:conda"
args "-u root"
alwaysPull true
}
}
steps {
Expand Down Expand Up @@ -173,6 +176,7 @@ pipeline {
docker {
label "linux-c52x-node"
image "dgllib/dgl-ci-cpu:conda"
alwaysPull true
}
}
steps {
Expand Down Expand Up @@ -200,6 +204,7 @@ pipeline {
docker {
label "linux-c52x-node"
image "dgllib/dgl-ci-cpu:conda"
alwaysPull true
}
}
stages {
Expand All @@ -221,6 +226,7 @@ pipeline {
label "linux-gpu-node"
image "dgllib/dgl-ci-gpu:conda"
args "--runtime nvidia"
alwaysPull true
}
}
stages {
Expand All @@ -241,6 +247,7 @@ pipeline {
docker {
label "linux-c52x-node"
image "dgllib/dgl-ci-cpu:conda"
alwaysPull true
}
}
stages {
Expand Down Expand Up @@ -292,6 +299,7 @@ pipeline {
label "linux-gpu-node"
image "dgllib/dgl-ci-gpu:conda"
args "--runtime nvidia"
alwaysPull true
}
}
stages {
Expand All @@ -318,6 +326,7 @@ pipeline {
docker {
label "linux-c52x-node"
image "dgllib/dgl-ci-cpu:conda"
alwaysPull true
}
}
stages {
Expand All @@ -344,6 +353,7 @@ pipeline {
label "linux-gpu-node"
image "dgllib/dgl-ci-gpu:conda"
args "--runtime nvidia"
alwaysPull true
}
}
stages {
Expand Down
3 changes: 1 addition & 2 deletions docker/install/conda_env/tensorflow_cpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ dependencies:
- python=3.6.9
- pip
- pip:
- tensorflow==2.2.0rc1
# - tf-nightly==2.2.0.dev20200327
- tensorflow==2.2.0
- tfdlpack
- pytest
- nose
Expand Down
3 changes: 1 addition & 2 deletions docker/install/conda_env/tensorflow_gpu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ dependencies:
- python=3.6.9
- pip
- pip:
- tensorflow==2.2.0rc1
# - tf-nightly==2.2.0.dev20200327
- tensorflow==2.2.0
- tfdlpack-gpu
- pytest
- nose
Expand Down
4 changes: 2 additions & 2 deletions python/dgl/backend/tensorflow/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
from ... import kernel as K
from ...function.base import TargetCode

if os.getenv("USE_OFFICIAL_TFDLPACK", False):
if not os.getenv("USE_TFDLPACK", False):
if LooseVersion(tf.__version__) < LooseVersion("2.2.0"):
raise RuntimeError("DGL requires tensorflow>=2.2.0 for the official DLPack support.")

def zerocopy_to_dlpack(input):
return tf.experimental.dlpack.to_dlpack(input)

def zerocopy_from_dlpack(dlpack_tensor):
# TODO(Jinjing): Tensorflow requires memory to be 64-bit aligned. We check the
# TODO(Jinjing): Tensorflow requires memory to be 64-bytes aligned. We check the
# alignment and make a copy if needed. The functionality is better in TF's main repo.
aligned = nd.from_dlpack(dlpack_tensor).to_dlpack(64)
return tf.experimental.dlpack.from_dlpack(aligned)
Expand Down
2 changes: 1 addition & 1 deletion tests/scripts/build_dgl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rm -rf _download

pushd build
cmake $CMAKE_VARS ..
make -j4
make -j8
popd

pushd python
Expand Down

0 comments on commit 6d04885

Please sign in to comment.