Re: [eigen] Tensor Execution on GPUs |
[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]
I'd recommend that you call your source file tanh.cu.cc. If you call it tanh.cc nvcc will most likely assume that it only contains host code, which could explain your linking error.You also need to modify the input and ouput tensor definition to make sure they reside on GPU (at least until we add support for unified virtual memory, see pull request https://bitbucket.org/eigen/eigen/pull-requests/112/added-support-for-unified-virtual-memory/diff):float* in_data;float* out_data;cudaMalloc((void**)(&in_data), 2*4);cudaMalloc((void**)(&out_data), 2*4);Eigen::TensorMap<Eigen::Tensor<float,1> > in(in_data, 2);Eigen::TensorMap<Eigen::Tensor<float,1> > out(out_data, 2);--On Tue, Apr 26, 2016 at 10:34 PM, Graham Neubig <neubig@xxxxxxxxxxx> wrote:Hello,I'm currently trying to use GpuDevice to perform operations on Tensors, but having trouble with compiling the following statements:Eigen::Tensor<float,1> in(2);in[0] = 1.f; in[1] = -2.f;Eigen::Tensor<float,1> out(2);Eigen::CudaStreamDevice stream;Eigen::GpuDevice dev(&stream);out.device(dev) = in.tanh();I've attached a relatively simple example that I think should be working with nvcc, but for some reason I'm getting the following linking error and I wasn't able to figure out what the problem was. Does anything look out of place here?Graham---------------------------------------------------------------nvcc -o test-tanh tanh.cc -I/home/is/neubig/usr/local/eigen -std=c++11 -DEIGEN_USE_GPU/tmp/tmpxft_0000699c_00000000-4_tanh.o: In function `Eigen::TensorDevice<Eigen::Tensor<float, 1, 0, long>, Eigen::GpuDevice>& Eigen::TensorDevice<Eigen::Tensor<float, 1, 0, long>, Eigen::GpuDevice>::operator=<Eigen::TensorCwiseUnaryOp<Eigen::internal::scalar_tanh_op<float>, Eigen::Tensor<float, 1, 0, long> const> >(Eigen::TensorCwiseUnaryOp<Eigen::internal::scalar_tanh_op<float>, Eigen::Tensor<float, 1, 0, long> const> const&)':tanh.cc:(.text._ZN5Eigen12TensorDeviceINS_6TensorIfLi1ELi0ElEENS_9GpuDeviceEEaSINS_18TensorCwiseUnaryOpINS_8internal14scalar_tanh_opIfEEKS2_EEEERS4_RKT_[_ZN5Eigen12TensorDeviceINS_6TensorIfLi1ELi0ElEENS_9GpuDeviceEEaSINS_18TensorCwiseUnaryOpINS_8internal14scalar_tanh_opIfEEKS2_EEEERS4_RKT_]+0x4c): undefined reference to `Eigen::internal::TensorExecutor<Eigen::TensorAssignOp<Eigen::Tensor<float, 1, 0, long>, Eigen::TensorCwiseUnaryOp<Eigen::internal::scalar_tanh_op<float>, Eigen::Tensor<float, 1, 0, long> const> const> const, Eigen::GpuDevice, true>::run(Eigen::TensorAssignOp<Eigen::Tensor<float, 1, 0, long>, Eigen::TensorCwiseUnaryOp<Eigen::internal::scalar_tanh_op<float>, Eigen::Tensor<float, 1, 0, long> const> const> const&, Eigen::GpuDevice const&)'collect2: error: ld returned 1 exit statusMakefile:11: recipe for target 'test-tanh' failedmake: *** [test-tanh] Error 1
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |