rsnt_translations
56,430
edits
m (Updated broken link to CUDA Home Page) |
No edit summary |
||
Line 22: | Line 22: | ||
<!--T:42--> | <!--T:42--> | ||
The following program will add two numbers together on a GPU. Save the file as <code>add.cu</code>. | The following program will add two numbers together on a GPU. Save the file as <code>add.cu</code>. <i>The <code>cu</code> file extension is important!</i>. | ||
</translate> | </translate> | ||
Line 69: | Line 69: | ||
=== Submitting jobs=== <!--T:44--> | === Submitting jobs=== <!--T:44--> | ||
To run the program, create a Slurm job script as shown below. Be sure to replace <code>def-someuser</code> with your specific account (see [[Running_jobs#Accounts_and_projects| | To run the program, create a Slurm job script as shown below. Be sure to replace <code>def-someuser</code> with your specific account (see [[Running_jobs#Accounts_and_projects|Accounts and projects]]). For options relating to scheduling jobs with GPUs see [[Using GPUs with Slurm]]. | ||
{{File | {{File | ||
|name=gpu_job.sh | |name=gpu_job.sh | ||
Line 83: | Line 83: | ||
<!--T:45--> | <!--T:45--> | ||
Submit your GPU job to the scheduler with | Submit your GPU job to the scheduler with | ||
<source lang="console"> | <source lang="console"> | ||
$ sbatch gpu_job.sh | $ sbatch gpu_job.sh | ||
Submitted batch job 3127733 | Submitted batch job 3127733 | ||
</source>For more information about the <code>sbatch</code> command and running and monitoring jobs see [[Running jobs]]. | </source>For more information about the <code>sbatch</code> command and running and monitoring jobs, see [[Running jobs]]. | ||
<!--T:46--> | <!--T:46--> | ||
Line 95: | Line 95: | ||
2+7=9 | 2+7=9 | ||
</source> | </source> | ||
If you run this without a GPU present you might see output like <code>2+7=0</code>. | If you run this without a GPU present, you might see output like <code>2+7=0</code>. | ||
=== Linking libraries === <!--T:48--> | === Linking libraries === <!--T:48--> | ||
Line 104: | Line 104: | ||
<!--T:47--> | <!--T:47--> | ||
To learn more about how the above program works and how to make the use of | To learn more about how the above program works and how to make the use of GPU parallelism, see [[CUDA tutorial]]. | ||
== Troubleshooting == <!--T:49--> | == Troubleshooting == <!--T:49--> | ||
=== | === Compute capability === <!--T:50--> | ||
<!--T:51--> | <!--T:51--> | ||
NVidia has created | NVidia has created this technical term, which they describe as follows: | ||
<!--T:52--> | <!--T:52--> | ||
<blockquote> | <blockquote> | ||
The | The <i>compute capability</i> of a device is represented by a version number, also sometimes called its "SM version". This version number identifies the features supported by the GPU hardware and is used by applications at runtime to determine which hardware features and/or instructions are available on the present GPU." ([https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#compute-capability CUDA Toolkit Documentation, section 2.6]) | ||
</blockquote> | </blockquote> | ||
<!--T:53--> | <!--T:53--> | ||
The following errors are connected with | The following errors are connected with compute capability: | ||
<!--T:54--> | <!--T:54--> | ||
Line 132: | Line 132: | ||
<!--T:56--> | <!--T:56--> | ||
If you encounter either of these errors, you may be able to fix it by adding the correct | If you encounter either of these errors, you may be able to fix it by adding the correct <i>flag</i> to the <code>nvcc</code> call: | ||
<!--T:57--> | <!--T:57--> | ||
Line 148: | Line 148: | ||
<!--T:60--> | <!--T:60--> | ||
where “XX” is the | where “XX” is the compute capability of the Nvidia GPU that you expect to run the application on. | ||
To find the value to replace “XX“, see the | To find the value to replace “XX“, see the [[Using GPUs with Slurm#Available_GPUs]]Available GPUs table. | ||
<!--T:61--> | <!--T:61--> | ||
<b>For example,</b> if you will run your code on a Narval A100 node, its compute capability is 80. | |||
The correct | The correct flag to use when compiling with <code>nvcc</code> is | ||
<!--T:62--> | <!--T:62--> |