How can I install CUDA 9 on Ubuntu 17.10

Installation of NVIDIA driver 384

First we install a fresh Ubuntu 17.10 on a computer with an NVIDIA GPU and select "Install third-party software" during the process. Alternatively, we can add the graphics drivers repository manually:

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update

Then we install the most recent NVIDIA driver using apt:

sudo apt install nvidia-384 nvidia-384-dev

We verify the installation by running:

nvidia-smi

We should see an output which lists the NVIDIA 384 driver and our discrete NVIDIA GPU - similar to summarized table below:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.90                 Driver Version: 384.90                    |
|                                                                             |
|-------------------------------+----------------------+----------------------+
|   0  Quadro M500M        Off  | 00000000:06:00.0 Off |                  N/A |
| N/A   48C    P0    N/A /  N/A |    943MiB /  2002MiB |     26%      Default |
+-------------------------------+----------------------+----------------------+

Preparation for installing of CUDA 9 + SDK

We install a number of build/dev packages which we require later:

sudo apt-get install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev

We notice that the default gcc/g++ version on 17.10 is 7.2.0 (Ubuntu 7.2.0-8ubuntu3) :

gcc -v

CUDA 9 requires gcc 6. Thus, we install it and set the corresponding sym-links:

sudo apt install gcc-6
sudo apt install g++-6
sudo ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++

Note that the default gcc version is still 7.2; can be checked by running gcc -v again.

Installation of CUDA 9 + SDK

Download a version of CUDA 9, such as

wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run

Make the downloaded file executable and run it using sudo:

chmod +x cuda_9.0.176_384.81_linux.run 
sudo ./cuda_9.0.176_384.81_linux.run --override

We install CUDA with the following configurations:

You are attempting to install on an unsupported configuration. Do you wish to continue?
y
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?
n
Install the CUDA 9.0 Toolkit?
y
Enter Toolkit Location
[default location]
Do you want to install a symbolic link at /usr/local/cuda?
y
Install the CUDA 9.0 Samples?
y
Enter CUDA Samples Location
[default location]

Test the CUDA 9 installation using the SDK

Build your favorite CUDA sample and run it:

cd ~/NVIDIA_CUDA-9.0_Samples/5_Simulations/smokeParticles
make
../../bin/x86_64/linux/release/smokeParticles 

Disclaimer: This guide is produced from memory and my .bash_histroy. Hence it is possible that a step is missing. Please comment if this is the case.

share improve this answer
 
  • Been stuck on this issue for a bit. Running 17.10, trying to install CUDA 9. I'm having an issue on step 2: nvidia-smi NVIDIA-SMI has failed because it couldn't communicate with the NVIDIA driver. Ran lspci | grep -i nvidia says I have a GeForce GTX 760. mokutil --sb-stateshows SecureBoot disabled. Ran sudo apt-get purge nvidia*, ran your install command for 384, and ran dpkg -S nvidia-smi nvidia-384: /usr/lib/nvidia-384/bin/nvidia-smi. Any suggestions? –  Clark Kent  Oct 23 '17 at 2:53
  • I assume you tried a reboot after installing nvidia-384, didn't you? –  B0rk4  Oct 23 '17 at 2:57
  • Yes, many reboots. I'm also getting another error from modprobe: modprobe: ERROR: ../libkmod/libkmod-module.c:832 kmod_module_insert_module() could not find module by name='nvidia_384' –  Clark Kent  Oct 23 '17 at 3:00
  • 4
    I had to do either sudo ln -s /usr/bin/gcc-6 /usr/local/cuda-9.0/bin/gcc sudo ln -s /usr/bin/g++-6 /usr/local/cuda-9.0/bin/g++ or sudo ./cuda_9.0.176_384.81_linux-run --override as author below recommends to install successfully without compiler conflict –  yauheni_selivonchyk  Nov 3 '17 at 4:22
  • 6
    the two commands to add the symbolic links for the gcc 6 compilers have to be done after installing cuda, because /usr/local/cuda does not exist before installing –  Luis Lobo Borobia  Nov 20 '17 at 2:32 

Getting this installed took more time than I would like to admit, and while the above answer is a good template, I had some additional steps required for my fresh install of Ubuntu 17.10:

blacklist nouveau

sudo vim /etc/modprobe.d/blacklist.conf

Add the following:

# this one might not be required for x86 32 bit users.
blacklist amd76x_edac 

blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv

Update initramfs disk

sudo update-initramfs -u

Stop gdm3

sudo /etc/init.d/gdm3 stop

sudo init 3

Get content

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-384 nvidia-384-dev
sudo apt-get install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev

nvidia-smi

Get the package

wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run

Run with --override to override compiler choice

chmod +x cuda_9.0.176_384.81_linux-run 
sudo ./cuda_9.0.176_384.81_linux-run --override

After installing the package, I would get errors with nvidia-smi, so I suggest running the command again to verify it works. When I had issues, I would purge nvidia* and re-get it.

nvidia-smi
share improve this answer
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值