当前位置:网站首页>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 .
边栏推荐
- Install the pit that the electron has stepped on
- TP5 automatic registration hook mechanism hook extension, with a complete case
- Will the memory of ParticleSystem be affected by maxparticles
- In yolov5, denselayer is used to replace focus, and the FPN structure is changed to bi FPN
- Ka! Why does the seat belt suddenly fail to pull? After reading these pictures, I can't stop wearing them
- Three layer switching ①
- How to view the computing power of GPU?
- Trading software programming
- Description of setting items of Jerry [chapter]
- Mobile phone battery - current market situation and future development trend
猜你喜欢

String hash, find the string hash value after deleting any character, double hash

Luogu p1309 Swiss wheel

Introduction to Tianchi news recommendation: 4 Characteristic Engineering

Huawei cloud micro certification Huawei cloud computing service practice has been stable

Small program graduation design is based on wechat order takeout small program graduation design opening report function reference

【.NET+MQTT】. Net6 environment to achieve mqtt communication, as well as bilateral message subscription and publishing code demonstration of server and client

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

In the process of seeking human intelligent AI, meta bet on self supervised learning

How to use AHAS to ensure the stability of Web services?

Maximum entropy model
随机推荐
Customize redistemplate tool class
Avoid playing with super high conversion rate in material minefields
Related configuration commands of Huawei rip
Small program graduation design is based on wechat order takeout small program graduation design opening report function reference
Huawei cloud micro certification Huawei cloud computing service practice has been stable
Huawei cloud micro certification Huawei cloud computing service practice has been stable
7.1 learning content
Yyds dry goods inventory it's not easy to say I love you | use the minimum web API to upload files
Chinese Mitten Crab - current market situation and future development trend
How programmers find girlfriends through blind dates
MySQL statement learning record
Remember a lazy query error
Applet graduation project based on wechat selection voting applet graduation project opening report function reference
Setting function of Jerry's watch management device [chapter]
Fundamentals of machine learning: feature selection with lasso
How to use AHAS to ensure the stability of Web services?
Meta metauniverse female safety problems occur frequently, how to solve the relevant problems in the metauniverse?
What are the advantages and disadvantages of data center agents?
2020-12-02 SSM advanced integration Shang Silicon Valley
Solution of cursor thickening