 <?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://Robo.Fish/wiki/index.php?action=history&amp;feed=atom&amp;title=CUDA</id>
	<title>CUDA - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://Robo.Fish/wiki/index.php?action=history&amp;feed=atom&amp;title=CUDA"/>
	<link rel="alternate" type="text/html" href="https://Robo.Fish/wiki/index.php?title=CUDA&amp;action=history"/>
	<updated>2026-04-22T17:27:03Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://Robo.Fish/wiki/index.php?title=CUDA&amp;diff=2849&amp;oldid=prev</id>
		<title>Kai: /* Ubuntu 18.04 */</title>
		<link rel="alternate" type="text/html" href="https://Robo.Fish/wiki/index.php?title=CUDA&amp;diff=2849&amp;oldid=prev"/>
		<updated>2018-05-16T18:58:58Z</updated>

		<summary type="html">&lt;p&gt;&lt;span class=&quot;autocomment&quot;&gt;Ubuntu 18.04&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
=== &amp;lt;br /&amp;gt;Introduction ===&lt;br /&gt;
CUDA is an extension to the C and C++ programming languages plus a runtime environment for managing GPU-based [[Parallel Computing | parallel computing]]. CUDA is developed by Nvidia (https://developer.nvidia.com/cuda-zone) and is currently the most popular hardware-accelerated parallel computing solution in [[Computer Vision | computer vision]] and [[Deep Learning | deep learning]]. CUDA programs run on Nvidia graphics cards (sold to computer gaming enthusiasts) or on Nvidia cards dedicated to parallel computing.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
=== Installing on Ubuntu ===&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Installing Nvidia drivers with &amp;#039;&amp;#039;ubuntu-drivers&amp;#039;&amp;#039; ====&lt;br /&gt;
First, install the &amp;#039;&amp;#039;ubuntu-drivers&amp;#039;&amp;#039; utility:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;terminal&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt install ubuntu-drivers-common&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Check if &amp;#039;&amp;#039;ubuntu-drivers&amp;#039;&amp;#039; reports your Nvidia card:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;terminal&amp;quot;&amp;gt;&lt;br /&gt;
ubuntu-drivers devices&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then install the drivers for the card&lt;br /&gt;
&amp;lt;pre class=&amp;quot;terminal&amp;quot;&amp;gt;&lt;br /&gt;
sudo ubuntu-drivers autoinstall&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
and reboot.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Installing Nvidia drivers manually ====&lt;br /&gt;
First, check if the installed Nvidia driver meets the requirement for the CUDA toolkit version you want to install. For example, CUDA Toolkit 9.x requires the driver version 390. To install, type&lt;br /&gt;
&amp;lt;pre class=&amp;quot;terminal&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt install nvidia-390 nvidia-settings&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
followed by a restart of your computer. If necessary, you can reconfigure the kernel module with this new driver by typing &lt;br /&gt;
&amp;lt;pre class=&amp;quot;terminal&amp;quot;&amp;gt;&lt;br /&gt;
sudo dpkg-reconfigure nvidia-390&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Ubuntu 16.04 ====&lt;br /&gt;
The Debian package for CUDA development from the Ubuntu/Launchpad repositories is &amp;#039;&amp;#039;&amp;#039;nvidia-cuda-dev&amp;#039;&amp;#039;&amp;#039;. If the version of CUDA included in this package is too old for your graphics card (cards with Pascal architecture require CUDA 8.0) then you can download the CUDA Debian package for the latest version from [https://developer.nvidia.com/cuda-downloads NVIDIA&amp;#039;s CUDA download page]. Install with these terminal commands:&lt;br /&gt;
&amp;lt;pre class=&amp;quot;terminal&amp;quot;&amp;gt;&lt;br /&gt;
sudo dpkg -i cuda-repo-ubuntu1604-xxxxxxxxxx.deb&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install cuda&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The reason for running &amp;#039;&amp;#039;apt-get update&amp;#039;&amp;#039; is that the Debian package does not install CUDA directly. If you downloaded the &amp;#039;&amp;#039;local&amp;#039;&amp;#039; version, it will copy the contained packages into the folder &amp;#039;&amp;#039;/var/cuda-repo-xxx-local&amp;#039;&amp;#039;  and register the folder as a third-party repository (&amp;#039;&amp;#039;/etc/apt/sources.list.d/cuda-xxx-local.list&amp;#039;&amp;#039;).&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
After updating to a new version of CUDA, don&amp;#039;t forget to rebuild all libraries and applications that use and link against CUDA. For example, [[PyTorch]] and [[OpenCV]].&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
==== Ubuntu 18.04 ====&lt;br /&gt;
At the moment there is no officially supported CUDA development kit for Ubuntu 18.04. You can follow these instructions that I fished out from [https://askubuntu.com/questions/1028830/install-cuda-on-ubuntu-18-04/1034093 askubuntu.com], however, to install CUDA 9.1 from the multiverse repository:&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
First, enable the multiverse repository&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
[[Image:Cuda-Ubuntu1804.png|x300px]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Then install Cuda&lt;br /&gt;
&amp;lt;pre class=&amp;quot;terminal&amp;quot;&amp;gt;&lt;br /&gt;
sudo apt install nvidia-cuda-toolkit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
which will also install GCC 6 alongside Ubuntu&amp;#039;s default compiler version GCC 7.3.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
Because you need to use GCC 6 when building a program that uses Cuda 9.1, you should be able to easily switch between GCC versions 7 and 6. Read [[GCC#Switching_between_GCC_versions_in_Ubuntu | Switching between GCC versions in Ubuntu]] to find out how to do this.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Execution Model ===&lt;br /&gt;
* Blocks can contain (up to 1024) threads.&lt;br /&gt;
* Assigning blocks to the available stream multiprocessors (SM) is scheduled by the GPU.&lt;br /&gt;
* Synchronization points (barriers) at which all threads wait until the last thread is finished.&lt;br /&gt;
* Atomic operations for synchronizing memory access across threads.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
=== Memory Model ===&lt;br /&gt;
* Thread-local stack memory. Fastest to access.&lt;br /&gt;
* Block-local memory, shared by the threads in the same block, with fast access speed.&lt;br /&gt;
* Global memory that is shared by ALL threads. Slow access speed, unless cached.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
=== Best Practices ===&lt;br /&gt;
* Coalesced memory access, access to contiguous memory locations&lt;br /&gt;
* Prevent code paths from diverging (due to for loops or &amp;#039;if&amp;#039; statements) so that threads run similarly long and the compute units are better utilized.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
=== Building CUDA Files In Your C/C++ Project ===&lt;br /&gt;
* Add a build phase in which the CUDA source files are compiled by the CUDA compiler &amp;#039;&amp;#039;nvcc&amp;#039;&amp;#039;.&lt;br /&gt;
* &amp;#039;&amp;#039;nvcc&amp;#039;&amp;#039; generates the binary code that will be loaded into the GPU.&lt;br /&gt;
* &amp;#039;&amp;#039;nvcc&amp;#039;&amp;#039; also generates the C/C++ code for the host side (CPU) by replacing CUDA syntax with CUDA runtime calls. &lt;br /&gt;
* Use the &amp;#039;&amp;#039;nvcc&amp;#039;&amp;#039; option &amp;#039;&amp;#039;--compile&amp;#039;&amp;#039; or &amp;#039;&amp;#039;-c&amp;#039;&amp;#039; for calling the host compiler (gcc or clang) to compile the generated C/C++ code down to machine code.&lt;br /&gt;
* Link against the CUDA runtime library &amp;#039;&amp;#039;&amp;#039;libcudart&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
=== External Resources ===&lt;br /&gt;
* [http://docs.nvidia.com/cuda CUDA official documentation home page]&lt;br /&gt;
* [http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/ NVCC]&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;Online Course&amp;#039;&amp;#039;&amp;#039; [https://www.udacity.com/course/intro-to-parallel-programming--cs344 Intro To Parallel Programming, Udacity]&lt;br /&gt;
* [https://mathema.tician.de/software/pycuda/ PyCUDA] Python binding&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kai</name></author>
	</entry>
</feed>