当前位置:网站首页>Write the first CUDA program
Write the first CUDA program
2022-07-04 01:45:00 【naibula】
1. Environmental preparation
Make sure cuda The driver has been installed correctly , Execute the following command to view :
nvidia-smi
There are specific graphics card information display , It indicates that the graphics card and its driver are working normally . If it does not work properly, you can refer to course Installation driver .
2. Source code preparation
The following source code output graphics card support CUDA Program information ,cuda_status Used to judge the status of obtaining information ,cuda_status by 0 Show success .
#include <iostream>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
using namespace std;
int main()
{
int dev = 0;
cudaDeviceProp dev_prop;
cudaError_t cuda_status;
cuda_status = cudaGetDeviceProperties(&dev_prop, dev);
cout << "cuda_status:" << cuda_status << endl;
cout << " Use GPU device " << dev << ": " << dev_prop.name << endl;
cout << "SM The number of :" << dev_prop.multiProcessorCount << endl;
cout << " Shared memory size per thread block :" << dev_prop.sharedMemPerBlock / 1024.0 << " KB" << endl;
cout << " Maximum number of threads per thread block :" << dev_prop.maxThreadsPerBlock << endl;
cout << " Every SM Is the maximum number of threads :" << dev_prop.maxThreadsPerMultiProcessor << endl;
cout << " Every SM The maximum number of thread bundles :" << dev_prop.maxThreadsPerMultiProcessor / 32 << endl;
return 0;
}
3. Compile and run
The above source code is saved in the file GPU_info.cu in , The compile command is as follows :
nvcc GPU_info.cu -o gpu_info
./gpu_info
As shown in the figure below , It is the result of correct execution .
边栏推荐
- 【.NET+MQTT】. Net6 environment to achieve mqtt communication, as well as bilateral message subscription and publishing code demonstration of server and client
- Small program graduation project based on wechat reservation small program graduation project opening report reference
- All ceramic crowns - current market situation and future development trend
- Neo4j learning notes
- The force deduction method summarizes the single elements in the 540 ordered array
- Force deduction solution summary 1189- maximum number of "balloons"
- Small program graduation project based on wechat video broadcast small program graduation project opening report function reference
- Huawei cloud micro certification Huawei cloud computing service practice has been stable
- MySQL utilise la vue pour signaler les erreurs, Explicit / show ne peut pas être publié; Verrouillage des fichiers privés pour la table sous - jacente
- Feign implements dynamic URL
猜你喜欢

I don't care about you. OKR or KPI, PPT is easy for you

Bacteriostatic circle scanning correction template

Applet graduation project based on wechat selection voting applet graduation project opening report function reference

Will the memory of ParticleSystem be affected by maxparticles

What is the student party's Bluetooth headset recommendation? Student party easy to use Bluetooth headset recommended

Douban scoring applet Part-3

Small program graduation project based on wechat reservation small program graduation project opening report reference

CLP information - how does the digital transformation of credit business change from star to finger?

1189. Maximum number of "balloons"

MySQL introduction - functions (various function statistics, exercises, details, tables)
随机推荐
CLP information - how does the digital transformation of credit business change from star to finger?
Why is the operation unsuccessful (unresolved) uncaught syntaxerror: invalid or unexpected token (resolved)
Software product download collection
TP5 automatic registration hook mechanism hook extension, with a complete case
Winter vacation daily question -- a single element in an ordered array
[leetcode daily question] a single element in an ordered array
Portable two-way radio equipment - current market situation and future development trend
Cancer biopsy instruments and kits - market status and future development trends
Customize redistemplate tool class
How programmers find girlfriends through blind dates
How to delete MySQL components using xshell7?
ThinkPHP uses redis to update database tables
Should enterprises start building progressive web applications?
Human resource management online assignment
Hbuilder link Xiaoyao simulator
MySQL uses the view to report an error, explain/show can not be issued; lacking privileges for underlying table
SRCNN:Learning a Deep Convolutional Network for Image Super-Resolution
Three layer switching ②
Magical usage of edge browser (highly recommended by program ape and student party)
Jerry's update contact [article]