lukeiwanski / tensorflow

OpenCL support for TensorFlow via SYCL
Apache License 2.0
65 stars 14 forks source link

Issue compiling tensorflow with SYCL [Anaconda] #176

Closed rahasayantan closed 6 years ago

rahasayantan commented 7 years ago

System information

Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No

OS Platform and Distribution (e.g., Linux Ubuntu):14.04.3-->Trusty

TensorFlow installed from (source or binary):Source

TensorFlow version (use command below):1.0 (Steps-> Downloaded tensorflow from https://github.com/benoitsteiner/tensorflow-opencl, ./configure - to configure project)

Bazel version (if compiling from source):0.5.4

CUDA/cuDNN version:NA

OPENCL Version: Number of platforms: 1 Platform Profile: FULL_PROFILE Platform Version: OpenCL 2.0 AMD-APP (1800.11) Platform Name: AMD Accelerated Parallel Processing Platform Vendor: Advanced Micro Devices, Inc. Platform Extensions: cl_khr_icd cl_amd_event_callback cl_amd_offline_devices

GPU model and memory: Platform Name: AMD Accelerated Parallel Processing Number of devices: 2 Device Type: CL_DEVICE_TYPE_GPU Board name: AMD Radeon (TM) R5 M335 Memory: 4096M

Exact command to reproduce: run the python script -- ipython keras_code.py

G++/GCC version: g++-4.8

I have compiled CPP programs, they work fine.

ComputeCPP: 0.3.4 -- Python: I am using Anaconda distribution Python for 2.7.2. (Anaconda - 2.4.3)

Describe the problem:

I have tried installing as per the steps given in : https://www.codeplay.com/portal/03-30-17-setting-up-tensorflow-with-opencl-using-sycl

I have cloned the following git Repo: git clone https://github.com/benoitsteiner/tensorflow-opencl.git

Everything works fine till the compile step: I use the following command: bazel build --local_resources 2048,.5,1.0 -c opt --config=sycl //tensorflow/tools/pip_package:build_pip_package

================

Error

ERROR: /home/sayantan/Downloads/tensorflow-opencl/tensorflow/core/kernels/BUILD:2512:1: C++ compilation of rule '//tensorflow/core/kernels:softmax_op' failed (Exit 1). In file included from tensorflow/core/kernels/softmax_op.cc:20: In file included from ./tensorflow/core/kernels/softmax_op.h:23: In file included from ./third_party/eigen3/unsupported/Eigen/CXX11/Tensor:4: In file included from external/eigen_archive/unsupported/Eigen/CXX11/Tensor:14: In file included from external/eigen_archive/Eigen/Core:299: In file included from external/local_config_sycl/crosstool/../sycl/include/SYCL/sycl.hpp:20: In file included from external/local_config_sycl/crosstool/../sycl/include/SYCL/sycl_interface.h:54: external/local_config_sycl/crosstool/../sycl/include/SYCL/multi_pointer.h:342:3: error: multiple overloads of 'global_ptr' instantiate to the same signature 'void (pointer_t)' (aka 'void (attribute((address_space(1))) float *)') global_ptr(pointer_t ptr) : Base(ptr) {} ^ external/eigen_archive/unsupported/Eigen/CXX11/src/Tensor/TensorSyclExprConstructor.h:42:74: note: in instantiation of template class 'cl::sycl::global_ptr<attribute((address_space(1))) float>' requested here EvalToLHSConstructor(const utility::tuple::Tuple &t) : expr(ConvertToActualTypeSycl(typename Eigen::internal::remove_all::type, utility::tuple::get(t))) {} ^ external/eigen_archive/unsupported/Eigen/CXX11/src/Tensor/TensorDeviceSycl.h:31:88: note: expanded from macro 'ConvertToActualTypeSycl'

define ConvertToActualTypeSycl(Scalar, buf_acc) reinterpret_cast<typename cl::sycl::global_ptr::pointer_t>((&(*buf_acc.get_pointer())))

                                                                                   ^

external/eigen_archive/unsupported/Eigen/CXX11/src/Tensor/TensorSyclExprConstructor.h:226:1: note: in instantiation of member function 'Eigen::TensorSycl::internal::EvalToLHSConstructor<attribute((address_space(1))) float *, 0, cl::sycl::accessor<unsigned char, 1, cl::sycl::access::mode::write, cl::sycl::access::target::global_buffer, cl::sycl::codeplay::access::placeholder::false_t>, cl::sycl::accessor<unsigned char, 1, cl::sycl::access::mode::read, cl::sycl::access::target::global_buffer, cl::sycl::codeplay::access::placeholder::false_t> >::EvalToLHSConstructor' requested here EVALTO(const) ^ external/eigen_archive/unsupported/Eigen/CXX11/src/Tensor/TensorSyclExprConstructor.h:223:41: note: expanded from macro 'EVALTO' : nestedExpression(funcD.xprExpr, t), buffer(t), expr(buffer.expr, nestedExpression.expr) {}\ ^ external/eigen_archive/unsupported/Eigen/CXX11/src/Tensor/TensorSyclExprConstructor.h:506:10: note: in instantiation of function template specialization 'Eigen::TensorSycl::internal::ExprConstructor<const Eigen::TensorEvalToOp<const Eigen::TensorReductionOp<Eigen::internal::MaxReducer, const Eigen::IndexList<Eigen::type2index<1>>, const Eigen::TensorMap<Eigen::Tensor<const float, 2, 1, long>, 16, MakeGlobalPointer>, MakeGlobalPointer>, MakeGlobalPointer>, const Eigen::TensorEvalToOp<const Eigen::TensorSycl::internal::PlaceHolder<const Eigen::TensorReductionOp<Eigen::internal::MaxReducer, const Eigen::IndexList<Eigen::type2index<1>>, const Eigen::TensorMap<Eigen::Tensor<const float, 2, 1, long>, 16, MakePointer>, MakePointer>, 1>, MakePointer>, cl::sycl::accessor<unsigned char, 1, cl::sycl::access::mode::write, cl::sycl::access::target::global_buffer, cl::sycl::codeplay::access::placeholder::false_t>, cl::sycl::accessor<unsigned char, 1, cl::sycl::access::mode::read, cl::sycl::access::target::global_buffer, cl::sycl::codeplay::access::placeholder::false_t> >::ExprConstructor<Eigen::TensorSycl::internal::FunctorExtractor<Eigen::TensorEvaluator<const Eigen::TensorEvalToOp<const Eigen::TensorReductionOp<Eigen::internal::MaxReducer, const Eigen::IndexList<Eigen::type2index<1>>, const Eigen::TensorMap<Eigen::Tensor<const float, 2, 1, long>, 16, MakePointer>, MakePointer>, MakePointer>, const Eigen::SyclDevice> > >' requested here return ExprConstructor<OrigExpr, IndexExpr, Params...>(funcD, t); .....

2 errors generated. Target //tensorflow/tools/pip_package:build_pip_package failed to build Use --verbose_failures to see the command lines of failed build steps. INFO: Elapsed time: 3715.231s, Critical Path: 167.06s

Can you please help?

Thanks and regards Sayantan Raha

lukeiwanski commented 7 years ago

Hi @rahasayantan

Thanks for the report. That issue is already solved in Eigen (https://bitbucket.org/eigen/eigen/commits/2f4e408134e6bf7257f3526ece63a20dda03173d). TensorFlow upstream needs to bump used Eigen version to cover that. https://github.com/lukeiwanski/tensorflow/tree/dev/amd_gpu should compile fine. I am in process of creating pull request for that.. however testing takes a while.

Hope that helps

rahasayantan commented 7 years ago

I cloned from the repo you mentioned above. and changed brance to AMD_GPU. When I compile, i get the following error.

INFO: Found 1 target... ERROR: /home/sayantan/Downloads/tensorflow/tensorflow/contrib/memory_stats/BUILD:17:1: C++ compilation of rule '//tensorflow/contrib/memory_stats:python/ops/_memory_stats_ops.so' failed (Exit 1). tensorflow/contrib/memory_stats/kernels/memory_stats_ops.cc:62:63: error: unknown type name 'MaxBytesInUseOp'; did you mean 'BytesInUseOp'? Name("BytesInUse").Device(DEVICE_SYCL).HostMemory("out"), MaxBytesInUseOp); ^~~~~~~ BytesInUseOp ./tensorflow/core/framework/op_kernel.h:1209:68: note: expanded from macro 'REGISTER_KERNEL_BUILDER' REGISTER_KERNEL_BUILDER_UNIQ_HELPER(COUNTER, kernel_builder, VA_ARGS__) ^ ./tensorflow/core/framework/op_kernel.h:1212:53: note: expanded from macro 'REGISTER_KERNEL_BUILDER_UNIQ_HELPER' REGISTER_KERNEL_BUILDER_UNIQ(ctr, kernel_builder, VA_ARGS) ^ ./tensorflow/core/framework/op_kernel.h:1225:24: note: expanded from macro 'REGISTER_KERNEL_BUILDER_UNIQ' return new VA_ARGS__(context); \ ^ tensorflow/contrib/memory_stats/kernels/memory_stats_ops.cc:44:7: note: 'BytesInUseOp' declared here class BytesInUseOp : public MemoryStatsOp { ^ 1 error generated. Target //tensorflow/tools/pip_package:build_pip_package failed to build

Thanks and regards Sayantan

lukeiwanski commented 7 years ago

Is the same happening on: https://github.com/lukeiwanski/tensorflow/commit/facc653661127d73d73b1eed8de7dd26bd740e1e ?

rahasayantan commented 7 years ago

I could not find those commits in the tensorflow-opencl projects. I found them when I clones from the tensorflow project. but then I have the following error. Actually I have always faced the problem of compiling protobuf from the root packages.. I think i have similar error..

I am getting the following error.. I guess I am missing some dependencies.. can you please help..

INFO: Found 1 target... ERROR: /home/sayantan/Downloads/tensorflow/tensorflow/python/BUILD:4458:1: undeclared inclusion(s) in rule '//tensorflow/python:framework/fast_tensor_util.so': this rule is missing dependency declarations for the following files included by 'tensorflow/python/framework/fast_tensor_util.cpp': '/home/sayantan/anaconda2/include/python2.7/Python.h' '/home/sayantan/anaconda2/include/python2.7/patchlevel.h' '/home/sayantan/anaconda2/include/python2.7/pyconfig.h' '/home/sayantan/anaconda2/include/python2.7/pymacconfig.h' '/home/sayantan/anaconda2/include/python2.7/pyport.h' '/home/sayantan/anaconda2/include/python2.7/pymath.h' '/home/sayantan/anaconda2/include/python2.7/pymem.h' '/home/sayantan/anaconda2/include/python2.7/object.h' '/home/sayantan/anaconda2/include/python2.7/objimpl.h' '/home/sayantan/anaconda2/include/python2.7/pydebug.h' '/home/sayantan/anaconda2/include/python2.7/unicodeobject.h' '/home/sayantan/anaconda2/include/python2.7/intobject.h' '/home/sayantan/anaconda2/include/python2.7/boolobject.h' '/home/sayantan/anaconda2/include/python2.7/longobject.h' '/home/sayantan/anaconda2/include/python2.7/floatobject.h' '/home/sayantan/anaconda2/include/python2.7/complexobject.h' '/home/sayantan/anaconda2/include/python2.7/rangeobject.h' '/home/sayantan/anaconda2/include/python2.7/stringobject.h' '/home/sayantan/anaconda2/include/python2.7/memoryobject.h' '/home/sayantan/anaconda2/include/python2.7/bufferobject.h' '/home/sayantan/anaconda2/include/python2.7/bytesobject.h' '/home/sayantan/anaconda2/include/python2.7/bytearrayobject.h' '/home/sayantan/anaconda2/include/python2.7/tupleobject.h' '/home/sayantan/anaconda2/include/python2.7/listobject.h' '/home/sayantan/anaconda2/include/python2.7/dictobject.h' '/home/sayantan/anaconda2/include/python2.7/enumobject.h' '/home/sayantan/anaconda2/include/python2.7/setobject.h' '/home/sayantan/anaconda2/include/python2.7/methodobject.h' '/home/sayantan/anaconda2/include/python2.7/moduleobject.h' '/home/sayantan/anaconda2/include/python2.7/funcobject.h' '/home/sayantan/anaconda2/include/python2.7/classobject.h' '/home/sayantan/anaconda2/include/python2.7/fileobject.h' '/home/sayantan/anaconda2/include/python2.7/cobject.h' '/home/sayantan/anaconda2/include/python2.7/pycapsule.h' '/home/sayantan/anaconda2/include/python2.7/traceback.h' '/home/sayantan/anaconda2/include/python2.7/sliceobject.h' '/home/sayantan/anaconda2/include/python2.7/cellobject.h' '/home/sayantan/anaconda2/include/python2.7/iterobject.h' '/home/sayantan/anaconda2/include/python2.7/genobject.h' '/home/sayantan/anaconda2/include/python2.7/descrobject.h' '/home/sayantan/anaconda2/include/python2.7/warnings.h' '/home/sayantan/anaconda2/include/python2.7/weakrefobject.h' '/home/sayantan/anaconda2/include/python2.7/codecs.h' '/home/sayantan/anaconda2/include/python2.7/pyerrors.h' '/home/sayantan/anaconda2/include/python2.7/pystate.h' '/home/sayantan/anaconda2/include/python2.7/pyarena.h' '/home/sayantan/anaconda2/include/python2.7/modsupport.h' '/home/sayantan/anaconda2/include/python2.7/pythonrun.h' '/home/sayantan/anaconda2/include/python2.7/ceval.h' '/home/sayantan/anaconda2/include/python2.7/sysmodule.h' '/home/sayantan/anaconda2/include/python2.7/intrcheck.h' '/home/sayantan/anaconda2/include/python2.7/import.h' '/home/sayantan/anaconda2/include/python2.7/abstract.h' '/home/sayantan/anaconda2/include/python2.7/compile.h' '/home/sayantan/anaconda2/include/python2.7/code.h' '/home/sayantan/anaconda2/include/python2.7/eval.h' '/home/sayantan/anaconda2/include/python2.7/pyctype.h' '/home/sayantan/anaconda2/include/python2.7/pystrtod.h' '/home/sayantan/anaconda2/include/python2.7/pystrcmp.h' '/home/sayantan/anaconda2/include/python2.7/dtoa.h' '/home/sayantan/anaconda2/include/python2.7/pyfpe.h' '/home/sayantan/anaconda2/include/python2.7/longintrepr.h' '/home/sayantan/anaconda2/include/python2.7/frameobject.h' '/home/sayantan/anaconda2/include/python2.7/compile.h' '/home/sayantan/anaconda2/include/python2.7/traceback.h'. In file included from /home/sayantan/anaconda2/lib/python2.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1809:0, from /home/sayantan/anaconda2/lib/python2.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:18, from /home/sayantan/anaconda2/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h:4, from bazel-out/local_linux-opt/genfiles/tensorflow/python/framework/fast_tensor_util.cpp:531: /home/sayantan/anaconda2/lib/python2.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]

warning "Using deprecated NumPy API, disable it by " \

^ cc1plus: warning: unrecognized command line option "-Wno-unused-command-line-argument" cc1plus: warning: unrecognized command line option "-Wno-unused-const-variable" Target //tensorflow/tools/pip_package:build_pip_package failed to build Use --verbose_failures to see the command lines of failed build steps.

lukeiwanski commented 6 years ago

It seems like environment set ups issue.. did you run ./configure ? Similarly looking issue here: https://github.com/tensorflow/tensorflow/issues/4851

lukeiwanski commented 6 years ago

If the issue still persist have a look at this: https://github.com/lukeiwanski/tensorflow/issues/193#issuecomment-354729010

otherwise, can this issue be closed?

jacogasp commented 6 years ago

@lukeiwanski thanks, worked for me