Install, configure, and test cuda[replication under Ubuntu]

Source: Internet
Author: User
Tags cuda toolkit nvcc

Installing Cuda under Ubuntu is a little more complicated and cumbersome than under Windows, especially for the installation of platforms and some other dependent packages.

Nvidia official only provided the Ubuntu10.10 under the Cuda toolkit,sdk, the first is to install Cuda on the Ubuntu11.10, the result installs a lot of errors and prompts the GCC version is too high (Ubuntu11.10 kernel is 2.6 and the default installation compiled GCC is 4.6) and then re-unloaded the gcc4.6 and then installed the gcc4.4. As a result of the previous use of the default Ubuntu open source Nvidia driver, still does not work, and online check reinstall Nvidia official driver, but when installing the driver prompted later installed gcc4.4 and kernel version inconsistent, the driver will not compile and install properly. Finally I broke many important software packages on my system, and GCC couldn't unload them. Eventually had to be re-loaded back to Ubuntu10.10.

After several toss finally installed, and later on the internet, looks like some other people have encountered similar problems, only one article mentioned will nvidia Cuda in 11.04 installed http://topic.csdn.net/u/20110809/13/ The key to the 281a50dc-605f-4b32-92bf-4193eeebf7ec.html problem is to compile and install the Nvidia driver with GCC, which conforms to the kernel version of the system, and then compile the CUDA program with no more than 4.6 versions of GCC required by Cuda, which is important is to switch between the two versions of the GCC link, and it is unclear whether there will be any problems with your own compiled Cuda program and system, and it will be more reliable to use a system consistent with the official version.

However, I do not want to change back to Ubuntu11.10, the new release version of compatibility also needs to be improved, and actually do the program development use of the system is not like the desktop users so requirements newness, the key is to ask for stability, on-line check with Ubuntu10.10 people or more. Now summarize the installation process so that you can use it next time.

The C/doc directory in the NVIDIA SDK has a getting_started_ The Linux.pdf documentation describes how to install and get started with Cuda in Linux, but because of the different Linux distributions, there are some places that are relatively approximate, but most of the steps are consistent. The installation steps are officially started below:

1. Download the installation package and drivers

This section see the Previous Development software download section, mainly to http://developer.nvidia.com/cuda-downloads download.

The four files required after download are as follows:

2. Verifying system and installation-related packages

Installation and the development of the program, all require administrator root permissions, the recommendation is directly with the root user login system after installation, save every operation and enter the password.

First verify the NVIDIA video card as in the Windows platform, and enter the command in the terminal:

Lspci | Grep-i nvidia

The results on my computer run as follows:

Next verify the Ubuntu system, get the system version information, enter the command in the terminal as follows:

Uname-m && Cat/etc/*release

The results on my computer run as follows:

Verify the GCC version again, and if there is no information, you will need to install it. Enter the following command:

Gcc–version

The results on my computer run as follows:

The g++ is actually used when writing the CUDA program, so install it.

To compile and run the examples in the SDK, support for Freeglut, Mesa, and OpenGL related libraries and header files is also required, and the Getting_started_linux.pdf documentation is recommended for installation in the following command line:

sudo apt-get install Freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev LIBGL1-MESA-GLX Libglu1-mesa Libglu1-mesa-dev

If the build-essential is not installed, the error "g++: Command not Found" appears at compile time,

The Freeglut, Mesa, and OpenGL libraries are not installed when the Cuda SDK program compiles with the error "cannot Find-lxi-lxmu-lglut" as shown in:

These errors were met when they were not installed at first, and later viewed Getting_started_linux.pdf documentation and NVIDIA forum posts http://forums.nvidia.com/index.php?showtopic=171590

only to understand.

The getting_started_linux.pdf documentation also mentions that if you install the Nvidia driver before installing the Mesa Library, you will be prompted to compile with the error "cannot Find-lglu" that the/usr/lib/libgl.so file could not be found. This is primarily due to the rewriting of the/usr/lib/libgl.so file created when installing the Nvidia driver when installing the Mesa Library. Therefore, it is best to install these libraries, and then the driver, in order to avoid the reverse installation caused by the need to re-install the driver to resolve the error "cannot Find-lglu". In the post http://topic.csdn.net/u/20110809/13/281a50dc-605f-4b32-92bf-4193eeebf7ec.html, the Nvidia driver was first installed and then the/usr/lib/ libgl.so file backup and then restore back after installing the Freeglut, Mesa, and OpenGL libraries is a viable option.

3. Installing the NVIDIA Driver

If it is a newly installed Ubuntu system, where the open source Nvidia graphics driver is not activated, you can directly install the Nvidia official download driver, and if it has been activated, you need to uninstall it and then install the official NVIDIA download driver.

To remove a previously activated graphics driver or an older version of the NVIDIA official driver, enter the following command in the terminal:

sudo apt-get–purge remove nvidia-*

sudo apt-get--purge Remove Xserver-xorg-video-nouveau

Then restart the computer, at the login screen or after landing press the shortcut key CTRL + ALT+F1 to the first console. Ubuntu after entering the root username and password in the character interface.

If you do not need to uninstall the Nvidia driver, you can press the shortcut key CTRL + ALT+F1 to the first console without rebooting, but you need one more step, which is to turn off the GUI service by entering the following command:

sudo stop GDM

If it is Ubuntu11.04 or later, you should enter the following command:

sudo stop LIGHTGDM

If the previous version of Ubuntu10.10, you should enter the following command:

SUDO/ETC/INIT.D/GDM stop

Then switch to the directory of the previously downloaded graphics driver via the CD command via the command:

sudo sh driver full name

As I entered on my own computer:

sudo sh devdriver.run

Enter the installation interface after entering the carriage. The first interface selects "Accept" accepts the installation protocol, the second interface, the second interface select "Yes", the back is also selected "OK" or "yes" can be installed all the way.

After installation, the character interface will be returned again, and the GUI service will need to be re-opened to return to the GUI, and enter the following command to start the service:

sudo start GDM

If it is Ubuntu11.04 or later, you should enter the following command:

sudo start LIGHTGDM

If the previous version of Ubuntu10.10, you should enter the following command:

SUDO/ETC/INIT.D/GDM start

Finally press the shortcut key CTRL + ALT+F7 to return to the graphical interface, so the official driver for NVIDIA graphics card installation is complete.

Some motherboards, such as discrete graphics, may also need to set up grub to support Nvidia's graphics card, or it may not be able to enter the graphical interface properly after a reboot:

To open the Grub configuration file in the system:

sudo gedit/etc/default/grub

Add the "Nomodeset" parameter to the Grub_cmdline_linux line:

grub_cmdline_linux= "Nomodeset"

and update Grub:

sudo update-grub

4. Cudatoolkit, Cudatools and gpucomputingsdk required for CUDA installation

This part is very simple, there are some articles on the net to start the installation through the terminal SH command, and actually can directly put these in the. Run suffix of the file's properties set to "Allow File Execution" can be directly right-click on the "Open" menu command installation, as shown in:

Selecting the rightmost command line button in the pop-up dialog will pop up the command-line window and give the appropriate installation prompts. The main is to indicate whether to set the installation path, such as toolkit, using the default path, so only need to go all the way to complete the installation of these three packages.

The default Cuda toolkit and CUDA tools are installed under the/usr/local/cuda path,

Installed under the $ (HOME)/nvidia_gpu_computing_sdk path. You can define a simple path to put the SDK, the default name is too long.

The installation sequence is recommended for Cudatoolkit, Cudatools, GPUCOMPUTINGSDK, because the SDK installs with the installation path to refer to toolkit.

After all three are installed, you can view the version of the NVCC compiler with the following command:

Nvcc–v

Note that the "V" is capitalized, and if you can see its version as shown, it indicates that the toolkit is installed correctly.

After installation, in order to be able to compile the sample program and your own CUDA application, you also need to set environment variables, enter the command:

sudo gedit ~/.BASHRC

Then, if the 32-bit Linux system is added at the end of the open file:

Export Path=/usr/local/cuda/bin: $PATH

Export Ld_library_path=/usr/local/cuda/lib: $LD _library_path

If the 64-bit Linux system is added at the end of the open file:

Export Path=/usr/local/cuda/bin: $PATH

Export LD_LIBRARY_PATH=/USR/LOCAL/CUDA/64: $LD _library_path

Save the file and close it, and last update:

~/.bashrc

5. Run the SDK example to test the development environment

To switch to the installation path of the SDK in the terminal:

CD/(HOME)/nvidia_gpu_computing_sdk/c

where home for its own username, such as root user under:

Cd/root/nvidia_gpu_computing_sdk/c

Then compile directly:

Make

However, an error occurred while compiling on your own computer, prompting "Error:kernel lauches from templates is not allowed in system files" as shown in

It seems that the smoke particle sample has not been compiled, the reason has not been found out, the NVIDIA forum also encountered this situation has not been resolved.

But by chance I saw a website in the UK Https://amcg.ese.ic.ac.uk/~fr710/wiki/dev/cuda/start

The explanation of the problem is given in the following text:

Nvccerrors

Kernellaunches from templates is not allowed in system files

Occurswhenever a kernel is launched from a template class or function this isdeclared in a header residing in a standard I Nclude Path of the compiler

Note:thisapplies also to include path expansion e.g. through the cplus_include_pathenvironment variable

Solution:the include path for thecorresponding headers must is specified by A-i flag to the compiler

This error occurs when the kernel is started from a template class or function declared in the header file of the compiler standard reference path.

Note: This error also occurs when the associated reference path is included in the CPLUS_INCLUDE_PATH environment variable. The workaround is to specify a-l flag in the compilation options for the corresponding header file that contains the path.

Now that you can't compile all of them, you have to switch to the source code path.

Cd/root/nvidia_gpu_computing_sdk/c/src then go into the Sample project folder of interest and make it, there should be no problem with most examples. The Devicequery, Bandwidthtest, Bicubictexture, bilateralfilter four samples are compiled and tested primarily.

Enter the directory compilation separately, as shown in

After compiling, go to the build folder and run each example, such as Run devicequery and enter the command:

./Devicequery

Enter to run and print out some information about the detected GPU device and its corresponding CUDA:

Run data transfer Bandwidth Bandwidthtest test example

Run Bilateral filter Bilateralfilter Test example

Run the double cubic texture bicubictexture Test Example

It is visible on the run effect and is consistent in Windows.

However, sometimes the compile time can pass, but the runtime prompts such errors: "X error of failed reques:badwindows (invalid Windows parameter)"

By its meaning, the Windows parameter of OpenGL in the program is set incorrectly, not actually. This problem is usually due to system updates, such as running the sudo apt-get Upgrade command, and so on, updating the X service in the system to overwrite some files of the previously installed Nvidia graphics card, and re-install the Nvidia graphics driver once again in the previous steps. can refer to http://www.linuxdiyf.com/bbs/viewthread.php?tid=194013

Some resources for CUDA programming under 6.Linux

CSDN

http://forum.csdn.net/SList/CUDA_Linux/

Nvidia

http://forums.nvidia.com/index.php?s=67988942b49f28d483a57faf0e34af94&showforum=68

Reference documents:

ubuntu10.10 the installation of the graphics driver and the opening of the 3D special effects

Http://www.cnblogs.com/ini_always/archive/2011/04/04/2004987.html

Practice compiling and installing NVIDIA graphics driver under Ubuntu

Http://www.sinoll.com/archives/569#respond

Build Cuda 4.0 platform under Ubuntu10.10

Http://blog.sina.com.cn/s/blog_8164a3130100s9ax.html

Ubuntu 10.10 Installs and configures Cuda 4.0.

http://blog.csdn.net/dreampursue/article/details/6359432

Install, configure, and test cuda[replication under Ubuntu]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.