[cfe-users] How to tell Clang which version of CUDA to use ?

Jean-Loup Tastet via cfe-users cfe-users at lists.llvm.org
Tue Aug 29 00:49:27 PDT 2017


As a workaround, we have temporarily disabled the CUDA 9.0 install (by
renaming its directory to /usr/local/_cuda-9.0). Now the program
compiles as expected (I also recompiled Clang in the meantime).

As soon as I manage to convince my sysadmin to enable CUDA 9.0 again, I
will retry with the `-v` command-line option and post the output here.

On Mon, 2017-08-28 at 11:42 -0700, Justin Lebar wrote:
> --cuda-path is the right flag to pass.  Strange it's not doing the
> right thing for you.
> 
> Can you include the output of running the same command line with -v?
> 
> On Fri, Aug 18, 2017 at 3:55 AM, Jean-Loup Tastet via cfe-users
> <cfe-users at lists.llvm.org> wrote:
> > Hi,
> > 
> > I am trying to use Clang to compile CUDA device code. I followed
> > the
> > instructions in [1] and compiled the latest Clang trunk [2].
> > 
> > However, my system has both CUDA 8.0 and 9.0 RC installed, in
> > `/usr/local/cuda-{8.0,9.0}`. The default `/usr/local/cuda` is
> > symlinked
> > to `/usr/local/cuda-8.0`.
> > 
> > Clang only supports version 8.0, however it seems to incorrectly
> > pick
> > version 9.0, even when manually specifying the `--cuda-path`. For
> > instance, trying to compile a trivial CUDA program (with no
> > kernel):
> > ```
> > $ cat main.cu
> > #include <cuda.h>
> > #include <iostream>
> > 
> > int main(int argc, char* argv[])
> > {
> >     std::cout << "Hello, World!" << std::endl;
> > }
> > 
> > $ clang++ -o main main.cu \
> >     --cuda-path=/usr/local/cuda-8.0 \
> >     -I/usr/local/cuda-8.0/include \
> >     -L/usr/local/cuda-8.0/lib64 \
> >     -lcudart_static -ldl -lrt -pthread
> > ```
> > generates the following error:
> > ```
> > /home/jtastet/.local/stow/llvm_gcc-
> > 6.3/lib/clang/6.0.0/include/__clang_cuda_runtime_wrapper.h:66:2:
> > error:
> > "Unsupported CUDA version!"
> > #error "Unsupported CUDA version!"
> >  ^
> > In file included from <built-in>:1:
> > In file included from /home/jtastet/.local/stow/llvm_gcc-
> > 6.3/lib/clang/6.0.0/include/__clang_cuda_runtime_wrapper.h:169:
> > /usr/local/cuda-9.0/targets/x86_64-
> > linux/include/device_functions.hpp:218:10: error: reference to
> > __device__ function '__nvvm_bar0_popc' in __host__ function
> >   return __nvvm_bar0_popc(predicate);
> >          ^
> > /usr/local/cuda-9.0/targets/x86_64-
> > linux/include/device_functions.hpp:218:10: note: '__nvvm_bar0_popc'
> > declared here
> > /usr/local/cuda-9.0/targets/x86_64-
> > linux/include/device_functions.hpp:223:10: error: reference to
> > __device__ function '__nvvm_bar0_and' in __host__ function
> >   return __nvvm_bar0_and(predicate);
> >          ^
> > [...output truncated...]
> > ```
> > Note the reference to CUDA 9.0 in the path.
> > 
> > Do you know how to tell Clang which version of CUDA to use ? Does
> > it
> > have to be specified at compile-time or as a command-line option ?
> > 
> > Uninstalling CUDA 9.0 is not an option here, since I do not have
> > privileged access to the machine.
> > 
> > Thanks in advance for your help !
> > 
> > Best regards,
> > Jean-Loup Tastet
> > 
> > 
> > [1] https://llvm.org/docs/CompileCudaWithLLVM.html
> > [2] For reference, I compiled revision 311091 with the following
> > configuration:
> > ```
> > cmake -G "Unix Makefiles" \
> >     -D CMAKE_INSTALL_PREFIX=/home/jtastet/.local/stow/llvm_gcc-6.3
> > \
> >     -D CMAKE_BUILD_TYPE=Release \
> >     -D
> > GCC_INSTALL_PREFIX=/afs/cern.ch/sw/lcg/external/gcc/6.3/x86_64-
> > centos7 \
> >     ..
> > ```
> > _______________________________________________
> > cfe-users mailing list
> > cfe-users at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20170829/e4104560/attachment.html>


More information about the cfe-users mailing list