简体   繁体   中英

CUDA NSight c++11 (Ubuntu 14.04)

I read the CUDA Programming Guide and have looked at a number of links here including the following: Eclipse/Nsight (7.0) and C++11 support

But can't get things to work. I'm using CUDA 7.O and the doc (CUDA Programming Guide, p.187) says that -std=cc++11 is supported for gcc >=4.7 & clang. Running using using gcc 4.8.2 (OS: Ubuntu 14.04) and despite going to Project -> Properties -> NVCC Compiler ->Build Settings -> Preprocessor options (-Xcompiler) and adding -std=c++11 I'm getting all kinds of errors. See patial output from console below (at very bottom see "nullptr" is undefined). I've spent +5hrs looking at and trying a number of suggested solutions and at links the nvidia dev forum and on stackoverflow and have yet to find a resolution. Where do I set the flag properly?

Partial console output:

 1. 15:29:39 **** Build of configuration Debug for project
    Test-Dynamic-Parallelism-ComputeCap5 **** make all Building file:
    ../src/cdpAdvancedQuicksort.cu Invoking: NVCC Compiler
    /usr/local/cuda-7.0/bin/nvcc
    -I"/usr/local/cuda-7.0/samples/6_Advanced" -I"/usr/local/cuda-7.0/samples/common/inc" -G -g -O0 -v -Xcompiler -fPIC -Xcompiler -std=c++11 -gencode arch=compute_50,code=sm_50 -odir "src" -M -o "src/cdpAdvancedQuicksort.d" "../src/cdpAdvancedQuicksort.cu"
    #$ _SPACE_=
    #$ _CUDART_=cudart
    #$ _HERE_=/usr/local/cuda-7.0/bin
    #$ _THERE_=/usr/local/cuda-7.0/bin
    #$ _TARGET_SIZE_=
    #$ _TARGET_DIR_=
    #$ _TARGET_DIR_=targets/x86_64-linux
    #$ TOP=/usr/local/cuda-7.0/bin/..
    #$ NVVMIR_LIBRARY_DIR=/usr/local/cuda-7.0/bin/../nvvm/libdevice
    #$ LD_LIBRARY_PATH=/usr/local/cuda-7.0/bin/../lib::/usr/local/cuda-7.0/bin/../lib:/usr/local/cuda-7.0/bin/../lib64
    #$ PATH=/usr/local/cuda-7.0/bin/../open64/bin:/usr/local/cuda-7.0/bin/../nvvm/bin:/usr/local/cuda-7.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/local/cuda-7.0/bin:/usr/local/lib:/usr/local/cuda-7.0/bin
    #$ INCLUDES="-I/usr/local/cuda-7.0/bin/../targets/x86_64-linux/include"
    #$ LIBRARIES= "-L/usr/local/cuda-7.0/bin/../targets/x86_64-linux/lib/stubs"
    "-L/usr/local/cuda-7.0/bin/../targets/x86_64-linux/lib"
    --no_remove_unneeded_entities --debug_mode --device-c --gen_c_file_name "/tmp/tmpxft_00001a46_00000000-4_cdpAdvancedQuicksort.cudafe1.c"
    --stub_file_name "/tmp/tmpxft_00001a46_00000000-4_cdpAdvancedQuicksort.cudafe1.stub.c"
    --gen_device_file_name "/tmp/tmpxft_00001a46_00000000-4_cdpAdvancedQuicksort.cudafe1.gpu"
    --nv_arch "compute_50" --gen_module_id_file --module_id_file_name "/tmp/tmpxft_00001a46_00000000-3_cdpAdvancedQuicksort.module_id"
    --include_file_name "tmpxft_00001a46_00000000-2_cdpAdvancedQuicksort.fatbin.c"
    "/tmp/tmpxft_00001a46_00000000-7_cdpAdvancedQuicksort.cpp1.ii"
    /usr/lib/gcc/x86_64-linux
-gnu/4.8/include/stddef.h(432): error: identifier "nullptr" is undefined 

This is wrong:

-Xcompiler -std=c++11

Just use this, as a switch to nvcc :

-std=c++11

nvcc will handle the necessary upstream switches needed for gcc / g++ .

You can do this "automagically" in the CUDA 7 version of nsight eclipse edition, by going through the following sequence:

Project...Properties...Build (expand sub-menu)...Settings...Tool Settings...NVCC Compiler (expand sub-menu)...Code Generation

and selecting the "Enable C++11 Support" checkbox. (There are other ways, as well, such as just going to the "NVCC Compiler" page and adding the switch manually on "All options")

Here:

nsight EE项目属性页面

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM