Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot compile against CUDA 9.1 on Ubuntu 18.04 #279

Closed
TysonRayJones opened this issue Jun 5, 2019 · 4 comments
Closed

Cannot compile against CUDA 9.1 on Ubuntu 18.04 #279

TysonRayJones opened this issue Jun 5, 2019 · 4 comments

Comments

@TysonRayJones
Copy link

Hi,

I'm trying to compile a simple example:

// demo.cpp

#include "viennacl/matrix.hpp"

int main(int argc, char* argv[]) {
    viennacl::matrix<double>  vcl_matrix(4, 5);
    vcl_matrix(0,2) = 1.0;
    return 0;
}

with command

nvcc -DVIENNACL_WITH_CUDA -IViennaCL demo.cpp

and file structure ViennaCL/viennacl/matrix.hpp (etc).

This causes a pretty huge error I've pasted into this pastebin, which begins with:

In file included from ViennaCL/viennacl/linalg/scalar_operations.hpp:40:0,
                 from ViennaCL/viennacl/scalar.hpp:30,
                 from ViennaCL/viennacl/tools/entry_proxy.hpp:27,
                 from ViennaCL/viennacl/detail/matrix_def.hpp:26,
                 from ViennaCL/viennacl/matrix.hpp:26,
                 from quest_viennacl.cpp:3:
ViennaCL/viennacl/linalg/cuda/scalar_operations.hpp: In function ‘typename viennacl::enable_if<((viennacl::is_scalar<T>::value && viennacl::is_scalar<ScalarT2>::value) && viennacl::is_any_scalar<FactorT>::value)>::type viennacl::linalg::cuda::as(ScalarT1&, const ScalarT2&, const NumericT&, viennacl::vcl_size_t, bool, bool)’:
ViennaCL/viennacl/linalg/cuda/scalar_operations.hpp:88:14: error: expected primary-expression before ‘<’ token
   as_kernel<<<1, 1>>>(viennacl::cuda_arg(s1),
              ^
ViennaCL/viennacl/linalg/cuda/scalar_operations.hpp:88:21: error: expected primary-expression before ‘>’ token
   as_kernel<<<1, 1>>>(viennacl::cuda_arg(s1),

I take it the CUDA syntax isn't being recognised. This seems specific to ViennaCL, since I CUDA compile other projects (e.g. QuEST) without issue on this system.

Is ViennaCL incompatible with CUDA 9.1? I'm compiling for a Quadro P6000 with computability 6.1, so need to use at least CUDA 8.0.
Is there any way I can make this work?

@TysonRayJones
Copy link
Author

(Note the same code compiles with CUDA 9.2 on MacOS 10.14 - perhaps this is a Ubuntu-specific issue)

@karlrupp
Copy link
Collaborator

karlrupp commented Jun 6, 2019

You need to name your source file with extension .cu to make nvcc interpret the CUDA code correctly. Then, calling nvcc -DVIENNACL_WITH_CUDA -IViennaCL demo.cu should succeed.

@karlrupp
Copy link
Collaborator

karlrupp commented Jun 6, 2019

An alternative is to pass -x cu to nvcc: https://stackoverflow.com/questions/26208784/cuda-cpp-files

@TysonRayJones
Copy link
Author

Right you are - it's curious this wasn't needed on MacOS. Thanks very much for the prompt help (and for your work on a fantastic library)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants