I have been following the TK1 discussion where people tried to compile TensorFlow for the TK1, but since the TX1 is out with CUDA 7.0 (see JetPack 2.0) I was wondering how to compile it for the TX1.
I started with the TensorFlow setup guide.
One of the first steps is to install bazel.
Already at that stage I get stuck. I was able to install all dependencies:
Then I downloaded the sources and tried to copile it:
wget https://github.com/bazelbuild/bazel/archive/0.1.1.tar.gz
tar -xf 0.1.1.tar.gz
cd bazel-0.1.1
./compile.sh
All I got was:
INFO: You can skip this first step by providing a path to the bazel binary as second argument:
INFO: ./compile.sh build /path/to/bazel
Building Bazel from scratch
I don’t have the binaries:
bazel-bin/src/bazel
and I did not receive any error message. Am I doing something obvious wrong?
Is there another way to get TensorFlow (with GPU support) up and running on the TX1?
You cannot use the Oracle Java, it is very confused by the kernel being 64bit and the user space 32bit.
You will need to install openjdk and then modify the scripts/bootstrap/buildenv.sh file to identify the Jetson TX1 as arm 32bit.
mfatica’s guide helped a lot with tensorflow, but it still had a lot of problems. I think I have worked through all the arm64 problems but now I am running into out of memory problems, and I need to add some swap to the board to finish the bazel build. If you have thoughts on this I have a thread.
(TX1 -- swapon failed: Function not implemented - Jetson TX1 - NVIDIA Developer Forums)
I have the changes I made up here. I plan on cleaning stuff up and doing a better post with a binary when I get done.
I installed openjdk8. I also had to modify some BUILD file in bazel to get to compile. You will see you also have to build protobuf from source on arm64 as well and swap out a jar and a binary file.
I have the compiled src folders zipped on my google drive. They have the compiled bazel and protobuf binaries in there. You are welcome to download it and use that. It won’t get you anywhere unless you can figure out how to mount a swap though.
After I get the thing compiled fully I’ll also post a cleaned up github fork with the changes for the TX1.
There has been no activity here for some time, so please allow me to ask a blunt question. What is the preferred way to install Tensorboard to JTX1 today? Does GPU support work?
I think this posting summarized the issue pretty clearly. Most likely we’ll have to wait for NVIDIA’s release of a new nvcc compiler (variadic templates problem) to be able to build GPU accelerated TensorFlow on JTX1.
I tried recently with the latest (as of this writing) LT24.2 and JetPack 2.3, and even with the advice on the CudaMusing blogpost referenced earlier it was still a no-go. Has anyone had success with any of the recent configurations under JetPack 2.3? Having access to TensorFlow on my TX1 would be the achievement of my heart’s desire, as far as the TX1 goes.
— a/tensorflow/core/kernels/BUILD
+++ b/tensorflow/core/kernels/BUILD
@@ -985,7 +985,7 @@ tf_kernel_libraries(
“reduction_ops”,
“segment_reduction_ops”,
“sequence_ops”,
- “sparse_matmul_op”,
+ #DC “sparse_matmul_op”,
],
deps = [
“:bounds_check”,
— a/tensorflow/stream_executor/cuda/cuda_gpu_executor.cc
+++ b/tensorflow/stream_executor/cuda/cuda_gpu_executor.cc
@@ -888,6 +888,9 @@ CudaContext* CUDAExecutor::cuda_context() { return context_; }
// For anything more complicated/prod-focused than this, you’ll likely want to
// turn to gsys’ topology modeling.
static int TryToReadNumaNode(const string &pci_bus_id, int device_ordinal) {
+ // DC - make this clever later. ARM has no NUMA node, just return 0
+ LOG(INFO) << “ARM has no NUMA node, hardcoding to return zero”;
+ return 0; #if defined(APPLE)
LOG(INFO) << “OS X does not support NUMA - returning NUMA node zero”;
return 0;
— a/tensorflow/stream_executor/cuda/cuda_blas.cc
+++ b/tensorflow/stream_executor/cuda/cuda_blas.cc
@@ -25,6 +25,12 @@ limitations under the License. define EIGEN_HAS_CUDA_FP16 endif
I tried to compile tensorflow 0.12.1 on TX1 with JetPack-2.3.1 (the latest)
# install necessary requirements for building everything
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install protobuf-compiler curl libprotobuf-dev python-numpy python-dev
# install oracle java dev kit - bazel has issues compiling with openjdk
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
mkdir src
cd src
# bazel compiles from "dist" zip only, since it includes required binaries for bootstrap.
# zip in release 0.4.3 includes working arm32 binaries for bootstrapping
wget https://github.com/bazelbuild/bazel/releases/download/0.4.3/bazel-0.4.3-dist.zip --no-check-zertificate
# yet bazel needs to be patched to compile (and run correctly) on aarch64
echo 'diff --git a/src/main/java/com/google/devtools/build/lib/util/CPU.java b/src/main/java/com/google/devtools/build/lib/util/CPU.java
index 7a85c29..ccd95bd 100644
--- a/src/main/java/com/google/devtools/build/lib/util/CPU.java
+++ b/src/main/java/com/google/devtools/build/lib/util/CPU.java
@@ -25,7 +25,7 @@ public enum CPU {
X86_32("x86_32", ImmutableSet.of("i386", "i486", "i586", "i686", "i786", "x86")),
X86_64("x86_64", ImmutableSet.of("amd64", "x86_64", "x64")),
PPC("ppc", ImmutableSet.of("ppc", "ppc64", "ppc64le")),
- ARM("arm", ImmutableSet.of("arm", "armv7l")),
+ ARM("arm", ImmutableSet.of("arm", "armv7l","aarch64")),
S390X("s390x", ImmutableSet.of("s390x", "s390")),
UNKNOWN("unknown", ImmutableSet.<String>of());
diff --git a/tools/cpp/cc_configure.bzl b/tools/cpp/cc_configure.bzl
index 330a068..793c2a2 100644
--- a/tools/cpp/cc_configure.bzl
+++ b/tools/cpp/cc_configure.bzl
@@ -140,6 +140,8 @@ def _get_cpu_value(repository_ctx):
return "x64_windows"
# Use uname to figure out whether we are on x86_32 or x86_64
result = repository_ctx.execute(["uname", "-m"])
+ if result.stdout.strip() in ["aarch64"]:
+ return "arm"
return "k8" if result.stdout.strip() in ["amd64", "x86_64", "x64"] else "piii"
' >bazel-0.4.3-arm64.patch
mkdir bazel-0.4.3
cd bazel-0.4.3/
unzip ../bazel-0.4.3-dist.zip
patch -p1 <../bazel-0.4.3-arm64.patch
./compile.sh
# ... Build successful! Binary is here: /home/ubuntu/src/bazel-0.4.3/output/bazel
sudo cp -a output/bazel /usr/local/bin/
cd ..
# tensorflow gets compiled from gir source, latest release is 0.12.1
git clone git clone -b 0.12.1 https://github.com/tensorflow/tensorflow.git tensorflow-0.12.1
# however it tries to download build time requirements, some of which have dead links
echo 'diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl
index 06e16cd..702b6be 100644
--- a/tensorflow/workspace.bzl
+++ b/tensorflow/workspace.bzl
@@ -64,7 +64,7 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
native.new_http_archive(
name = "nasm",
- url = "http://www.nasm.us/pub/nasm/releasebuilds/2.12.02/nasm-2.12.02.tar.bz2",
+ url = "http://pkgs.fedoraproject.org/repo/pkgs/nasm/nasm-2.12.02.tar.bz2/d15843c3fb7db39af80571ee27ec6fad/nasm-2.12.02.tar.bz2",
sha256 = "00b0891c678c065446ca59bcee64719d0096d54d6886e6e472aeee2e170ae324",
strip_prefix = "nasm-2.12.02",
build_file = str(Label("//third_party:nasm.BUILD")),
@@ -228,7 +228,7 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
native.new_http_archive(
name = "zlib_archive",
- url = "http://zlib.net/zlib-1.2.8.tar.gz",
+ url = "http://zlib.net/fossils/zlib-1.2.8.tar.gz",
sha256 = "36658cb768a54c1d4dec43c3116c27ed893e88b02ecfcb44f2166f9c0b7f2a0d",
strip_prefix = "zlib-1.2.8",
build_file = str(Label("//:zlib.BUILD")),
' >tensorflow-0.12.1-tx1.patch
cd tensorflow-0.12.1
patch -p1 <../tensorflow-0.12.1-tx1.patch
./configure # inputs according to http://www.nvidia.com/object/gpu-accelerated-applications-tensorflow-installation.html
# set GPU usage to yes, set CuDnn install location (defaults to /usr/local/cuda to) /usr (cudnn.h is in /usr/include, won't be found otherwise)
bazel build -c opt --config=cuda --jobs 1 --verbose_failures --local_resources 2048,.5,1.0 //tensorflow/tools/pip_package:build_pip_package
However, the compilation fails with an internal error in the Cuda compiler. Seems like an issue with cuda8 is blocking tensorflow compilation right now:
bazel build -c opt --config=cuda --jobs 1 --verbose_failures --local_resources 2048,.5,1.0 //tensorflow/tools/pip_package:build_pip_package
WARNING: Sandboxed execution is not supported on your system and thus hermeticity of actions cannot be guaranteed. See http://bazel.build/docs/bazel-user-manual.html#sandboxing for more information. You can turn off this warning via --ignore_unsupported_sandboxing.
INFO: Found 1 target...
INFO: From Compiling tensorflow/core/kernels/sparse_xent_op_gpu.cu.cc:
external/eigen_archive/unsupported/Eigen/CXX11/src/Tensor/TensorBroadcasting.h(275): internal error: assertion failed at: "/dvs/p4/build/sw/rel/gpu_drv/r361/r361_00/drivers/compiler/edg/EDG_4.10/src/folding.c", line 9819
1 catastrophic error detected in the compilation of "/tmp/tmpxft_000027e8_00000000-9_sparse_xent_op_gpu.cu.compute_61.cpp1.ii".
Compilation aborted.
Aborted
ERROR: /home/ubuntu/src/tensorflow-0.12.1/tensorflow/core/kernels/BUILD:2018:1: output 'tensorflow/core/kernels/_objs/sparse_xent_op_gpu/tensorflow/core/kernels/sparse_xent_op_gpu.cu.pic.o' was not created.
ERROR: /home/ubuntu/src/tensorflow-0.12.1/tensorflow/core/kernels/BUILD:2018:1: not all outputs were created or valid.
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 6.765s, Critical Path: 5.98s
(This is from a repeated run of bazel, the original run took hours, but the error is always the same on sparse_xent_op_gpu)
The same error also happens when trying tensorflow’s master branch and/or 1.0 pre-releases.
A similar issue seems to happen with CUDA8 on darwin, blocking tensorflow compilation with the same error.