1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > win10+ubuntu18.04双系统配置深度学习环境

win10+ubuntu18.04双系统配置深度学习环境

时间:2021-09-09 22:29:49

相关推荐

win10+ubuntu18.04双系统配置深度学习环境

目录

一、双系统安装

1、制作U盘启动盘

2、选择装机位置

3、用U盘装机

二、Windows系统下cuda10.1+cudnn+anoconda+pycharm+tensorflow+pytorch环境搭建

三、Ubuntu18.04系统下cuda10.1+cudnn+anoconda+pycharm+tensorflow+pytorch环境搭建

由于虚拟机对硬件支持不是太好,所以在笔记本上装了双系统,并配置了深度学习环境,折腾了近两天,现在做个简单记录。

一、双系统安装

1、制作U盘启动盘

可以先下载一个ubuntuxxx.iso文件,由于其官网速度可能会比较慢,这里以18.04版本为例,可以到国内镜像源网站直接下载,如/ubuntu-releases/18.04/。下载完成后,无须多疑,插上U盘(最后先将其格式化),点开ubuntu-18.04.5-desktop-amd64.iso文件,将里面的内容全部复制到U盘即可,当然也可以尝试用其他工具,但能简单一点怎就不简单一点。

2、选择装机位置

再在windows系统里面格式化一块分区用于装ubuntu系统,我这里将1T的机械硬盘分区成两个E和F,最后将系统装在了F盘。步骤大致如下图所示:

3、用U盘装机

大概就是重启进入bios,选择用U盘启动。这里大致如这般(进入boot后不同的电脑可能不一样,但目的都一样,将U盘设为启动的第一项)我这儿的示例图中由于时已经装了ubuntu系统的,也会稍有差别:

进入后,不出意外就会从U盘启动ubuntu系统,但意外总是会有的,本机是拯救者Y7000,独显RTX2060,在启动过程中,会出现花屏的现象。在进入ubuntu系统的时候按e,进入后,找到“quite splash”,在其后空一格输入nomodeset。

待其安装完成后,拔掉U盘,开机进入bios选择启动的系统,如果仍然出现花屏,先在GRUB界面,按e,找到“quite splash”,空一格输入nomodeset。进入系统后,在终端输入:sudo gedit /etc/default/grub,找到这行:GRUB_CMDLINE_LINUX_DEFAULT="quiet splash",改成:GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset" 保存文档,更新GRUB: sudo update-grub。至此,双系统就算安装完成。附上装双系统后windows时间不对的解决方法,在此表示感谢。

二、Windows系统下cuda10.1+cudnn+anoconda+pycharm+tensorflow+pytorch环境搭建

windows上安装cuda比较简单,电脑一般都已经安装好NVIDIA驱动,只需要安装cuda和cudnn即可,在Nvidia官网下载相应的版本,如windows下10.1如下图。

在Nvidia官网下载cudnn(需要先注册个账号),选择相应的版本,进行下载。这里以cuda10.1为例进行安装,由于官网可能网速比较慢,这里有百度网盘链接,密码li6f。下载完成后,双击exe进行安装。然后解压cudnn,将cudunn对应的lib64、include下的文件移动到的cuda10.1中,安装中如果没有修改路径应该是C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1。我安装的时候,自动加了环境变量,所以这里不再赘述。这里写得比较简略,具体可参考这篇博文,实属优秀,在此表示感谢。至此,cuda环境已有,接下来就是安装pycharm和anoconda,在此表示感谢。然后就是一堆conda命令,即可完成环境搭建,常用命令在此,在此表示感谢。完成环境搭建后,需要注意的是,搭建pytroch环境的时候,在其官网选择相应系统和版本后,推荐的安装指令中,去掉-c pytorch,就不会从pytorch官方下载源安装,而从conda配置的源(国内有很多的)中下载,速度应该会快一点。就是验证环境是否成功,tensorflow-gpu2.3.1和pytorch1.8.1的验证如下:

Microsoft Windows [版本 10.0.19041.867](c) Microsoft Corporation. 保留所有权利。C:\Users\lee>conda activate tf2(tf2) C:\Users\lee>pythonPython 3.8.0 (default, Nov 6 , 16:00:02) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32Type "help", "copyright", "credits" or "license" for more information.>>> import tensorflow as tf-04-04 20:54:47.962721: I tensorflow/stream_executor/platform/default/:48] Successfully opened dynamic library cudart64_101.dll>>> print(tf.__version__)2.3.1>>> print(tf.test.is_gpu_available())WARNING:tensorflow:From <stdin>:1: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.Instructions for updating:Use `tf.config.list_physical_devices('GPU')` instead.-04-04 20:55:15.952168: I tensorflow/core/platform/:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.-04-04 20:55:15.959075: I tensorflow/compiler/xla/service/:168] XLA service 0x28f1c8c9290 initialized for platform Host (this does not guarantee that XLA will be used). Devices:-04-04 20:55:15.959113: I tensorflow/compiler/xla/service/:176] StreamExecutor device (0): Host, Default Version-04-04 20:55:15.960597: I tensorflow/stream_executor/platform/default/:48] Successfully opened dynamic library nvcuda.dll-04-04 20:55:15.991689: I tensorflow/core/common_runtime/gpu/:1716] Found device 0 with properties:pciBusID: 0000:01:00.0 name: GeForce RTX 2060 computeCapability: 7.5coreClock: 1.2GHz coreCount: 30 deviceMemorySize: 6.00GiB deviceMemoryBandwidth: 245.91GiB/s-04-04 20:55:15.991837: I tensorflow/stream_executor/platform/default/:48] Successfully opened dynamic library cudart64_101.dll-04-04 20:55:15.995591: I tensorflow/stream_executor/platform/default/:48] Successfully opened dynamic library cublas64_10.dll-04-04 20:55:15.998593: I tensorflow/stream_executor/platform/default/:48] Successfully opened dynamic library cufft64_10.dll-04-04 20:55:15.999658: I tensorflow/stream_executor/platform/default/:48] Successfully opened dynamic library curand64_10.dll-04-04 20:55:16.003465: I tensorflow/stream_executor/platform/default/:48] Successfully opened dynamic library cusolver64_10.dll-04-04 20:55:16.005307: I tensorflow/stream_executor/platform/default/:48] Successfully opened dynamic library cusparse64_10.dll-04-04 20:55:16.012095: I tensorflow/stream_executor/platform/default/:48] Successfully opened dynamic library cudnn64_7.dll-04-04 20:55:16.012257: I tensorflow/core/common_runtime/gpu/:1858] Adding visible gpu devices: 0-04-04 20:55:16.448161: I tensorflow/core/common_runtime/gpu/:1257] Device interconnect StreamExecutor with strength 1 edge matrix:-04-04 20:55:16.448257: I tensorflow/core/common_runtime/gpu/:1263]0-04-04 20:55:16.448366: I tensorflow/core/common_runtime/gpu/:1276] 0: N-04-04 20:55:16.449417: I tensorflow/core/common_runtime/gpu/:1402] Created TensorFlow device (/device:GPU:0 with 4722 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2060, pci bus id: 0000:01:00.0, compute capability: 7.5)-04-04 20:55:16.452087: I tensorflow/compiler/xla/service/:168] XLA service 0x28f4e1093c0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:-04-04 20:55:16.452238: I tensorflow/compiler/xla/service/:176] StreamExecutor device (0): GeForce RTX 2060, Compute Capability 7.5True>>> exit()(tf2) C:\Users\lee>conda activate pytorch(pytorch) C:\Users\lee>pythonPython 3.8.8 (default, Feb 24 , 15:54:32) [MSC v.1928 64 bit (AMD64)] :: Anaconda, Inc. on win32Type "help", "copyright", "credits" or "license" for more information.>>> import torch>>> print(torch.__version__)1.8.1>>> print(torch.cuda.is_available())True

三、Ubuntu18.04系统下cuda10.1+cudnn+anoconda+pycharm+tensorflow+pytorch环境搭建

Ubuntu系统下环境的搭建比windows下多了某些步骤,下载部分同windows,这里同样以cuda10.1为例,附上链接,提取码:4ilr 。过程可见/ithinking110/article/details/105144202/,其中包含了cuda及cudann的安装,环境变量等等,在此表示感谢。但在安装前需要进入bios禁掉secure boot,我是在禁掉之后才安装成功的,还有就是我安装cuda是通过deb方式安装的,可参见nvidia官网,具体如下:

wget https://developer./compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pinsudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600wget https://developer./compute/cuda/10.1/Prod/local_installers/cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.debsudo dpkg -i cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.debsudo apt-key add /var/cuda-repo-10-1-local-10.1.243-418.87.00/7fa2af80.pubsudo apt-get updatesudo apt-get -y install cuda

安装完成后验证同windows,这里不再赘述。至此,双系统windows10+ubuntu18.04+深度学习环境就已经搭建好了,就这些东西,两天的时间东拼西凑,但总有不成功的时候,这里进行汇总。对于文中提到的链接,这里再次表示感谢。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。