当前位置:网站首页>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 .
边栏推荐
- [leetcode daily question] a single element in an ordered array
- Sequence sorting of basic exercises of test questions
- MPLS③
- All ceramic crowns - current market situation and future development trend
- C import Xls data method summary I (upload files and create Workbooks)
- Development of user-defined navigation bar in uniapp
- C library function int fprintf (file *stream, const char *format,...) Send formatted output to stream
- When the watch system of Jerry's is abnormal, it is used to restore the system [chapter]
- Portable two-way radio equipment - current market situation and future development trend
- File contains vulnerability summary
猜你喜欢

Some other configurations on Huawei's spanning tree

Maximum likelihood method, likelihood function and log likelihood function

Openbionics exoskeleton project introduction | bciduino community finishing

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

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

Audio resource settings for U3D resource management

SQL statement

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

GUI application: socket network chat room

I don't care about you. OKR or KPI, PPT is easy for you
随机推荐
ES6 deletes an attribute in all array objects through map, deconstruction and extension operators
All metal crowns - current market situation and future development trend
The latest analysis of hoisting machinery command in 2022 and free examination questions of hoisting machinery command
How to delete MySQL components using xshell7?
Long article review: entropy, free energy, symmetry and dynamics in the brain
[typora installation package] old typera installation package, free version
Stringutils and collectionutils
CLP information - how does the digital transformation of credit business change from star to finger?
Jerry's update contact [article]
When the watch system of Jerry's is abnormal, it is used to restore the system [chapter]
The contact data on Jerry's management device supports reading and updating operations [articles]
AI helps make new breakthroughs in art design plagiarism retrieval! Professor Liu Fang's team paper was employed by ACM mm, a multimedia top-level conference
0 basic learning C language - nixie tube dynamic scanning display
Luogu p1309 Swiss wheel
I don't know why it can't run in the project and how to change it
How can enterprises optimize the best cost of cloud computing?
Maximum entropy model
A little understanding of GSLB (global server load balance) technology
Solution of cursor thickening
Pratique technique | analyse et solution des défaillances en ligne (Partie 1)