Ubuntu 16.04 安装CUDA9.2

本文主要介绍在Ubuntu系统安装CUDA Toolkit的步骤。首先要验证有支持CUDA的GPU、合适版本的Linux、已安装gcc以及正确的内核头文件和开发包。接着可选择安装方式,从官网下载工具包并验证下载文件,最后检查CUDA是否安装成功。
PyTorch 2.5

PyTorch 2.5

PyTorch
Cuda

PyTorch 是一个开源的 Python 机器学习库,基于 Torch 库,底层由 C++ 实现,应用于人工智能领域,如计算机视觉和自然语言处理

Verify You Have a CUDA-Capable GPU

$ lspci | grep -i nvidia
01:00.0 VGA compatible controller: NVIDIA Corporation Device 1b06 (rev a1)
01:00.1 Audio device: NVIDIA Corporation Device 10ef (rev a1)

Verify You Have a Supported Version of Linux

$ uname -m && cat /etc/*release
x86_64
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=16.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 16.04.5 LTS"
NAME="Ubuntu"
VERSION="16.04.5 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.5 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial

Verify the System Has gcc Installed

$ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.10) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Verify the System has the Correct Kernel Headers and Development Packages Installed

the CUDA Driver requires that the kernel headers and development packages for
the running version of the kernel be installed at the time of the driver installation,
as well whenever the driver is rebuilt. For example, if your system is running kernel
version 3.17.4-301, the 3.17.4-301 kernel headers and development packages must also be
installed.
While the Runfile installation performs no package validation, the RPM and Deb
installations of the driver will make an attempt to install the kernel header and
development packages if no version of these packages is currently installed. However,
it will install the latest version of these packages, which may or may not match the
version of the kernel your system is using. Therefore, it is best to manually ensure the

correct version of the kernel headers and development packages are installed prior to
installing the CUDA Drivers, as well as whenever you change the kernel version.
The version of the kernel your system is running can be found by running the following
command:

$ uname -r
4.15.0-33-generic

This is the version of the kernel headers and development packages that must be
installed prior to installing the CUDA Drivers. This command will be used multiple
times below to specify the version of the packages to install. Note that below are the
common-case scenarios for kernel usage. More advanced cases, such as custom kernel
branches, should ensure that their kernel headers and sources match the kernel build
they are running.

Ubuntu
The kernel headers and development packages for the currently running kernel can be
installed with:

$ sudo apt-get install linux-headers-$(uname -r)

Choose an Installation Method
      The CUDA Toolkit can be installed using either of two different installation mechanisms:
distribution-specific packages (RPM and Deb packages), or a distribution-independent
package (runfile packages). The distribution-independent package has the advantage of
working across a wider set of Linux distributions, but does not update the distribution's
native package management system. The distribution-specific packages interface with
the distribution's native package management system. It is recommended to use the
distribution-specific packages, where possible.

 

Download the NVIDIA CUDA Toolkit
The NVIDIA CUDA Toolkit is available at

http://developer.nvidia.com/cuda-downloads.


Choose the platform you are using and download the NVIDIA CUDA Toolkit
The CUDA Toolkit contains the CUDA driver and tools needed to create, build and run
a CUDA application as well as libraries, header files, CUDA samples source code, and
other resources.
Download Verification
The download can be verified by comparing the MD5 checksum posted at http://
developer.nvidia.com/cuda-downloads/checksums with that of the downloaded
file. If either of the checksums differ, the downloaded file is corrupt and needs to be
downloaded again.
To calculate the MD5 checksum of the downloaded file, run the following:

$ md5sum <file>

download a local deb

then

$ sudo dpkg -i cuda-repo-ubuntu1604-9-2-local_9.2.148-1_amd64.deb
$ sudo apt-key add /var/cuda-repo-9-2-local/7fa2af80.pub
$ sudo apt-get update
$ sudo apt-get install cuda

$ echo 'export PATH=/usr/local/cuda-9.2/bin:$PATH' >> ~/.bashrc
$ echo 'export LD_LIBRARY_PATH=/usr/local/cuda-9.2/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
$ source ~/.bashrc
$ sudo reboot

check if cuda is installed sucess.

$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2018 NVIDIA Corporation
Built on Tue_Jun_12_23:07:04_CDT_2018
Cuda compilation tools, release 9.2, V9.2.148

The NVIDIA Persistence Daemon should be automatically started for POWER9
installations. Check that it is running with the following command:

$ systemctl status nvidia-persistenced
nvidia-persistenced.service - NVIDIA Persistence Daemon
   Loaded: loaded (/lib/systemd/system/nvidia-persistenced.service; static; vendor preset: enabled)
   Active: active (running) since 三 2018-08-29 13:11:14 CST; 16min ago
  Process: 851 ExecStart=/usr/bin/nvidia-persistenced --user nvidia-persistenced --no-persistence-mode --verbose (code=exited, status=0/SUCCESS)
 Main PID: 866 (nvidia-persiste)
   CGroup: /system.slice/nvidia-persistenced.service
           └─866 /usr/bin/nvidia-persistenced --user nvidia-persistenced --no-persistence-mode --verbose

If it is not active, run the following command:

$ sudo systemctl enable nvidia-persistenced

 

您可能感兴趣的与本文相关的镜像

PyTorch 2.5

PyTorch 2.5

PyTorch
Cuda

PyTorch 是一个开源的 Python 机器学习库,基于 Torch 库,底层由 C++ 实现,应用于人工智能领域,如计算机视觉和自然语言处理

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值