当前位置:网站首页>Install cuda+cusp environment and create the first helloword starter project

Install cuda+cusp environment and create the first helloword starter project

2022-06-13 07:45:00 Xiao Feng, senior student, big bang

Catalog

install CUDA Environmental Science

It's common to report mistakes

nvcc fatal : Cannot find compiler 'cl.exe' in PATH

CUDA Programming tutorial series

establish HelloWord engineering

cusp Calculation library installation



install CUDA Environmental Science

You can refer to the tutorial : Nanny level CUDA Download, install and use , Detailed environment variable configuration , Not only will you be able to install , It will also teach you to understand why to install like this - You know

You can also refer to the official website :https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html

Installation environment , first Helloword Refer to the following section for the project .


It's common to report mistakes

nvcc fatal : Cannot find compiler 'cl.exe' in PATH

You can refer to this article :https://blog.csdn.net/qq_40993412/article/details/81454531

CUDA Programming tutorial series

Start from scratch ,CUDA The engineering structure is described in detail :

GPU Self taught programming 1 —— introduction _shuzfan The blog of -CSDN Blog

CUDA From introduction to Mastery Course :

【CUDA Development 】CUDA From entry to mastery _Zhang_P_Y The blog of -CSDN Blog _cuda Development


establish HelloWord engineering

The following is the first project creation step in more detail :

1、 open visual studio, New projects , choice cuda

Automatically created “kernel.cu” file , It's a classic Vector addition Of GPU Program , We don't need to , So it will main Code comments in functions . Then add your own code :

#include <iostream>

__global__  void mkernel(void){}

int main()
{
    mkernel <<<1,1>>>();
    std::cout<<"Hello, World!"<<std::endl;
    system("pause");
    return 0;
}

And then run , You get the result

  Specific structure analysis , You can see it 《GPU Self taught programming 》 series .

cusp Calculation library installation

Some students will also use cusp library , Because it's just a library file , Therefore, there is no need to compile , Easy to install .

Official website :CUSP: Quick Start Guide (cusplibrary.github.io)

First, according to the first section above “ install CUDA Environmental Science ” Complete the environment installation .

Download the source code :

Official warehouse , Pay attention to use develop Branch , Otherwise, when cuda Greater than version 9 after , Error will be reported in compilation :cusplibrary/cusplibrary: CUSP : A C++ Templated Sparse Matrix Library (github.com)https://github.com/cusplibrary/cusplibrary

Pay attention to the direct selection “code - download ZIP”!!!

When the download is complete , Refer to official documentation , take cusp Put the folder in :

  My computer win11 The path is :C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7\include

  Then you can refer to the above “ establish HelloWord engineering ” section , Reference in project , No need for extra operation :

#include <cusp/coo_matrix.h>
#include <cusp/csr_matrix.h>
#include <cusp/dia_matrix.h>
#include <cusp/ell_matrix.h>
#include <cusp/hyb_matrix.h>
#include <cusp/print.h>
#include <cusp/io/matrix_market.h>
#include <iostream>
#include <cusp/array1d.h>
#include <cusp/array2d.h>
#include <cusp/multiply.h>
#include <chrono>

It's common to report mistakes

thrust blocking.h No such file or directory

Try to lower cuda Try the version , Put on a cuda toolkit 10, And then up there cusp choice cuda10 Branch .

CUDA Toolkit 10.0 Archive | NVIDIA Developer

原网站

版权声明
本文为[Xiao Feng, senior student, big bang]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/164/202206130738403921.html