当前位置:网站首页>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 .
边栏推荐
- JVM performance tuning and practical basic theory - medium
- Rearrangement of tag number of cadence OrCAD components and sequence number of schematic page
- Pyinstaller packaging py script warning:lib not found and other related issues
- Stringutils and collectionutils
- Applet graduation design is based on wechat course appointment registration. Applet graduation design opening report function reference
- Jerry's update contact [article]
- Introduction to Tianchi news recommendation: 4 Characteristic Engineering
- Jerry's watch listens to the message notification of the target third-party software and pushes the message to the device [article]
- 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
- Gee: create a new feature and set corresponding attributes
猜你喜欢

Small program graduation project based on wechat video broadcast small program graduation project opening report function reference

Small program graduation project based on wechat e-book small program graduation project opening report function reference

Maximum likelihood method, likelihood function and log likelihood function
![[turn] solve the problem of](/img/c2/368582a8ed26254409fe391899ba41.jpg)
[turn] solve the problem of "RSA public key not find" appearing in Navicat premium 15 registration
![The contact data on Jerry's management device supports reading and updating operations [articles]](/img/89/d36e785bd94c2373c34fb95eee3a9c.jpg)
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

Three layer switching ②

How programmers find girlfriends through blind dates

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

Since the "epidemic", we have adhered to the "no closing" of data middle office services
随机推荐
[turn] solve the problem of "RSA public key not find" appearing in Navicat premium 15 registration
be based on. NETCORE development blog project starblog - (14) realize theme switching function
Conditional test, if, case conditional test statements of shell script
Hbuilder link Xiaoyao simulator
Meta metauniverse female safety problems occur frequently. How to solve the related problems in the metauniverse?
Jerry's update contact [article]
51 single chip microcomputer timer 2 is used as serial port
51 MCU external interrupt
Rearrangement of tag number of cadence OrCAD components and sequence number of schematic page
Logical operator, displacement operator
Query efficiency increased by 10 times! Three optimization schemes to help you solve the deep paging problem of MySQL
Feign implements dynamic URL
In the process of seeking human intelligent AI, meta bet on self supervised learning
Huawei cloud micro certification Huawei cloud computing service practice has been stable
Luogu p1309 Swiss wheel
In yolov5, denselayer is used to replace focus, and the FPN structure is changed to bi FPN
Applet graduation project is based on wechat classroom laboratory reservation applet graduation project opening report function reference
MySQL introduction - functions (various function statistics, exercises, details, tables)
Small program graduation project based on wechat video broadcast small program graduation project opening report function reference
Cancer biopsy instruments and kits - market status and future development trends