Так что это была ошибка Intellisense. Если бы у вас был установлен уровень детализации, вы бы увидели фактическую ошибку от nvcc

ько начал изучать немного CUDA, и я столкнулся с этой ошибкой в ​​следующей строке, в выражении <<< >>>

#include "kernels.h"
#include "helpers.h"
#include <iostream>
#include <cmath>
#include <cuda_runtime.h>
#include <device_launch_parameters.h>
__global__
void blur(unsigned char* input_image, unsigned char* output_image, int width, int height) {

    const unsigned int offset = blockIdx.x*blockDim.x + threadIdx.x;
    int x = offset % width;
    int y = (offset - x) / width;
    int fsize = 5; // Filter size
    if (offset < width*height) {

        float output_red = 0;
        float output_green = 0;
        float output_blue = 0;
        int hits = 0;
        for (int ox = -fsize; ox < fsize + 1; ++ox) {
            for (int oy = -fsize; oy < fsize + 1; ++oy) {
                if ((x + ox) > -1 && (x + ox) < width && (y + oy) > -1 && (y + oy) < height) {
                    const int currentoffset = (offset + ox + oy * width) * 3;
                    output_red += input_image[currentoffset];
                    output_green += input_image[currentoffset + 1];
                    output_blue += input_image[currentoffset + 2];
                    hits++;
                }
            }
        }
        output_image[offset * 3] = output_red / hits;
        output_image[offset * 3 + 1] = output_green / hits;
        output_image[offset * 3 + 2] = output_blue / hits;
    }
}


void filter(unsigned char* input_image, unsigned char* output_image, int width, int height) {

    unsigned char* dev_input;
    unsigned char* dev_output;
    getError(cudaMalloc((void**)&dev_input, width*height * 3 * sizeof(unsigned char)));
    getError(cudaMemcpy(dev_input, input_image, width*height * 3 * sizeof(unsigned char), cudaMemcpyHostToDevice));

    getError(cudaMalloc((void**)&dev_output, width*height * 3 * sizeof(unsigned char)));

    dim3 blockDims(512, 1, 1);
    dim3 gridDims((unsigned int)ceil((double)(width*height * 3 / blockDims.x)), 1, 1);

    blur <<< gridDims, blockDims >>>(dev_input, dev_output, width, height);


    getError(cudaMemcpy(output_image, dev_output, width*height * 3 * sizeof(unsigned char), cudaMemcpyDeviceToHost));

    getError(cudaFree(dev_input));
    getError(cudaFree(dev_output));
}

в

blur <<< gridDims, blockDims >>>(dev_input, dev_output, width, height);

В третьей строке в этой строке я вижу ошибку из заголовка, и из-за этого я не могу скомпилировать код (другие люди говорили, что это ошибка Intellisense, но для других людей программа компилируется, а моя нет). «т).

Я также получаю эту ошибку, когда я пытаюсь скомпилировать

Severity    Code    Description Project File    Line    Suppression State
Error   MSB3721 The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\bin\nvcc.exe" -gencode=arch=compute_30,code=\"sm_30,compute_30\" --use-local-env --cl-version 2017 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.12.25827\bin\HostX86\x64" -x cu  -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.1\include"  -G   --keep-dir x64\Debug -maxrregcount=0  --machine 64 --compile -cudart static  -g   -DWIN32 -DWIN64 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /FS /Zi /RTC1 /MDd " -o x64\Debug\kernel.cu.obj "C:\Users\Artyomska\Documents\Visual Studio 2017\Projects\ScreenFilter\ScreenFilter\kernel.cu"" exited with code 1. ScreenFilter    C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\BuildCustomizations\CUDA 9.1.targets    707 

Я пытаюсь запустить программу в Windows 10, Visual Studio 2017 (последняя версия, с установленным инструментарием для поддержки 15.4, поэтому я не получаю сообщение о несовместимой версии). Я попытался переустановить CUDA 9.1.85, VS2017 и создать новый проект. Я добавил пути в зависимости и библиотеки в набор инструментов NVIDIA, и этот код присутствует в файле .cu.

Проблема в том, что даже если я создаю новый проект, ничего не меняя и не позволяя kernel.cu заполнить его настройками по умолчанию, он все равно имеет ошибку выражения в строке <<< >>>.

Что я должен сделать, чтобы решить это? Спасибо.

Ответы на вопрос(1)

Ваш ответ на вопрос