Score:0

Cuda Error std::integral

do flag

I am new to cuda programing and after many erors of nvcc final I can install cuda tool kit but I got a eror mesage the output of nvcc

and my code is

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define N 10

__global__ void vector_add(int* a, int* b, int* c) {
    int i = threadIdx.x;
    if (i < N) {
        c[i] = a[i] + b[i];
    }
}

int main() {
    int a[N], b[N], c[N];
    int *dev_a, *dev_b, *dev_c;

    cudaMalloc((void**)&dev_a, N * sizeof(int));
    cudaMalloc((void**)&dev_b, N * sizeof(int));
    cudaMalloc((void**)&dev_c, N * sizeof(int));

    for (int i = 0; i < N; i++) {
        a[i] = -i;
        b[i] = i * i;
    }

    cudaMemcpy(dev_a, a, N * sizeof(int), cudaMemcpyHostToDevice);
    cudaMemcpy(dev_b, b, N * sizeof(int), cudaMemcpyHostToDevice);

    vector_add<<<1, N>>>(dev_a, dev_b, dev_c);

    cudaMemcpy(c, dev_c, N * sizeof(int), cudaMemcpyDeviceToHost);

    for (int i = 0; i < N; i++) {
        printf("\n results of matrix addition %d. element equals to  %d",i+1, c[i]);
    }

    cudaFree(dev_a);
    cudaFree(dev_b);
    cudaFree(dev_c);

    return 0;
}
Esther avatar
es flag
please post error messages as text, not as cut-off screenshots.
cc flag
Nothing wrong with the code. What CUDA version. What are your PATH and LD_LIBRARY_PATH env variables and how/where did you install CUDA. what does gcc --version output. nvcc --version Add info to your original posting.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.