win10+ubuntu18双硬盘双系统安装记录+深度学习环境搭建

工作需要,在已经预装了Windows10的工作站,需要再安装ubuntu。因为工作站本身有两块硬盘,所以准备空出一个装ubuntu,这样两个系统互不干扰,不使用对方的硬盘空间。工作站装里有两块Nvidia 1080TI,导致后续安装ubuntu有一些需要注意的问题,下文详述。

Ubuntu 18.04 下深度学习环境搭建

借了一个烧录好的ubuntu16的u盘,可惜的是安装中出现了各种问题,进入不了安装界面,找不到硬盘等等。

于是重新下了18.04 desktop lts 的镜像,官网list里找了以下这个国内的源,上海交大的,下载速度还可以。工作电脑没有中文输入,下文部分英文,以后有时间再翻译一下。

--------------------------------------------------------------------------------------------------------------------------

UEFI introduced Install Ubuntu 18.04 LTS desktop

Step1: download 18.04 lts desktop image from http://ftp.sjtu.edu.cn/ubuntu-cd/18.04/

Step2: download UltraISO trail version and burn your image to an fresh USB

Step3: Turnoff your secure boot and fast startup options in BIOS and control panel respectively

* Step4: Reboot and use F12 to go into one-time boot options

[Trick] for Nvidia graphic card]Step5: Select second option *Install ubuntu,  press e, modify apci =off and press F10 to go into install

[Trick] If your screen stuck at

/dev/sda1 contains a file system with errors, check forced.

(initramfs)_

Input command: fsck /dev/sda1 then enter y when prompted to perform fixes, then input reboot if it doesn't do so automatically

Assuming everything works well you would have ubuntu 18.04 on your introduction screen when boot, if it doesn't meaning your UEFI file is not working, you need to download easyUEFI to repair, don't download BCD because it is not free in commercial environment.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Ubuntu 18.04 setting up for Deep learning environment

Important Note, when setup the environment you need to know exactly which system, graphic card, CUDA, CUDNN you will install because everything is dependent. Don't start installing without figuring out which system and CUDA and CUDNN you need, you may have to go back and forth if you do not have a plan, it is painful!

Reference https://medium.com/@zhanwenchen/install-cuda-and-cudnn-for-tensorflow-gpu-on-ubuntu-79306e4ac04e

Prerequisite:

nvidia-smi to see if you have install NVIDIA drivers in your software center, take a look at driver version, if your already got results this could be good or bad. If you want to install CUDA 10 but your driver version is older than 400, unfortunately you have to remove all the driver and download the new driver and reinstall!

Step1. Figure out which graphic card you have, for me, Geforce GTX 1080TI, go to the following website to get your driver, this is essential for success for the following install!!!! Don't just use a random blog's command to install random driver, it is much easier to use apt-get but the version might be wrong for your graphic card or system or CUDA!!!!

 Legacy drivers: https://www.nvidia.com/Download/Find.aspx

Latest driver: https://www.nvidia.com/Download/index.aspx?lang=en-us (100+M)

*****If you have unfortunately installed the wrong driver, here is the post to help you reinstall**********

Step A.  Remove nvidia driver by following command

$ sudo apt-get purge nvidia*

$ sudo apt-get autoremove

Step B. Reboot to go to the secure mode, without opening X, because X is also using nvidia thus when you try to install driver, it will say some nvidia stuff is loaded and could not install

In secure mode select root shell, in the root shell install your downloaded driver

https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html

*******************************************************************

Step 2, Download CUDA and install, for my ubuntu18.04, CUDA 10.1(注意至今2019/4/7最新版的tensorflow仍然只支持CUDA10.0,所以如果你是tensorflow 用户请使用CUDA10.0,并且你的driver version不要是最新的,得是如上图所示如果是pytorch用户CUDA10.1我试过是可以的)


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

download your .run file, cd to the downloaded folder, do

sudo chmod +x cuda_10.1_linux.run

./cuda_9.0.176_384.81_linux.run --override

sudo apt-get install nvidia-384 nvidia-modprobe

Step 2 install CUDNN

Download CUDNN from download page: https://developer.nvidia.com/rdp/cudnn-download

In my case, I need CUDNN 7.5 which is made for CUDA 10.1

Installation guide can be found in the following link, ignore the last step, just copy files to corresponding folders will be fine.

https://docs.nvidia.com/cuda/cuda-installation-guide-microsoft-windows/index.html

*[Trick] When testing CUDNN, Error may occur:

CUDA driver version is insufficient for CUDA runtime version, congratulations, this means your system/ graphic card/ CUDA driver/ CUDA/CUDNN must have some version inconsistent.

I would give you some encouragement by saying this, let's have a look at the the top of this post and install the environment again, this is also what I did and my motivation to record the process in this post.




sudo apt install python3-pip


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Optional install:

Sougou pinyin

Reference: http://ubuntuhandbook.org/index.php/2016/07/2-best-chinese-pinyin-im-ubuntu-16-04/

Issue: Couldn't open sougou web page so can not download .deb file, Stuck, need to get it from my PC

Step1 : In terminal, type command

$sudo apt remove fcitx* && sudo apt autoremove



Windows10 下深度学习环境搭建

与在unbuntu下搭建深度学习环境(tensorflow)一样,由于tensorflow各个版本所需的CUDA driver +CUDA +CUDNN版本有特殊需求(这里不得不吐槽一下这个tensorflow版本控制做的稀烂,各种向上向下不兼容,很多人都是装到最后一步,测试tensorflow代码的时候,发现运行不了tensorflow, 要么找不到CUDA.xx.dll,要么specific module不能import。)在windows10里,我测试了两种安装方法,docker安装和一步步自己安装。

从底层开始一步一步安装

安装CUDA

如果要自己一步步装tensorflow,推荐的是装CUDA 9.0, CUDA10.0这种大版本,但是也不能保证一定不出问题。为了记录下遇到各种问题的解决方法,我特意装了CUDA 9.2,下文详述如何安装。所需的文件我会共享到百度网盘里去,方便大家下载(待更新)。如果想自己下载可以看上文linux安装里,给出了driver,cuda,cudnn的下载链接,不过你需要自己找到版本。

1. CUDA Driver  (398.82-desktop-win10-64bit-international-whql.exe)

要安装CUDA 9.2,需要安装对应的CUDA driver,见上文中的TABLE 1,由于我的CUDA 9.2下的是148版本,在Windows下需要398.82的driver版本。安装是否成功可以在命令行里用nvidia-smi命令确定,如果找不到这个命令,到你安装CUDA driver的文件夹里去找到这个exe程序添加到系统path变量里去。


如果看到你的显卡则安装成功,比如我有俩1080TI,则输出如下

2. CUDA (cuda_9.2.148_win10_network.exe)

装CUDA 之前要安装Visual Studio 2015,这个版本比较保险,如果你想使用Visual Studio 2017, 在安装CUDA 9.2时,自定义安装里不要选择与Visual Studio相关的子选项,不然你的CUDA会安装失败(我从网上查了好几,说这个已经broken for ages,所以其实我也不确定2015的就可以勾选。测试CUDA有没有安装完成,可以在CMD里使用nvcc -V,可以查看你安装的CUDA版本。

3 CUDNN(cudnn-9.2-windows10-x64-v7.5.1.10)

把文件夹里的各个文件copy到对应的cuda文件夹里,并把几个folder的路径也加入到path中去,你的cudnn安装就完成了(见上图)。

安装Tensorflow-gpu

我尝试用pip 安装了tensorflow-gpu的各个官方版本,1.10 -1.18装了个遍,然后在CMD里用 python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))" 测试安装成功与否,出现了找不到cuda9.0.dll,can't import module 等各种错误,主要原因就是CUDA不是大版本比如9.0或者10.0这样的,各种版本不兼容。这种情况下可能需要build from source,但是步骤很麻烦。所以给出一个别人build好tensorflow各种版本wheel的网址,大家可以根据自己的cuda版本和python版本及所需要的tensorflow版本自由选择。

https://github.com/fo40225/tensorflow-windows-wheel

由于我是CUDA9.2, python3.6.6版本的,希望使用的是tensorflow任一GPU版本,所以选择了

tensorflow_gpu-1.9.0-cp36-cp36m-win_amd64.whl 下载到本地,pip安装这个wheel后测试tensorflow成功。

一个容器一锅端

从说明来看,其实tensorflow-gpu不能在Windows系统上用docker,因为要启动NVIDIA GPU的docker容器,需要安装nvidia-docker,然后nvidia-docker目前仅适用于Linux,但是就我来说,我还是下载了Windows下的tensorflow-gpu待jupyter notebook的docker,并且测试成功了。我不确定是什么情况,是不是效率会低,因为还没有真正训练过一个模型,那么目前先写到这里,全测试完成后再来更新。

未完待续

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,491评论 5 459
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,856评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,745评论 0 319
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,196评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,073评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,112评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,531评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,215评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,485评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,578评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,356评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,215评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,583评论 3 299
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,898评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,174评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,497评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,697评论 2 335

推荐阅读更多精彩内容