Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install CUDA under Linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Today, the editor will share with you the relevant knowledge about how to install CUDA under Linux. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look at it.

Is a parallel computing platform and C-like programming model, we can easily implement parallel algorithms, just like writing C code. With NVIDIA GPU, you can run your parallel programs on many devices, whether it's desktops, laptops or tablets.

Check if the video card supports CUDA

Enter the following command to view the NVIDIA model of the computer:

Vincent@dell-Inspiron-7559 Dir:~ $lspci | grep-I nvidia02:00.0 3D controller: NVIDIA Corporation GM107M [GeForce GTX 960m] (rev a2)

My graphics card model is GeForce GTX 960m

Then go to the official website to see if it supports CUDA, URL address.

Check the relationship between CUDA version and NVIDIA driver

Download the CUDA file

Download the latest CUDA software installation package, CUDA Toolkit 9.2 Download.

We chose the runfile file to install. Then put it in a directory, and remember, we're going to execute it later.

Confirm the installation environment

1. The NVIDIA video card has been installed normally.

2. Nouveau has been disabled

You can view it using the following command, and if there is no output, it means success:

Lsmod | grep nouveau

If the NVIDIA driver is installed correctly, it will be disabled.

3. Verify that the system has gcc installed

The terminal enters the following command to see if it is installed:

Vincent@dell-Inspiron-7559 Dir:~ $gcc-- versiongcc (Ubuntu 7.3.0-16ubuntu3) 7.3.0Copyright (C) 2017 Free Software Foundation, Inc.This is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Install CUDA

1. Enter the tty interface

Press alt + ctrl + F1 to enter the tty command line interface, login user and password

two。 Close the graphical interface

Enter the following command in tty to close the graphical interface:

Sudo service lightdm stop

Or

Sudo telinit 3

3. Run the cuda file

First, give cuda executable permission:

Sudo chmod axix cuda_9.2_linux.run

Run the cuda file:

Sudo. / cuda_9.2_linux.run-- no-opengl-libs

Cuda mainly has the following parameters:

-- no-opengl-libs: means that only driver files are installed, not OpenGL files. Required parameters for the same reason as above. Note: not-no-opengl-files. -- uninstall (deprecated): used to uninstall CUDA Driver (obsolete). -- toolkit: means that only CUDA Toolkit is installed, not Driver and Samples--help: see more advanced options.

4. Option selection for the installation process

(1)。 There will be a reading statement, just press D all the time, and then accept. (2)。 Option install nvidia accelerated Graphics Driver, enter n, because we have installed the driver for nvidia. (3)。 Option install the OpenGL libraries, if the dual display card (set + unique display) selects n, if only the unique display can select y, if the dual display card selects y, there will be the problem of black screen or circular login. If you add the above parameters, this option will not appear. (4)。 The latter can all choose yes, and the last option we can choose is n, that is, do not copy Samples, because there is samples in the installation directory.

The following information will be available at the end of the installation process:

Driver: InstalledToolkit: Installed in / usr/local/cuda-9.2Samples: Installed in / home/vincent

Indicates that the installation is complete, but does not represent success. A reboot is needed at this point.

5. Verify that cuda is installed successfully

Restart to enter the interface and open the terminal to enter:

Export PATH= "/ usr/local/cuda-9.2/bin:$PATH" export LD_LIBRARY_PATH= "/ usr/local/cuda-9.2/lib64:$LD_LIBRARY_PATH"

These two commands export cuda's bin file and lib to the system environment. If the installation version is not the same, change the cuda-9.2 in the path.

(1)。 Terminal input:

Nvcc-V

If there is a CUDA version information, it is normal.

(2)。 Compile the samples example

# compile and test device deviceQuery:cd / usr/local/cuda-9.2/samples/1_Utilities/deviceQuerysudo make./deviceQuery# compile and test bandwidth bandwidthTest:cd.. / bandwidthTestsudo make./bandwidthTest

If the final result of both tests is Result = PASS, CUDA installation is successful.

Note: if the installation fails, there may be a lack of dependencies, and the terminal executes:

Sudo apt-get install freeglut3-dev\ build-essential\ libx11-dev\ libxmu-dev\ libxi-dev\ libgl1-mesa-glx\ libglu1-mesa\ libglu1-mesa-dev

(6)。 Write the bin and lib of cuda to the system environment

Open the ~ .bashrc file and add two sentences at the end:

Export CUDA_HOME=/usr/local/cuda-9.2export LD_LIBRARY_PATH=/usr/local/cuda-9.2/lib64:$LD_LIBRARY_PATHexport PATH=/usr/local/cuda-9.2/bin:$PATH

Then exit and reopen the terminal.

CUDA uninstall

CUDA is installed under / usr/local/cuda-9.2 by default, and uninstall it with the following command:

Sudo / usr/local/cuda-9.2/bin/uninstall_cuda-9.2.pl

NVIDIA driver uninstall:

Sudo / usr/bin/nvidia-uninstall

The uninstall process is yes all the way.

Other questions

1. If a circular login occurs

Press alt + ctrl + F1 to enter tty, and then toggle set display:

Sudo prime-select intel

Uninstall the cuda file:

Sudo / usr/local/cuda-9.2/bin/uninstall_cuda_9.2.pl

If you still cannot enter after reboot, uninstall the nvidia driver:

Sudo / usr/bin/nvidia-uninstall

You can also select Advanced at startup and enter the system in root mode to uninstall nvidia, cuda and other software.

Then restart, if you restart the black screen, press the e key on the grub interface to enter linux, find quiet splash, add nouveau.modeset=0 at the back, and then press F10 to start. Then install the nvidia driver and then install the CUDA software.

2.gcc version verification fails if it occurs during the installation of cuda

Failed to verify gcc version

Then it is very possible that your gcc version is too high, for example: cuda 10.1 requires gcc version 7.3.0, but the default gcc version of ubuntu 20.04/linux mint 20 is 9.3.0, so you can add the following parameters to install.

Sudo sh cuda_10.1.243_418.87.00_linux.run-override above is all the contents of the article "how to install CUDA under Linux". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report