ubuntu set up 3 - cuda
https://www.pugetsystems.com/labs/hpc/How-to-install-CUDA-9-2-on-Ubuntu-18-04-1184/
How to install CUDA 9.2 on Ubuntu 18.04
Written on June 15, 2018 by Dr Donald Kinghorn
- Steps to install CUDA 9.2 on Ubuntu 18.04
- Step 1) Get Ubuntu 18.04 installed!
- Step 2) Get the "right" NVIDIA driver installed
- Step 3) Install CUDA "dependencies"
- step 4) Get the CUDA "run" file installer
- Step 4) Run the "runfile" to install the CUDA toolkit and samples
- Step 5) Install the cuBLAS patch
- Step 6) Setup your environment variables
- Step 7) Test CUDA by building the "samples"
If you are wanting to use Ubuntu 18.04 and also want a CUDA install this post should help you get that working.
I was surprised when NVIDIA did not include an installer for Ubuntu 18.04 when they launched CUDA 9.2. The new Ubuntu had been out for a while and it seemed like "everybody" already had support it. It was working with Docker, NVIDIA-Docker, TensorFlow, Virtualbox, Anaconda Python, etc.. I hadn't found anything that was not working fine. It's not that much different, at a system level, from Ubuntu 17.10 or Fedora-23 which are both supported for CUDA 9.2. I'm still not sure exactly why they don't have an installer link for it but after doing my own install I have some suspicions of where the they may have run into trouble with Ubuntu 18.04. However, ...
... I didn't have any serious problems installing CUDA 9.2 on Ubuntu 18.04! I did it using the ".run" file for Ubuntu 17.10 together with the GeForce runtime driver rather than the Tesla driver that comes with the CUDA 9.2 install.
In my recent post The Best Way To Install Ubuntu 18.04 with NVIDIA Drivers and any Desktop Flavor I went through how I've been doing installs for the latest Ubuntu. If you are thinking about installing 18.04 you might want to look at that post especially if you have had any trouble with the install. I usually include a CUDA install when I do a post like that but in that one I decided to look at it separately since NVIDIA had not released an official installer for it. Well, this is the post where I do the (unofficial) CUDA install.
Disclaimer: What follows is my own personal hack to get CUDA installed and running on Ubuntu 18.04. It is not supported by anyone, not even me!
Steps to install CUDA 9.2 on Ubuntu 18.04
Step 1) Get Ubuntu 18.04 installed!
Fortunately, this "shouldn't" be too hard. See my recent post on doing that.
Step 2) Get the "right" NVIDIA driver installed
If you followed my instructions for installing Ubuntu 18.04 you would have installed the driver nvidia-390 from the graphics-drivers ppa. That is the current "long term" driver and it supports cards up-to and including Titan V. However if you jumped ahead and did the CUDA toolkit install like I describe in later steps you would compile the deviceQuery code and run it and see a message like,
kinghorn@u18:~/projects/samples/1_Utilities/deviceQuery$ ./deviceQuery
./deviceQuery Starting...
CUDA Device Query (Runtime API) version (CUDART static linking)
cudaGetDeviceCount returned 35
-> CUDA driver version is insufficient for CUDA runtime version
Result = FAIL
That is a run-time version miss-match! The NVIDIA display drivers come with a CUDA runtime library. That's so you can run CUDA accelerated programs without having CUDA installed on your system. That's usually just what you want. But, If you are doing CUDA dev work you need to have your run-time and development libraries in sync! The nvidia-390 driver is not recent enough for CUDA 9.2.
The CUDA installers contain a display driver. For CUDA 9.2 that driver is currently version 396.26. That is the Tesla driver! [ If you go to the NVIDIA driver download page and select "Product Type:" Tesla you will get to the 396.26 driver. ] The equivalent driver for GeForce or Titan is 396.24. That's the one that you want. 396.24 is the current "short term" driver and it is available on the graphics-drivers ppa. However, ...
Ubuntu 18.04 quirk: You can't install nvidia-396 from the graphics drivers ppa using apt-get!
I don't understand why but, if you have the graphics-drivers ppa configured for apt and try to install nvidia-396 you will get a "package not found" error even though you can go to the ppa page and see the deb file sitting there for 18.04. apt-get will only "see" up-to version nvidia-390 from the ppa. This is an unsolved puzzle for me.
Work-around: use the "Software & Updates" "Additional Drivers" GUI
The Software & Updates utility does list the nvidia-396 driver. Go ahead and select that and "Apply" it. Reboot and you will be running the needed 396.24 driver.
Step 3) Install CUDA "dependencies"
There are a few dependencies that get installed when you run the CUDA deb file but, since we are not going to use the deb file, you will want to install them separately. It's simple since we can get what's needed with just four package installs,
sudo apt-get install freeglut3 freeglut3-dev libxi-dev libxmu-dev
Those packages will get the needed GL, GLU, Xi, Xmu libs and several other libraries that will be installed as dependencies from those.
step 4) Get the CUDA "run" file installer
Go to the CUDA Zone and click the Download Now button. Then click the link buttons until you get the following,
Download both of both of those.
Step 4) Run the "runfile" to install the CUDA toolkit and samples
This is where we get the CUDA developer toolkit and samples onto the system. Just use sh to run the shell script (runfile),
sudo sh cuda_9.2.88_396.26_linux.run
You will be asked several questions. Here are my answers, (after accepting the EULA),
You are attempting to install on an unsupported configuration. Do you wish to continue?
(y)es/(n)o [ default is no ]: y
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 396.26?
(y)es/(n)o/(q)uit: n
Install the CUDA 9.2 Toolkit?
(y)es/(n)o/(q)uit: y
Enter Toolkit Location
[ default is /usr/local/cuda-9.2 ]:
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y
Install the CUDA 9.2 Samples?
(y)es/(n)o/(q)uit: y
Enter CUDA Samples Location
[ default is /home/kinghorn ]: /usr/local/cuda-9.2
The most important part of those answers was saying "No" to installing the Driver. The default is "yes".
Step 5) Install the cuBLAS patch
The runfile for the cuBLAS patch just copies the fixed version into the CUDA install directory.
sudo sh cuda_9.2.88.1_linux.run
Step 6) Setup your environment variables
There are two good ways to setup your environment variables so you can use CUDA.
- Setup system environment
- Setup user environment
In the past I have usually been doing installs for any number of users on a system so I would do system-wide environment configuration. You can do this even for a single user workstation but you might prefer to just create a couple of small scripts that set things up just for the terminal you are working in when you need it.
System-wide alternative
- To configure the CUDA environment for all users (and applications) on your system create the file (use sudo and a text editor of your choice)
/etc/profile.d/cuda.sh
with the following content,
export PATH=$PATH:/usr/local/cuda/bin
export CUDADIR=/usr/local/cuda
Also create the file,
/etc/ld.so.conf.d/cuda.conf
and add the line,
/usr/local/cuda/lib64
Then run
sudo ldconfig
The next time you login your shells will start with CUDA on your path and be ready to use. If you want to load that environment in a shell right now without logging out then just do, source /etc/profile.d/cuda.sh.
User per terminal alternative
If you want to be able to activate your CUDA environment only when and where you need it then this is the way to do it. You might prefer this method over a system-wide environment.
- For a localized user CUDA environment create the following simple script. You don't need to use sudo for this and you can keep the script anywhere in your home directory. You will just need to "source" it when you want a CUDA dev environment.
I'll create the file with the name cuda9.2-env. Add the following lines to this file,
export PATH=$PATH:/usr/local/cuda-9.2/bin
export CUDADIR=/usr/local/cuda-9.2
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.2/lib64
Note: I explicitly used the full named path to version 9.2 i.e /usr/local/cuda-9.2 rather than to the symbolic link /usr/local/cuda. You can use the symbolic link path if you want. I just did this in case I want to install another version of CUDA and make another environment script pointing to the different version.
Now when you want your CUDA dev environment just do source cuda9.2-env. That will set those environment variables in your current shell. (you could copy that file to your working directory or else give the full path to it when you use the source command.)
Step 7) Test CUDA by building the "samples"
Let's make sure everything is working correctly. Copy the CUDA samples source directory to someplace in your home directory
mkdir cuda-testing
source cuda-9.2-env
cp -a /usr/local/cuda/samples cuda-testing/
cd cuda-testing/samples
make -j4
Running that make command will compile and link all of the source examples as specified in the Makefile. ( the -j4 just means run 4 "jobs" make can build objects in parallel so you can speed up the build time by using more processes. The systems I was testing this on had 4 CPU cores.)
After everything finishes building you can cd to bin/x86_64/linux/release/ and see all of the sample executables. I had 165 programs built without error. I believe that is the entire sample set. I ran several of the programs and they were working as expected including the one that were using OpenGL graphics.
Just because the samples built OK doesn't mean that there are not any problems with the install but it is a really good indication that you can proceed with confidence for your development work!
I hope this post helps you with your CUDA projects!
I want to finish by saying that I personally am starting to use Docker containers when I need something like a CUDA dev environment. I did that for building TensorFlow from source a few weeks ago. I have written a series of posts on using Docker on your workstation (along with lots of other stuff!) which you can find on the Puget Systems HPC blog.
Happy computing! --dbk
ubuntu set up 3 - cuda的更多相关文章
- Ubuntu安装opencv with cuda
Ubuntu安装opencv with cuda 为了运行dense flow真是折腾啊,下面网址是教程 http://blog.aicry.com/ubuntu-14-04-install-open ...
- Ubuntu系统---“NVIDIA 驱动+CUDA+cuDNN ”之后 OpenCV安装
Ubuntu系统---“NVIDIA 驱动+CUDA+cuDNN ”之后 OpenCV安装 目录: 一.OpenCV安装包下载 二.cmake安装 三.OpenCV安装 正文 一.OpenCV安装包下 ...
- Caffe + Ubuntu 14.04 64bit + CUDA 6.5 配置说明
本文安装显卡驱动的方式已经过时, 最新安装说明请参考发布在Gist上的这篇文章,如有任何疑问,仍然欢迎在本文下留言 :P (本文档使用同一块NVIDIA显卡进行显示与计算, 如分别使用不同的显卡进行显 ...
- ubuntu 16.04 安装cuda的方法
很多神经网络架构都需要安装CUDA,安装这个的确费了我不少时间,是要总结一下流程了. 安装这个,最好使用官网的安装步骤和流程,不然,会走很多弯路: https://developer.nvidia.c ...
- Ubuntu 14.04 安装 CUDA 问题及解决
本文安装环境: - 双显卡: intel 集显 + nvidia 独显 - Ubuntu 14.04.4 - CUDA 8.0.44 1. Deb 安装包是个坑 (不要用这种方法!) 使用 Deb 安 ...
- Caffe + Ubuntu 14.04 64bit + CUDA 6.5 配置说明2
1. 安装build-essentials 安装开发所需要的一些基本包 sudo apt-get install build-essential 2. 安装NVIDIA驱动 (3.4.0) 2.1 准 ...
- [笔记] Ubuntu 18.04安装cuda 10及cudnn 7流程
安装环境 OS:Ubuntu 18.04 64 bit 显卡:NVidia GTX 1080 任务:安装 CUDA 10及cuDNN 7 工具下载 NVidia官网下载下列文件: CUDA 10:cu ...
- Ubuntu 18.04安装 CUDA 10.1 、cuDNN 7.6.5、PyTorch1.3
转载请注明出处 BooTurbo https://www.cnblogs.com/booturbo/p/11834661.html 安装平台及环境 CPU:i9-9900k桌面级 GPU:RTX 2 ...
- Ubuntu P40显卡配置CUDA 10.1,CUDNN 7.6,Conda 5.2.0, Tensorflow-gpu 1.8
1. 安装CUDA 禁用nouveau vim /etc/modprobe.d/blacklist.conf 最后两行加入 blacklist nouveau options nouveau mode ...
随机推荐
- JS的基本概念和数据类型
什么是 JavaScript 语言 Normal 0 7.8 磅 0 2 false false false EN-US ZH-CN X-NONE /* Style Definitions */ ta ...
- 阿里妈妈的iconfont的引用问题
一.先进官网 我们看到了上面的这些图标,是不是很心动,阿里妈妈就是给力,给马老师点赞,但是问题来了我们怎么去使用呢. 二.点击图标 嘿嘿,上面的操作步骤我就不多说了吧,我相信大家都会做的,接下来我们就 ...
- Git常用命令 - 随时更新
1. 配置用户信息 git config --global user.name <name> git config --global user.email <email_addres ...
- C# Winform初体验
设计一个简单的登录窗口,要求输入用户名:小金,密码:123456时候点登录能正确转到另一个窗口. 1.建立窗体应用. 2.这里创建一个login和一个NewForm的窗体. 3.在login的窗体拖拉 ...
- C# MVC 中自定义权限特性[Authorize]中对于Ajax访问的处理
在MVC中定义自己的权限特性. 下例中是简单的登录判断,登录信息存与Session中,如果Session中没有登录信息,那么就不通过. 在处理无权限的时候,判断当前请求是否为Ajax请求,如果是Aja ...
- 《自拍教程18》adb_Android设备debug连接工具
adb命令介绍 做Android App测试,Android手机系统测试, 还有很多Android终端产品(手表,车载,智能电视,智能手表等) 都必须用adb命令,通过USB接口,与Android设备 ...
- 基于SSM开发大学食堂采购管理系统源码
开发环境: Windows操作系统开发工具: Eclipse+Jdk+Tomcat+MySQL数据库 次项目分为管理员和普通用户两种角色 运行效果图
- Windows显示默认桌面图标(计算机,用户的文件,网络,控制面板,回收站)
1.按Win+R 2.复制以下命令 rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,0 3.点击运行,根据需求勾选相应图标即可
- IE浏览器中IFrame被加载两次问题的解决-sunziren
本文为作者sunziren原创,首发博客园,转载请注明出处. 昨天遇到了一个问题,先上代码. var content = '<iframe src="www.baidu.com&quo ...
- 剑指offer-面试题39-数组中出现次数超过一半的数字-抵消法
/* 题目: 数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字. 例如输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}.由于数字2在数组中出现了5次,超过数组长度的一半,因此输 ...